Could not load file or assembly Operation is not supported. (Exception from HRESULT: 0x80131515)

守給你的承諾、 提交于 2019-11-29 02:58:58
Raj

Right click on the Dll and unblock it.

During my research I found that this may happen when you downloaded a test in a ZIP from the internet and the advice was to unblock the ZIP. But I copied the files over the network from my developer system to the test PCs and the files were not blocked.

Searching more for the error code 0x80131515 I found this answer in the MSDN forum.

So I edited the file

C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow\vstest.console.exe.config

and added the entry <loadFromRemoteSources enabled="true" /> under the runtime tag and voilá, the tests run fine without any issues from a scheduled task.

Maybe this helps other users who also run into this strange issue.

As previously stated, a Zip file is blocked when downloaded from an untrusted site. If you are confident the site is reliable you can prevent this behavior by adding it to your trusted sites list in Internet Explorer -> Tools Menu -> Internet Options -> Security Tab -> Trusted Sites. Future downloads will not be marked as blocked.

For blocked files that have already been extracted, run this at a Powershell prompt to unblock all the files in the current folder and subfolders:

Get-ChildItem *.* -Recurse | Unblock-File

This problem occurs when sgen.exe is not able to get write access to your output assembly to generate serialization assembly.

Reason may be file is read only or it is on UNC path.

To resolve this issue you have following options.

  1. Copy your solution to you system local drive then build your solution.
  2. Use caspol.exe to grant full trust to the UNC path.
  3. Disable Generate serialization assembly option from your project properties build tab.

For more info please visit http://bimbim.in/post/2010/09/06/SGEN-error-Could-not-load-file-or-assembly.aspx

answer replyed from: bimbim.in

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