【发布时间】:2015-04-30 13:57:23
【问题描述】:
我正在使用 WCF 服务调试一个类库,该服务使用 WCF 测试客户端和 Visual Studio 2013 Ultimate 调试器在 Windows 8.1 上安装 Azure SDK 2.4。该库是使用 AnyCPU 编译的。调用RoleEnvironment.IsAvailable 时发生异常。以下是详细信息:
Message=The type initializer for 'Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment' threw an exception.
...
InnerException: System.TypeInitializationException
Message=The type initializer for '<Module>' threw an exception.
Source=Microsoft.WindowsAzure.ServiceRuntime
TypeName=<Module>
StackTrace:
at Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment.InitializeEnvironment()
at Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment..cctor()
InnerException: <CrtImplementationDetails>.ModuleLoadException
HResult=-2146233088
Message=The C++ module failed to load while attempting to initialize the default appdomain.
Source=msshrtmi
StackTrace:
at <CrtImplementationDetails>.ThrowModuleLoadException(String errorMessage, Exception innerException)
at <CrtImplementationDetails>.LanguageSupport.Initialize(LanguageSupport* )
at .cctor()
InnerException: System.Runtime.InteropServices.COMException
HResult=-2146234334
Message=Invalid operation. (Exception from HRESULT: 0x80131022)
Source=mscorlib
ErrorCode=-2146234334
StackTrace:
at System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo)
at <CrtImplementationDetails>.GetDefaultDomain()
at <CrtImplementationDetails>.DoCallBackInDefaultDomain(IntPtr function, Void* cookie)
at <CrtImplementationDetails>.DefaultDomain.Initialize()
at <CrtImplementationDetails>.LanguageSupport.InitializeDefaultAppDomain(LanguageSupport* )
at <CrtImplementationDetails>.LanguageSupport._Initialize(LanguageSupport* )
at <CrtImplementationDetails>.LanguageSupport.Initialize(LanguageSupport* )
启用非托管代码调试没有给我任何新信息。我尝试安装 Azure SDK 的最新版本,将 useLegacyV2RuntimeActivationPolicy="true" 标志添加到配置文件,但这些都没有帮助。从我的测试项目中调用的相同库代码可以正常工作。同时使用 x86 和 x64 测试设置。调试文件夹似乎包含完全相同版本的 ServiceRuntime dll。
是什么导致了这个异常,我该如何解决?
【问题讨论】:
-
你有没有找到解决这个问题的方法?在我们的 TeamCity 和 NUnit 测试运行程序的项目中遇到了这个问题。 MSTest 运行器都可以正常工作。
-
我遇到了同样的错误,但是在普通的 Azure 应用服务中访问 RoleEnvironment 时 - 还没有找到任何解决方案 - 这让我发疯了......
标签: c# wcf visual-studio-2013 windows-8.1 azure-sdk-.net