Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I've seen this: VSTS 2010 SGEN : error : Could not load file or assembly (Exception from HRESULT: 0x80131515) 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:

<configuration>
 <runtime>
   <loadFromRemoteSources enabled="true" />
 </runtime>
</configuration>

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.

like image 914
SventoryMang Avatar asked Dec 15 '11 17:12

SventoryMang


4 Answers

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

like image 67
Aymeric Gaurat-Apelli Avatar answered Nov 17 '22 10:11

Aymeric Gaurat-Apelli


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

like image 28
hawkke Avatar answered Nov 17 '22 09:11

hawkke


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.

like image 10
BardMorgan Avatar answered Nov 17 '22 08:11

BardMorgan


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.

like image 9
Mbeware Avatar answered Nov 17 '22 10:11

Mbeware