简体   繁体   中英

Can't build release configuration because of 'missing' references

I've got a solution containing 6 or so projects which all build fine when in debug configuration. However, when I try and build it in release mode, I get 53 errors all complaining that DLL's can't be found. This is just a few of the messages:

Errors:

  • 'AnimatedSplashScreen' does not contain a definition for 'Message' and no extension method 'Message' accepting a first argument of type 'AnimatedSplashScreen' could be found (are you missing a using directive or an assembly reference?)
  • The name 'DataContext' does not exist in the current context.
  • The name 'InitializeComponent' does not exist in the current context.
  • The tag 'MetroProgressBar' does not exist in XML namespace 'clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro'.39

Warnings

  • Could not resolve this reference. Could not locate the assembly "EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors.
  • Could not resolve this reference. Could not locate the assembly "Fluent, Version=3.5.1.198, Culture=neutral, PublicKeyToken=3e436e32a8c5546f, processorArchitecture=MSIL". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors.
  • Could not resolve this reference. Could not locate the assembly "GalaSoft.MvvmLight, Version=5.2.0.37222, Culture=neutral, PublicKeyToken=e7570ab207bcb616, processorArchitecture=MSIL". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors.

How do I start to fix this?

The debug paths have been left as they are, but each project release path has been set to build into a specific folder.

EDIT: This is what my Error List looks like. All of the errors appear to be related to third party packages. 错误和警告

I had a similar problem. Project builds fine in Debug mode but in Release mode some references were missing.

I found out, the dll's of the missing references were all located in the bin/debug folder. I moved them towards a neutral location, added them again to the project and the problem was solved.

As pointed out by Filburt. There were some broken reference paths in the project files. After correcting these paths, everything builds as expected.

Not sure how they got broken to begin with though. Any thoughts?

My problem with this was that the referenced library had the "allow unsafe code" checkbox checked, but on the release build it wasn't checked. The error of not allowing unsafe code was not visible.

Go to your "References" under your project when you have the error. Delete the reference that the compiler complains about. Add it again.

That should fix the broken references.

I was facing the same issue when I changed from Debug to release mode. I was trying different suggestions posted above but nothing has solved the issue. However, for me, when I did right click on Reference > Migrate packages.config to PackageReference... select OK, it started working.

右键单击引用

I had same problem after I renamed one of classes in a referenced project. I tried all [well, most] suggestions posted here, but none of them worked. I finally unloaded the projects that had errors and just reloaded them again, and all errors were gone!

For the other searchers who will reach this post. I also figured out a issue, that maybe the references library is not having the matching .NET version! It is also worth a short check...

删除“.vs”文件夹是我的解决方案。

I had the similar issue and I did not find any of the solution mentioned above.

But this is what I tried and it fixed my issue.

  1. Go to the bin folder of your project. Delete all the files.
  2. Go to the packages folder. Inside delete all the files. Files that you could not delete ignore them. For me I wasn't able to clean FxCop.
  3. Now go back to Visual Studio. Make sure you are still selected Debug for build.
  4. Clean Build.
  5. Rebuild
  6. If you find any missing dll, then try to download the nuget package for that. I had the issue with Dapper. I made sure I am installing the appropriate version for the framework that I am using.
  7. Build.
  8. Build should be successful.
  9. Now rebuild in "Relase" mode. Hopefully you won't see the issue.

I had a similar experience. I could build in Debug mode but not in Release mode. The broken references were all to dlls in a shared library directory.

I had moved my project to a different directory. To fix the issue, I corrected the <HintPath> in my.csproj file.

Adding this, since I see there might be multiple solutions for each problem.

Experiencing the same issue - after transferring the project's solution from one PC to another - changing the output path from Properties > Build > Output fixed this issue.

The problem was that during the publish process, VS was looking for the application files in a folder that they were not generated at (By default it is /bin/[Project Name Folder]/ ).

So I changed this output path value to /bin/Release/ folder and everything worked like charm.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM