views:

544

answers:

3

Hi !

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 trusted. We have been working like that for at least two years and everything worked perfectly.

Today, I converted a webapp to vs2010 and when I compile it in Release, it's giving me:

SGEN : error : Could not load file or assembly 'file:///L:\Api\Release API_20100521.1\Release\CS.API.Exceptions.dll' or one of its dependencies. Operation is not supported. (Exception from HRESULT: 0x80131515)

The strange thing is that it's working when it's under the Debug profile...

I tried adding the

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

into app.config and still no luck (See http://social.msdn.microsoft.com/Forums/en/msbuild/thread/d12f6301-85bf-4b9e-8e34-a06398a60df0 and http://msdn.microsoft.com/en-us/library/dd409252(VS.100).aspx)

I am pretty sure that this issue is from visual studio or msbuild, as our code won't run from a network share when in prod because all the referenced dll's are copied into the bin folder.

If anyone has an solution (or just an idea for a search path) please let me know !

Edit : It turns out that it was working in Debug mode because generation of serialisation assemblies was turned Off. As the title say, it's really a SGEN problem since it is this utility that says that the path is not trusted...

A: 

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

gabouy
the thing is we don't want those in the GAC. we resolved as serialisation assemblies turned Off
Developer IT
+1  A: 

Hi, 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>

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

Martin Hyldahl
yeah I came across this solution but was useless for me, I did not changed anything ... we resolved as serialisation assemblies turned Off
Developer IT
+1  A: 

Reason for this error is sgen.exe is not able to update output assembly for generating serialization info assembly. For more details please see SGEN error details

bimbim.in