【问题标题】:Running (local) Azure worker role from network share从网络共享运行(本地)Azure 辅助角色
【发布时间】: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


【解决方案1】:

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

【讨论】:

  • 我已经运行了 Azure VM...Visual Studio 强制您以管理员权限运行才能启动它。
  • 是的,我知道。您必须以管理员身份运行才能运行 azure local emu。但是我有通过VM上的共享文件夹打开我的源代码并对其进行调试的经验,失败了。这就是为什么我猜你没有足够的权限在 VM 上工作,而不仅仅是 azure 项目。
猜你喜欢
  • 1970-01-01
  • 2011-08-21
  • 2012-07-06
  • 1970-01-01
  • 1970-01-01
  • 2015-05-31
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多