VSTS 2010 SGEN : error : Could not load file or assembly (Exception from HRESULT: 0x80131515)

喜欢而已 提交于 2019-11-28 03:21:48

I was able to fix this error by finding the assembly DLL in Windows Explorer, right clicking, choosing Properties, and then pressing the "unblock" button. The DLL has a stream that is marking it as an external file - and by clicking unblock you remove that designation.

Martin Hyldahl

I just had the same/similar issue on a TFS build server where a build was referencing dll's from a network share.

The problems is that the CLR v4 security policy model has changed since previous versions and are not sandboxing assemblies as before.

To fix your issue just find the location of sgen.exe and create a sgen.exe.config in the same folder with following contents:

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

sgen.exe is usually at

"C:\Program Files\Microsoft SDKs\Windows\v[current version]\bin\NETFX 4.0 Tools"

You can read about some of the changes around CAS policies in .NET 4.0 in this blogpost: Link

Had the same problem and the config change didnt work. Only when i set Generate Serialization Assembly to off in the project properties did it work.

I had the same error and found my DLL was "blocked". Open up the DLL in explorer, right click -> properties -> press 'Unblock'.

http://cantgrokwontgrok.blogspot.com/2009/10/visual-studio-unknown-build-error.html

I had this exact same problem and fixed it by adding the sgen.exe.config under C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\NETFX 4.0 Tools

with this simple config as others have said

<?xml version ="1.0"?>
<configuration>
  <runtime>
    <loadFromRemoteSources enabled="true" />
  </runtime>
</configuration>

For those of you running a 64bit version of the TFS build service, I had to create the config file in the following path:

 C:\Program Files (x86)\Microsoft SDKs\Windows\v8.0A\bin\NETFX 4.0 Tools\x64

And the file contents:

<?xml version ="1.0"?>
<configuration>
<runtime>
    <loadFromRemoteSources enabled="true" />
</runtime>
</configuration>

I had the same issue, loaded the assembly in the GAC and worked

Adding the snippet below to the app.config file worked in my case. I'm Running Windows XP, with VS2010 service pack 1.

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

Just as an FYI if you are running Windows 7 the sgen.exe file can be found at:

C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\NETFX 4.0 Tools

I had to create a sgen.exe.config and place it there and then this problem went away.

Neither the unblock nor the config worked for me. What did the trick for me was this tip about caspol. I ran

 %windir%\Microsoft.NET\Framework\v2.0.50727\CasPol.exe -m -ag 1.2 -url file://UncPathName/UncSubPath/* FullTrust

And I was ready to go, not even a VisualStudio restart required.

I got a similar problem and I finally got over with it by removing the licenses.licx file in the Properties folder of the solution.

Just in case like me, Unblock was not a solution, as Unblock does not appear on my dll file properties. Kept looking and ended up closing my solution file and re-opening using the local C: copy instead of network UNC path to project sln file. Was able to publish after going this route.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!