Visual Studio Build seems not to use current proje

2019-08-27 20:52发布

I am using Visual Studio 2017 Enterprise, C# 4.7.2

My Solution contains currently nine different projects. A build succeeds without any error messages. When I run the application, a TypeLaodException is thrown, The Type Namespace.AClassName could not be loaded.

The weird thing is, that there isn't any class named AClassName anymore. BUT, the mentioned class did exist in a former version.

I cleaned the solution, startet a build, same error. I rebuilt the solution, same error. Cleaned than rebuilt the solution, same error.

Apparently, the build is not correct. But what can I do to ensure, that the build runs correctly?

2条回答
Melony?
2楼-- · 2019-08-27 21:14
  1. Clean Solution.
  2. Clean Debug & Bin folder.
  3. Make sure all project reference are from Project libraries (it should not be directly from Bin folder).
  4. Make sure all interconnected project build on same .net platform (4 , 4.5 or 4.6 ).
  5. Build and try to run.
查看更多
成全新的幸福
3楼-- · 2019-08-27 21:20

If manually deleting the folders bin and obj as suggested in the comments is not working, I will also delete de .vs and there are a few things you can try:

  • Unload the projects, and search in the .csproj for any reference to the Old-Deleted AClassName. Check also that there is no namespace related to it.
    You will have to do it in the project where originally was the class, but I will recommend to search in all 9 projects.
  • Check if there is any Project Dependency in the Configuration Manager related to the project where the AClassName was.
  • I would also restart my machine, delete temp folder and run VS As administrator.
查看更多
登录 后发表回答