Getting “type or namespace name could not be found” but everything seems ok?

后端 未结 30 1520
北海茫月
北海茫月 2020-11-22 09:27

I\'m getting a:

type or namespace name could not be found

error for a C# WPF app in VS2010. This area of code was compiling fine

30条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-11-22 09:39

    I got this error trying to make a build with a Visual Studio Team Services build running on my local machine as an agent.

    It worked in my regular workspace just fine and I was able to open the SLN file within the agent folder locally and everything compiled ok.

    The DLL in question was stored within the project as Lib/MyDLL.DLL and references with this in the csproj file:

    
      False
      Lib\MYDLL.dll
    
    

    It turned out it literally just wasn't finding the file despite the hint path. I think maybe msbuild was looking relative to the SLN file instead of the project file.

    In any case if the message you get is Could not resolve this reference. Could not locate the assembly then make sure that the DLL is in an accessible location to msbuild.

    I kind of cheated and found a message that said Considered "Reference\bin\xxx.dll" and just copied the dlls into there instead.

提交回复
热议问题