我试图调试使用反射来加载插件一些code
I'm trying to debug some code that uses reflection to load plugins
下面是调试code:
Type a = methodInfo.GetParameters()[0]
.ParameterType.BaseType;
Type b = typeof(MessageContext);
Debug.WriteLine(a.AssemblyQualifiedName);
Debug.WriteLine(b.AssemblyQualifiedName);
Debug.WriteLine(a.Equals(b));
这里是它的输出:
And here is its output:
OrtzIRC.Common.MessageContext,OrtzIRC.Common,版本= 1.0.0.0,文化=中性公钥=空 OrtzIRC.Common.MessageContext,OrtzIRC.Common,版本= 1.0.0.0,文化=中性公钥=空 假
OrtzIRC.Common.MessageContext, OrtzIRC.Common, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null OrtzIRC.Common.MessageContext, OrtzIRC.Common, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null False
我不明白什么使这两类不同?
I don't understand what would make these two types different?
由不同的应用程序域[.NET]或类加载器【JAVA]不会比较平等的,不分配给/相互加载的同一类/类型直接。
The same class / type loaded by different app domains [.NET] or class loaders [Java] will not compare equal and are not assignable to/from each other directly.
您可能必须包含该类型的DLL的两个副本 - 一个由主程序加载并一个接的一个被载入的Assembly.Load *(......)
方法?
You likely have two copies of the DLL containing that type - one loaded by the main program and one loaded by one of the Assembly.Load*(...)
methods?
尝试显示/比较特性:
a.Assembly.Equals(b.Assembly)
和
a.Assembly.Location.Equals(b.Assembly.Location)
Try displaying / comparing the properties:
a.Assembly.Equals(b.Assembly)
and
a.Assembly.Location.Equals(b.Assembly.Location)
在一般情况下,你只需要每个DLL的一个副本,并把它装成一个单一的应用程序域。
In general, you only want one copy of each DLL and have it loaded into a single app domain.