运行 32/64 位 Web 应用程序
我正在运行 Windows Web 2008 x64 安装。
由于需要应用程序能够导入 Excel 文件,我不得不将 Web 应用程序更改为在 32 位模式下运行。 MSAccess/Excel 库在 x64 中不可用。
我还必须提升应用程序以在 trust=Full 下运行。以前它处于 level=medium 之下。
对于这个问题有没有好的解决方法。我想降低信任级别,而不必仅仅因为一个屏幕需要 Excel 导入(该屏幕的使用也不频繁)而将应用程序妥协为 32 位
是否可以设置特定文件夹/页面以在其中使用 32 位应用程序,其余为 x64。我不相信你可以。信任级别也是如此。信任级别应用程序是特定的还是我可以将其发送到嵌套文件夹中?
I have a windows web 2008 x64 installation running.
Due to the requirement for the application having the ability to import Excel files, I have had to change the web application to run in 32bit mode. The MSAccess/Excel libraries are not available in x64.
I have also had to elavate the application to run in trust=Full. Previously it was under level=medium.
Is there a good workaround to this issue. I want to bring the trust level down and not have to compromise the app to 32bit just because one screen requires excel import (usage of this screen is not frequent as well)
Is it possible to set a particular folder/page to use 32 bit in the application, and the rest as x64. I don't believe you can. And same for trust level. Is the trust level application specific or can i sent it in a nested folder?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在同一个进程中,您永远不能混合使用 32 位和 64 位。您也许可以编写第二个应用程序来为您执行 Excel 操作,然后将其编译为 32 位可执行文件。然后,您可以从 Web 应用程序调用(使用一些参数执行文件)该可执行文件(仍然需要完全信任,但它可以运行 64 位)。
编辑:您不一定需要完全信任。您还可以创建自定义信任级别。但关键是它不会在标准网络信任级别中运行。
Within the same process you can never have mixed 32bit and 64bit. You could perhaps write a second application that does the Excel stuff for you and then compile it into a 32bit executable. You could then call (execute the file with some parameters) that executable from your web-application (will still require full trust, but it could run 64bit then).
Edit: You don't need full-trust neccessarily. You could also create a custom trust-level. But the point is that it won't run in standard web trustlevel remains.
正如 FoxFire 正确指出的,你不能在同一进程中混合 32 位和 64 位代码。
任何需要与 Office 交互的 ASP.NET 应用程序都需要提升信任级别。
有一种方法可以通过使用称为“沙箱”的技术来解决这个问题。
您要做的就是编写一个包装器程序集,它只完成您需要使用 Excel 完成的工作。使用
[程序集:AllowPartiallyTrustedCallers]
属性标记程序集,对其进行签名,然后部署到 GAC 中。此程序集中需要与 Office Interop 组件通信的任何类都应具有
[PermissionSet(SecurityAction.Assert, Unrestricted=true)]
或任何所需的需求。这将允许您降低服务器上的信任级别,但仍然使用 Office 组件。
这是基于这样的假设:您具有服务器的管理访问权限,能够将“可信”沙箱程序集放入 GAC 中。
As FoxFire correctly points out, you can't mix 32bit and 64bit code in the same process.
Any ASP.NET application that needs to interact with Office will require elevated trust levels.
There is a way around this by using a technique known as 'sandboxing'.
What you do is write a wrapper assembly which does just the work you require done with Excel. Mark the assembly with the
[assembly: AllowPartiallyTrustedCallers]
attribute, sign it and then deploy into the GAC.Any classes in this assembly that are required to talk to the Office Interop components should be attributed with
[PermissionSet(SecurityAction.Assert, Unrestricted=true)]
or whatever demand is required.This will allow you to lower the trust level on your server but still use the Office components.
This is based on the assumption that you have administrative access to the server to be able to drop the 'trusted' sandbox assembly into the GAC.