Azure SDK 1.4 – WIF – 尝试初始化默认应用程序域时无法加载C ++模块

我有一个旧的azure应用程序,它运行在azure 1.2 SDK上,依赖于WIF进行身份validation。

我最近一直在尝试将其更新到最新的SDK(1.4)。

应用程序在Azure上编译和运行,包括使用我的STS进行身份validation。 但是,网站上的某些页面不会加载以下错误。

Unable to find assembly 'Microsoft.IdentityModel, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. [SerializationException: Unable to find assembly 'Microsoft.IdentityModel, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.] System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) +4767763 System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) +1725 System.AppDomain.get_Id() +0 .DoCallBackInDefaultDomain(IntPtr function, Void* cookie) +191 .LanguageSupport._Initialize(LanguageSupport* ) +354 .LanguageSupport.Initialize(LanguageSupport* ) +102 [ModuleLoadException: The C++ module failed to load while attempting to initialize the default appdomain. ] .ThrowModuleLoadException(String errorMessage, Exception innerException) +50 .LanguageSupport.Initialize(LanguageSupport* ) +169 .cctor() +33 

我确保将WIF依赖项设置为复制本地 – 并且它正在工作 – 某些页面可以工作!

关于如何解决这个问题的任何想法?

编辑:错误仅发生在访问tablestorage的页面上

看起来错误是由Microsoft.WindowsAzure.ServiceRuntime调用方法引起的,它会更改webrole的appdomain。

为了解决这个问题,您可以将连接字符串硬编码到应用程序中(或使用web.config)而不是azure配置。 (这个问题的解决方案非常糟糕)

或者,您可以使用以下url上的说明: http : //blogs.infosupport.com/blogs/eriko/archive/2011/01/14/adding-assemblies-to-the-gac-in-windows-azure.aspx添加任何内容您遇到azure色GAC问题的程序集。

如果遇到类似问题,建议阅读:

http://social.msdn.microsoft.com/Forums/kk-KZ/windowsazuretroubleshooting/thread/35d37b41-b638-4023-aaab-b8134ac27278

http://blog.smarx.com/posts/how-to-resolve-setconfigurationsettingpublisher-needs-to-be-called-before-fromconfigurationsetting-can-be-used-after-moving-to-windows-azure-sdk- 1-3

很多人都遇到过这种情况。 我想这应该是FAQ。 但是,我无法在stackoverflow上找到正确的答案。 这里的问题是在bin目录中包含Microsoft.IdentityModel.dll是不够的。 在很少的地方,Appdomain的配置不会查看/ bin,因此它需要是全局的,安装在GAC中。

按照此处描述的步骤操作: http : //blogs.infosupport.com/blogs/eriko/archive/2011/01/14/adding-assemblies-to-the-gac-in-windows-azure.aspx 。 总之,您需要创建启动任务并运行以下命令:

 gacutil /nologo /i .\Microsoft.IdentityModel.dll