Analyze 64-bit DLL from within T4 template in Visual Studio (32-bit) using Reflection

怎甘沉沦 提交于 2019-12-04 16:46:27

A thing worth testing is that if loading an assembly for reflection only works for you. I did experiment a bit and it seems it succeeds loading a 64bit assembly into a 32bit process then. It can't execute obviously but that should be ok for you if I understood you correctly:

For the full sample look at: https://github.com/mrange/CodeStack/tree/master/q18985529/Reflect

var assembly = Assembly.ReflectionOnlyLoad ("X64");

var types = assembly.GetTypes ();

foreach (var type in types)
{
    Console.WriteLine (type.FullName);

    foreach (var field in type.GetFields ())
    {
        Console.WriteLine ("  {0} {1}", field.FieldType, field.Name);
    }

    foreach (var property in type.GetProperties ())
    {
        Console.WriteLine ("  {0} {1}", property.PropertyType, property.Name);
    }

}

Loading for ReflectionOnly has some drawbacks IIRC but sometimes it's worth it.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!