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

前端 未结 13 2444
执念已碎
执念已碎 2020-12-07 13:35

I am experiencing a strange issue with VS2010. We use TFS to build our API dlls and we used to reference them in our projects usign a mapped network drive that was fully tru

相关标签:
13条回答
  • 2020-12-07 14:09

    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>
    
    0 讨论(0)
  • 2020-12-07 14:11

    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.

    0 讨论(0)
  • 2020-12-07 14:11

    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.

    0 讨论(0)
  • 2020-12-07 14:14

    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

    0 讨论(0)
  • 2020-12-07 14:22

    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.

    0 讨论(0)
  • 2020-12-07 14:23

    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.

    0 讨论(0)
提交回复
热议问题