2

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 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).

5
  • 1
    Isn't that article referring to externals rather than .DLLs created by projects in your same solution? "I have two C# projects (launcher and adaptor) under one solution." - why not just use a project reference rather than an explicit file reference to the DLL in the "debug folder"? That way VS knows about project dependencies and build order which I suspect is your problem described above
    – user585968
    Jan 29, 2015 at 4:29
  • @MickyDuncan: Using project references can cause problems if the .csproj file is used outside of Visual Studio in an automated build system. At least that's my experience - I've seen MSBuild performing unexpected builds of the referenced project in situations where I only wanted to build the single project defined by the .csproj file.
    – RenniePet
    Jan 29, 2015 at 5:37
  • @RenniePet How do I target a specific .NET project within a Solution using MSBuild from VS2010?. I find it works with VS2013 too
    – user585968
    Jan 29, 2015 at 5:50
  • @MickyDuncan: No, what I'm saying is that I have experienced that a build system based on invoking MSBuild n times for n projects, by specifying the .csproj file to MSBuild each time, was sometimes unexpectedly (for me, at least) performing additional builds of projects that were referenced via project references instead of dll references. But it's only relevant if you are using some kind of build system outside of Visual Studio. Anyway, I became allergic to project references after that experience.
    – RenniePet
    Jan 29, 2015 at 5:57
  • @RenniePet Yes no problem. We found the external builds to differ when msbuild was targeting the .csproj directly. Dependencies would not build. We moved to msbuild'ing against the .sln with /t and msbuild would correctly build dependencies even if we told it to build a single project which was rather nice.
    – user585968
    Jan 29, 2015 at 6:04

1 Answer 1

2

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:

  1. 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!

  2. 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!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.