2

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.

webaware
  • 2,795
  • 2
  • 30
  • 37
JD Roberson
  • 589
  • 3
  • 7
  • 25
  • This is partially covered here - http://stackoverflow.com/questions/4445188/using-two-dlls-with-same-name-and-same-namespace - it's not trivial, really. However, if the DLL's are strongly named, I'd imagine you might be able to get away with it. – dash Feb 05 '13 at 13:30

1 Answers1

5

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/

Lloyd
  • 29,197
  • 4
  • 84
  • 98
  • how can I do this on a precompiled dll that uses it as a dependency? – JD Roberson Feb 05 '13 at 14:33
  • AFAIK you can't do it on a precompiled library, there's no way of telling it to use one namespace over another, that's done at compile time :/ – Lloyd Feb 05 '13 at 14:42