我有一个c#静态类:
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);
}
基本上它加载了一些我需要在设置自定义属性(SialBaseType)时探索的程序集,如下所示:
[Serializable]
[SialBaseType("SialMinBaseType", true)]
public abstract class SialMinBaseType : BEBase
{
#region Property
/// <summary>
/// Identificativo univoco dell'oggetto
/// </summary>
public string Id { get; set; }
...
问题是有时候我可以获得自定义属性数据,有时候不会...而且我无法弄清楚为什么......
在这种情况下:
2)问题给了我&#34;找不到方法:&#39; Void NETA.SUITE.SIAL.Tipi.Base.SialBaseTypeAttribute..ctor(System.String)&#39;。&#34;。 ;: