【发布时间】:2012-01-30 17:38:57
【问题描述】:
在 Azure 开发(或者说真的,任何与 Windows 和 .Net 相关的事情)方面,我都是新手,所以请多多包涵...
我不日常使用 Windows,所以对于这个项目,我设置了一个 Windows 7 VirtualBox 实例来进行开发。我将主机操作系统的代码目录与 VM 共享,并且 VM 将其挂载为网络共享(显示为 E:\ 或 \\VBOXSVR\,具体取决于...?)。
我遇到的问题是,当我尝试让我的辅助角色在 Azure Compute Emulator 上运行时,它会因以下错误而死:
Microsoft.WindowsAzure.ServiceRuntime Critical: 201 : Role entrypoint could not be created:
System.IO.FileLoadException: Could not load file or assembly 'file://\\VBOXSVR\XXX\YYY\csx\Debug\roles\WorkerRole\approot\WorkerRole.dll' or one of its dependencies. Operation is not supported. (Exception from HRESULT: 0x80131515)
File name: 'file://\\VBOXSVR\XXX\YYY\csx\Debug\roles\WorkerRole\approot\WorkerRole.dll' ---> System.NotSupportedException: An attempt was made to load an assembly from a network location which would have caused the assembly to be sandboxed in previous versions of the .NET Framework. This release of the .NET Framework does not enable CAS policy by default, so this load may be dangerous. If this load is not intended to sandbox the assembly, please enable the loadFromRemoteSources switch. See http://go.microsoft.com/fwlink/?LinkId=155569 for more information.
at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
at System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection, Boolean suppressSecurityChecks)
at System.Reflection.RuntimeAssembly.InternalLoadFrom(String assemblyFile, Evidence securityEvidence, Byte[] hashValue, AssemblyHashAlgorithm hashAlgorithm, Boolean forIntrospection, Boolean suppressSecurityChecks, StackCrawlMark& stackMark)
at System.Reflection.Assembly.LoadFrom(String assemblyFile)
at Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment.CreateRoleEntryPoint(RoleType roleTypeEnum)
at Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment.InitializeRoleInternal(RoleType roleTypeEnum)
关注that link 会给你一个页面,上面写着要添加:
<loadFromRemoteSources enabled="true" />
到你的配置文件。我将它添加到工作者角色的 app.config 中,留下了:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<runtime>
<loadFromRemoteSources enabled="true"/>
</runtime>
...
</configuration>
但是,当我尝试运行它时,我会收到相同的错误消息。
【问题讨论】:
-
差不多一年后我在VS2012上也出现了这种情况。同样的问题:解决这个问题的正确方法是什么?
标签: .net visual-studio-2010 azure visual-studio-2012 azure-worker-roles