Ok。私はそれを考え出した。私の目的では、これはアセンブリの単純な型の検出であり、インスタンス化は行われていないため、Assembly.ReflectionOnlyLoad を使用すると、アセンブリが 32 ビットの場合に機能します。
Assembly.ReflectionOnlyLoad を使用してアセンブリをロードすると、型を反映することができます。AppDomain.CurrentDomain.ReflectionOnlyLoadResolve にもフックする必要があります。
属性名を取得するには、型、メソッド、またはモジュールで CustomAttributeData.GetCustomAttributes を使用する必要があります。
static void Main(string[] args)
{
AppDomain.CurrentDomain.ReflectionOnlyAssemblyResolve += new ResolveEventHandler(CurrentDomain_ReflectionOnlyAssemblyResolve);
Assembly assm = Assembly.ReflectionOnlyLoadFrom("TestProject1.dll");
Type t = assm.GetType("TestProject1.ProgramTest");
MethodInfo m = t.GetMethod("MainTest");
IList<CustomAttributeData> data = CustomAttributeData.GetCustomAttributes(t);
}
static Assembly CurrentDomain_ReflectionOnlyAssemblyResolve(object sender, ResolveEventArgs args)
{
return Assembly.ReflectionOnlyLoad(args.Name);
}