0

I have an ASP.NET MVC application, that needs to reference a number of assemblies that contain the same namespace and types, for example: ProductSdkBe.DLL, ProductSdkIt.DLL, etc. In fact, they are about the same assemblies with same types, but differ in implementation details.

I found that this could be done with 'extern alias' as described at two different DLL with same namespace, but it doesn't work. So what I did:

  1. From my ASP.NET MVC application, reference the assemblies
  2. For each assembly, set the alias (instead of the default global)
  3. Put extern alias on top of file

I always get error: 'The extern alias was not specified in a /reference option'.

I then tried the solution of The extern alias 'xxx' was not specified in a /reference option and added the following to the project file:

 <Target Name="solveAliasProblem" >
<ItemGroup>
  <ReferencePath Remove="D:\path\EC.ProductServices.Sdk_be.dll"/>
  <ReferencePath Include="D:\path\EC.ProductServices.Sdk_be.dll">
    <Aliases>ProductSdkBe</Aliases>
  </ReferencePath>
</ItemGroup>
<ItemGroup>
  <ReferencePath Remove="D:\path\EC.ProductServices.Sdk_it.dll"/>
  <ReferencePath Include="D:\path\EC.ProductServices.Sdk_it.dll">
    <Aliases>ProductSdkIt</Aliases>
  </ReferencePath>
</ItemGroup>

but then it gives the error:

An assembly with the same simple name 'EC.ProductServices.Sdk, Version=1.0.0.1, Culture=neutral, PublicKeyToken=null has already been imported. Try removing one of the references or sign them to enable side-by-side. EC.ProductServices.Sdk_be.dll.

What am I doing wrong?

Community
  • 1
  • 1
L-Four
  • 13,345
  • 9
  • 65
  • 109
  • have you thought about Aliasing the assemblies so that you can insure that the right methods / functionality are being implemented..?? – MethodMan Feb 16 '12 at 16:08
  • do you mean step 2 that I described? – L-Four Feb 16 '12 at 16:50
  • lets say that you have a reference using System.Generics for example and to alias that you would do using GEN = System.Generics so in your case if you have a using that references the 3 individual references use Aliases then in code if you were to use that reference to new something up ..you would use the Alias name as the new ... Alias does that make sense.. – MethodMan Feb 16 '12 at 17:58
  • I think you don't understand my question, which is about EXTERN alias – L-Four Feb 17 '12 at 07:27

0 Answers0