Azure SDK 1.4 - WIF - C++尝试初始化默认应用程序域时模块加载失败
我有一个旧的 azure 应用程序,它在 azure 1.2 SDK 上运行,并依赖 WIF 进行身份验证。
我最近一直在尝试将其更新到最新的SDK(1.4)。
应用程序在 Azure 上编译和运行,包括使用我的 STS 进行身份验证。但是,该网站上的某些页面将无法加载并抛出以下错误。
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
<CrtImplementationDetails>.DoCallBackInDefaultDomain(IntPtr function, Void* cookie) +191
<CrtImplementationDetails>.LanguageSupport._Initialize(LanguageSupport* ) +354
<CrtImplementationDetails>.LanguageSupport.Initialize(LanguageSupport* ) +102
[ModuleLoadException: The C++ module failed to load while attempting to initialize the default appdomain.
]
<CrtImplementationDetails>.ThrowModuleLoadException(String errorMessage, Exception innerException) +50
<CrtImplementationDetails>.LanguageSupport.Initialize(LanguageSupport* ) +169
.cctor() +33
我已确保 WIF 依赖项设置为复制本地 - 并且它正在工作 - 某些页面可以工作!
关于如何解决这个问题有什么想法吗?
编辑:错误仅发生在访问表存储的页面上
I have an old azure application which was running on the azure 1.2 SDK and relies on WIF for authentication.
I have recently been trying to update it to the latest SDK (1.4).
The applications compiles and runs on Azure, including authenticating with my STS. However some pages on the site just will not load throwing the following errors.
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
<CrtImplementationDetails>.DoCallBackInDefaultDomain(IntPtr function, Void* cookie) +191
<CrtImplementationDetails>.LanguageSupport._Initialize(LanguageSupport* ) +354
<CrtImplementationDetails>.LanguageSupport.Initialize(LanguageSupport* ) +102
[ModuleLoadException: The C++ module failed to load while attempting to initialize the default appdomain.
]
<CrtImplementationDetails>.ThrowModuleLoadException(String errorMessage, Exception innerException) +50
<CrtImplementationDetails>.LanguageSupport.Initialize(LanguageSupport* ) +169
.cctor() +33
I have ensured that the WIF dependency is set to copy local - and it is working - some pages work!
any ideas on how to resolve this?
Edit: The error only occurs on pages that access tablestorage
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
看起来该错误是由 Microsoft.WindowsAzure.ServiceRuntime 调用方法引起的,该方法更改了您的网络角色的应用程序域。
为了解决这个问题,您可以将连接字符串硬编码到您的应用程序中(或使用 web.config)而不是 azure 配置。 (这个问题的解决方案非常糟糕)
或者您可以使用以下说明: 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
It looks like the error is caused by calling methods from Microsoft.WindowsAzure.ServiceRuntime which changes the appdomain of your webrole.
In order to get around this you can hardcode your connection string into your app (or use web.config) instead of the azure config. (A really poor solution to this problem)
Alternatively you can use the instructions at: http://blogs.infosupport.com/blogs/eriko/archive/2011/01/14/adding-assemblies-to-the-gac-in-windows-azure.aspx to add any assemblies that you have trouble with to the azure GAC.
Recommended reading if you encounter a similar issue:
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
很多人都遇到过这种情况。我想这应该已经是常见问题解答了。然而令人惊讶的是我在 stackoverflow 上找不到正确的答案。这里的问题是,将 Microsoft.IdentityModel.dll 放在 bin 目录中是不够的。在少数地方,Appdomain 的配置不查看 /bin,因此它需要是全局的,安装在 GAC 中。
请按照此处描述的步骤操作:http://blogs.infosupport.com/blogs/eriko/archive/2011/01/14/adding-assemblies-to-the-gac-in-windows-azure.aspx。简而言之,您需要创建启动任务并运行以下命令:
So many people have run into this. I suppose this should be already FAQ. However suprizinly I could not find correct answer on stackoverflow. The problem here is that having Microsoft.IdentityModel.dll inside your bin directory is NOT enough. In few places configuration of Appdomain does not look at /bin, so it needs to be global, installed in GAC.
Follow steps described here: http://blogs.infosupport.com/blogs/eriko/archive/2011/01/14/adding-assemblies-to-the-gac-in-windows-azure.aspx. In short summary, you will need to create startup task and run this command: