Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# type defined in an assembly that is not referenced

I have two projects A and B. Project A makes use of type X in project B, so I have a reference to B added in A. Everything built fine.

I signed project B using a strong named key file. Everything still built fine.

Then I decided to change the strong named key file for B. I rebuilt project B ok. When I try to build project A I receive the error "Error 1 The type X is defined in an assembly that is not referenced. You must add a reference to assembly B, Version=1.0.0.0, Culture=neutral, PublicKeyToken=95b41b0d6571627b'. "

So I deleted the reference in project A and added it back in again, no joy. I can dbl click on the project B reference in project A, open the object browser and see type X in there ok. I also fully qualified the type X objects in A and the intellisense picked them up fine but it still does not build.

I thought that changing the key file I might need to up the revision, so I changed assembly B version to 2.0.0.0 but still A complains that it needs version 1.0.0.0. Looking at the properties of the B reference in A it definitely points to the correct version and indeed it shows as 2.0.0.0

I could live with using the existing key file but i'd like to understand where I am going wrong if possible.

like image 376
CSharpHolder Avatar asked Aug 07 '10 20:08

CSharpHolder


1 Answers

What worked for me was to remove the reference to the project, then add it back in again. A new error message appeared stating that I needed a reference to a third library that was missing, so the original message was a bit misleading!

like image 192
Norman H Avatar answered Sep 27 '22 23:09

Norman H