CS0012 (missing assembly reference) but assembly is referenced!

bri189a

Senior Contributor
Joined
Sep 11, 2003
Messages
1,004
Location
VA
The solution compiles fine, but when running I get a CS0012 error. The supposed missing reference is indeed referenced. This started occurring when added some implict operators...here's the scenerio:

in namespace CompanyName.Whatever1 there is a class called X; in namespace CompanyName.Whatever2 there is also a class called X. These two classes our highly coupled (purposefully) but *are* indeed seperate objects (let's not get into this design, it's a problem that's being addressed).

Anyway these two 'X' object have to be pretty interchangable so we're using implicit casting. This is all fine and well, and again works fine, but now at runtime when you go to create an instance of Whatever1.X you get CS0012 saying you need to add a reference to CompanyName.Whatever2.dll Verision 1.0.0.0 blah blah...and this is what is referenced in the assembly references!!! It compiles just fine, so I don't understand why we're getting the runtime error.

I have a zip I can email that demonstrates the behavior if you think you can help. (too large to attach to post)

Thanks
 
When the code is compiled, for any reference that is made to any type the IL explicitly declares the name of the module, namespace, and the class that is being referenced. I'm curious to see what the compiled IL looks like. I don't see how there can any sort of naming conflict. Could it possibly be a versioning issue? Would it be possible for you to use Reflector to decompile the code that is throwing the exception and post it here?
 
Last edited:
Is there, by chance, a circular reference between the two projects? Do you have them setup as project references or file references?

If you have file references and a circular reference, as well as having the assemblyInfo files having a hard-coded version number, you might get this error. It's just a guess, but that's mine.

You can email me the project at nerseus at google mail dotcom (you know the one, gmail.com). If you do, please include some basic instructions for setting it up. You can often reduce the size of project by removing the bin and obj folders, if that helps.

-ner
 
Back
Top