简体   繁体   中英

C# compiler is picking the wrong assembly for a type

We have recently split some shared code from one assembly into two assemblies both named differently from the original. When updating an application I have removed all references to the old assembly and added references to the two new assemblies. When compiling the code it tells me I must add a reference to the old assembly for some of the types even though those types are defined in one of the new assemblies.

The type 'ICustomerDetails' is defined in an assembly that is not referenced. You must add a reference to assembly 'OldAssembly, Version=xxxx, Culture=neutral, PublicKeyToken=xxxx'.

Example Code

using newAssemblyOne; -resharper says it not needed
using newAssemblyTwo;

....

var obj = customer.Details;

customer is an interface defined in newAssemblyTwo which the compiler is happy with. Details is an interface of type ICustomerDetails defined in newAssemblyOne which the compiler is complaining about.

customerDetails works fine when ran from newAssemblyTwo . the application and both assemblies all have the same target framework.

Any help would be appreciated

I had been provided the wrong version of one of the assemblies

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM