Could not load file or assembly HRESULT: 0x80131515 (When adding controller to MVC project that has assembly references on network drive)

asp.net MvcVisual Studio-2010Assemblies.Net Assembly

asp.net Mvc Problem Overview


I've seen this: https://stackoverflow.com/questions/3007190/vsts-2010-sgen-error-could-not-load-file-or-assembly-exception-from-hresult and none of the answers work. It also doesn't appear when I build or anything. I can run the project fine, it happens when I try to add an entity framework templated controller:

controller settings

Then I get this error:

error message

All project files are on my network share because that is where My Documents resides for our work. Here is what I tried:

  1. Turning Generator Serialization Assembly in project settings to on, off, and auto.

  2. Adding sgen.exe.config to C:\Program Files\Microsoft SDKs\Windows\v7.0A\bin\NETFX 4.0 Tools with the following code:

  3. Tried to unblock the assemblies, but I had no unblock option in the properties tab. no unblock option

None of these solutions work. Does anyone have any idea how I can fix this??? This error occurs for any custom assembly from nuget or my own projects due to their location existing on the network space, but only when trying to add an EF templated controller. I can build and run the program fine.

asp.net Mvc Solutions


Solution 1 - asp.net Mvc

I just needed to click "Unblock" in the file properties dialog in Windows Explorer.

Solution 2 - asp.net Mvc

Try adding your <loadFromRemoteSources enabled="true" /> to C:\[Visual Studio 2010 Install Dir]\Common7\IDE\devenv.exe.config directly below <runtime> and see if that helps :)

Solution 3 - asp.net Mvc

Just as an additional solution, we had an issue like this recently. The solution turned out to be unblocking the files, but with a twist. We copied the files to our server in a zip file. When we extracted the files from the zip archive, they were already blocked. We were not able to unblock the files. We would click the unblock button, then OK, and when we looked at the properties, they were still blocked.

What we had to do is delete all the blocked files, unblock the source zip file, and then extract the files. At that point, the formerly blocked files were unblocked, and the application ran fine. Hope that helps someone avoid some frustration.

EDIT: I believe you also have to be running windows explorer as administrator to be able to unblock files.

Solution 4 - asp.net Mvc

This issue comes from the fact that some required files are on "untrusted location" such as the network or a shared location (even on the same computer). If the location is on the same computer, you can use the subst command line option.

Solution 5 - asp.net Mvc

These solutions did not work for me either.

In my case, I was accessing files on a mapped network drive. The solution for me was to add my network IP address as a trusted drive by doing the following:

  1. Control Panel
  2. Network and Sharing Center
  3. Internet Options (bottom left of window)
  4. Security Tab
  5. Select "Local intranet"
  6. Click "Sites" button
  7. Click "Advanced" button
  8. Add the IP of your network drive to the zone.

Not sure what made this work over all other options, but this is what solved the problem for me. All project and solutions now build with no issues.

Solution 6 - asp.net Mvc

I saw from other forum regarding this issue, and here is the solution someone posted: On the property of the project that contains the DLL assembly that would not load, go to the Build setting, and way at the bottom where it says "Generate serialization assembly:", the default is Auto. Set that to Off. Your solution should then build OK.

This happened to me when I had the API in a webform solution with multiple project. It worked OK on a single-project solution MVC.

Solution 7 - asp.net Mvc

None of these solutions worked for me. Instead, I found the way by making sgen.exe.config via https://stackoverflow.com/a/3407750/516512

Solution 8 - asp.net Mvc

  1. I just needed to click "Unblock" in the file properties dialog.

  2. Please check if your file read only, then uncheck it and do the first step (before wasting further time on this :) )

Solution 9 - asp.net Mvc

The other answers here helped me to figure out this issue in PowerShell. Run Unblock-File <filename> to allow it to be accessed by the script being executed.

Solution 10 - asp.net Mvc

Try to unblock the file desbloquer.

This solved my problem.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionSventoryMangView Question on Stackoverflow
Solution 1 - asp.net MvcAymeric Gaurat-ApelliView Answer on Stackoverflow
Solution 2 - asp.net MvchawkkeView Answer on Stackoverflow
Solution 3 - asp.net MvcBardMorganView Answer on Stackoverflow
Solution 4 - asp.net MvcMbewareView Answer on Stackoverflow
Solution 5 - asp.net Mvcbrendo234View Answer on Stackoverflow
Solution 6 - asp.net MvcYogiView Answer on Stackoverflow
Solution 7 - asp.net MvcFarshidView Answer on Stackoverflow
Solution 8 - asp.net MvcavulosundaView Answer on Stackoverflow
Solution 9 - asp.net MvcAndaciousView Answer on Stackoverflow
Solution 10 - asp.net MvcGerardo Ramirez RiofrioView Answer on Stackoverflow