Reputation: 71
It seems many ppls getting this kind of errors:
the type or namespace name 'data' does not exist in the namespace "xxx.yyy.zzz" (are you missing an assembly reference?)
I have searched everywhere I can trying to find a solution to it. It turns out that there are many causes for this error to occur.
I have two c# projects (launcher and adaptor) under one solution. The error is related to the namespace defined in the adaptor dll and referenced in launcher console app.
setup & environment:
target framework: 4.51
platform target: x64
Adaptor dll was built and placed in the debug folder of adaptor
Reference in launcher was added to point to the adaptor dll;
Symptome:
Rebuilding both projects separately, Ok;
When I rebuilt the solution, I got the error;
When I did a clean and build, I got the error;
If I built it a again, it succeeded;
Here are what I tried without success: Adaptor reference property's "copy to local"=T/F and no luck; Changing the adaptor reference property's "specific version"=T/F and no luck;
The strange thing is that error appears after a clean build or rebuild and then disappears in subsequent build (even if I made minor changes, and save all).
Upvotes: 2
Views: 4866
Reputation: 71
I have tried many changes suggested by others and none is working for this problem. These include changes to target frameworks, platform, "Copy to Local", set reference path etc.
Here is how I solve this problem using two methods:
Add reference to project adaptor from launcher. In launcher, right click then "add reference", then select "project" under solution in the dialog, check the adaptor project (the actual reference is the csproj, not dlls). hit Ok , rebuild and smile; This is the preferred method: adding project reference not file reference. Simple and easy!
This trick comes from MikeTeeVee (more steps involved): While I was writing this, something came to my attention: Storing referenced Dlls in visual studio solution folder
By creating a solution folder (virtual) linked to a physical folder containing all the to-be-referenced dlls, it resolved the above problem. Somehow, adding a reference to the dlls in the debug folder in adaptor doesn't work. And the virtual solution folder helps to resolve the reference problem.
So I share these with those who might have similar problem. GLTA!
Upvotes: 2