I've got a c# static class which does:
public static class AssStaticHelp
{
static private List<Type> Tipi=new List<Type>();
public static string searchManagerMethod = @"C:\StoredWeb\StoredWeb\searchManagerMethod";
public static List<Type> GetTipi()
{
AppDomain currDomain = AppDomain.CurrentDomain;
currDomain.ReflectionOnlyAssemblyResolve += new ResolveEventHandler(HandlerMethodTipi);
if (currDomain.ReflectionOnlyGetAssemblies().Length == 0)
Tipi = new List<Type>();
if (Tipi.Count == 0) {
currDomain.ReflectionOnlyAssemblyResolve += new ResolveEventHandler(HandlerMethodTipi);
DirectoryInfo di = new DirectoryInfo(searchManagerMethod);
foreach (FileInfo f in di.GetFiles("*.dll"))
{
Assembly ass = Assembly.ReflectionOnlyLoadFrom(f.FullName);
Type[] listType = ass.GetTypes();
if (listType.Length > 0)
{
Tipi.AddRange(listType);
}
}
}
return Tipi;
}
private static Assembly HandlerMethodTipi(object sender, ResolveEventArgs args)
{
AssemblyName assName = new AssemblyName(args.Name);
string fileName = Path.GetFullPath(searchManagerMethod + "\\" + assName.Name + ".dll");
if (File.Exists(fileName))
{
return Assembly.ReflectionOnlyLoadFrom(fileName);
}
return Assembly.ReflectionOnlyLoad(args.Name);
}
Essentially it loads some assembly I need to explore when a custom attribute (SialBaseType) is set, like this:
[Serializable]
[SialBaseType("SialMinBaseType", true)]
public abstract class SialMinBaseType : BEBase
{
#region Property
/// <summary>
/// Identificativo univoco dell'oggetto
/// </summary>
public string Id { get; set; }
...
the problem is sometimes I can get the custom attribute data, sometimes not...and I can't figure out why...
here's the situation:
the problem which gives me
"Method not found: 'Void NETA.SUITE.SIAL.Tipi.Base.SialBaseTypeAttribute..ctor(System.String)'."
: