2

当谈到 Azure 开发(或者说真的,任何与 Windows 和 .Net 相关的事情)时,我是一个完全的新手,所以请多多包涵……


我不每天使用 Windows,所以对于这个项目,我设置了一个 Windows 7 VirtualBox 实例来进行开发。我将主机操作系统的代码目录与虚拟机共享,并且虚拟机将其安装为网络共享(显示为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)

该链接之后,您会看到一个页面,上面写着要添加:

<loadFromRemoteSources enabled="true" />

到你的配置文件。我将它添加到工作角色的 app.config 中,给我留下了:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <runtime>
        <loadFromRemoteSources enabled="true"/>
    </runtime>
    ... 
</configuration>

但是,当我尝试运行它时,我会收到相同的错误消息。

4

1 回答 1

-1

我没有在 VM 上运行我的 Azure 项目,而是在主机上运行源代码。但据我所知,天蓝色的本地模拟器需要管理员权限。这可能是我猜的原因,因为我试图从 VM 调试主机上的应用程序,它只是在 VS 的共享文件夹中打开解决方案,但失败了。

于 2012-01-31T06:13:17.113 回答