3

I need to call a specific function from Castle.Core.dll but it seems as though AutoMapper and Moq have Castle.Core merged into their assemblies.

This is what I need to call

Castle.DynamicProxy.Generators.AttributesToAvoidReplicating.Add(typeof(System.Security.Permissions.UIPermissionAttribute));

But I get an Ambiguous reference because Castle.Core is technically available in 3 locations (AutoMapper, Moq, and the standalone DLL)

I can't simply un-ref any of the dlls because they are all managed by NuGet and Castle.Core standalone is needed for NHib and the other dlls are what were pulled in by the AutoMapper and Moq nuget packages.

Any suggestions? other then not depending on NuGet for managing my library refs?

Jon Erickson
  • 112,242
  • 44
  • 136
  • 174
  • 1
    Since AutoMapper and Moq are both open-source, you may be able to rebuild them from source in a way that doesn't embed the Castle.Core.dll into their output DLL. This way there will only be one instance of the Castle.Core assembly loaded and the ambiguity goes away. – Dan Bryant Apr 12 '11 at 17:29
  • @Dan, that is definitely an option, but I'd like to simply use what gets installed through NuGet, and the unmerged AutoMapper library isn't available in NuGet. I think jbogard even releases a version of AutoMapper that is unmerged with external libraries, so I wouldn't even need to compile from source. – Jon Erickson Apr 12 '11 at 18:44

2 Answers2

2

You could try using extern aliases. You can find it as a property on your Assembly references.

Look at this question for detail:
What use is the Aliases property of assembly references in Visual Studio 8

Community
  • 1
  • 1
Botz3000
  • 39,020
  • 8
  • 103
  • 127
0

You could allays call it by reflection by enumerating the types of the correct assembly.

rerun
  • 25,014
  • 6
  • 48
  • 78