问题
I am trying to use an application called DynamicDashboards to create a stats dashboard at work. This is precompiled using two other dependencies Ext.Net 1.5.0.0 and Newtonsoft.Json 4.0.8.0. At the same time I am trying to use a newer version of Ext.Net 2.1 to build some modules which requires Newtonsoft.Json 4.5.0.0.
Since in both cases the DLL's have the same name and most of the same types I am getting errors about types being available in both DLL's and/or the wrong version is loaded.
How can I use DynamicDashboards with Ext.Net 2.1 and resolve the conflicts? I do not have the source for DynamicDashboards, I do have the source for Ext.Net and Newtonsoft.Json.
回答1:
Reference both assemblies. Select each on in the Solution Explorer and look at the properties. There should be an Aliases
property. Usually this is set to global
, however you can change and/or add to this. For example call the first reference Lib1
and the second Lib2
.
In your C# you must then put an extern to it, such as:
extern alias Lib1;
You can then reference each individual assembly, like this:
Lib1::Some.Namespace.Type
Lib2::Some.Namespace.Type
If you'd like a better explaination of this read this blog post - http://www.lloydkinsella.net/2012/07/13/extern-alias-underused-or-unknown/
来源:https://stackoverflow.com/questions/14708633/using-two-different-versions-of-the-same-dll-in-an-asp-site-using-two-sdks