将 ELMAH 添加到 WCF 项目后出现 SecurityException

发布于 2024-08-26 18:39:00 字数 1147 浏览 2 评论 0原文

我在 IIS 7.5 上使用 ELMAH 的 WCF (.Net 3.5) 站点时遇到问题。这是异常消息:

System.Security.SecurityException: Request for the permission of type 'System.Web.AspNetHostingPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.

为了验证它是IIS7.5上的WCF和ELMAH的组合,我在VS2008中创建了一个新的WCF服务项目,并在IIS 7.5站点下创建了一个新的应用程序。我发布了它并确保没问题。然后我添加了 ELMAH DLL。还是可以的。然后将 ELMAH configSection 引用添加到 Web.config。还是可以的。然后我将 ELMAH 内容添加到 system.web 中的 httpHandlers 和 httpModules 中(是的,我知道这不适用于 7.5)。还是可以的。然后我将其添加到 system.webServer 中的处理程序和模块中:

<handlers>
    :
  <add name="Elmah" verb="POST,GET,HEAD" 
       path="elmah.axd" type="Elmah.ErrorLogPageFactory, Elmah" />

<modules>
    :
  <add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah"/>
  <add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah" />
  <add name="ErrorFilter" type="Elmah.ErrorFilterModule, Elmah" />

然后我得到了安全异常。我没有进行其他配置更改。

使用 VS 开发网络服务器一切正常。开发机器是2008 R2 x64,安装了VS 2008 SP1。 WCF 服务是为 x86 构建的(因为原始项目是)。 ELMAH 是.Net 3.5 x86 版本。 IIS7.5应用程序池设置为允许32位。

知道我需要做什么才能使其正常工作吗?

I'm having a problem with a WCF (.Net 3.5) site using ELMAH on IIS 7.5. This is the exception message:

System.Security.SecurityException: Request for the permission of type 'System.Web.AspNetHostingPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.

To verify that it was the combination of WCF and ELMAH on IIS7.5, I created a new WCF Service project in VS2008 and a new Application under the IIS 7.5 site. I published it and made sure it was okay. Then I added the ELMAH DLL. Still okay. Then added the ELMAH configSection references to Web.config. Still okay. Then I added the ELMAH stuff to httpHandlers and httpModules in system.web (yeah, I know this is not for 7.5). Still okay. Then I added this to handlers and modules in system.webServer:

<handlers>
    :
  <add name="Elmah" verb="POST,GET,HEAD" 
       path="elmah.axd" type="Elmah.ErrorLogPageFactory, Elmah" />

<modules>
    :
  <add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah"/>
  <add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah" />
  <add name="ErrorFilter" type="Elmah.ErrorFilterModule, Elmah" />

And then I got the security exception. I've made no other config changes.

Everything works using the VS dev webserver. The development machine is 2008 R2 x64 with VS 2008 SP1 installed. The WCF service is built for x86 (because the original project was). ELMAH is the .Net 3.5 x86 version. The IIS7.5 app pool is set to allow 32-bit.

Any idea what I need to do to get this working?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

旧情勿念 2024-09-02 18:39:00

就我而言,我必须在应用程序池中设置“load User Profile=True”才能使其正常工作。

步骤:

从应用程序池列表中,转到“高级设置”、“进程模型”部分,并将“加载用户配置文件”设置为“True”。

In my case, I had to set the "load User Profile=True" in app pool to make it work.

Steps:

From application pools list, Go to Advanced Settings, Process Model section and set "Load User Profile" to "True".

情未る 2024-09-02 18:39:00

您必须在 IIS 管理器中为您的虚拟 Web 目录转至添加托管处理程序。

  • 请求路径将为:elmah.axd
  • 类型将为:Elmah.ErrorLogPageFactory, Elmah
  • 名称:您希望其识别的任何内容。

:每次从 Visual Studio 发布更改时都会删除此设置。所以你必须再次添加它。

You will have to go to Add managed handler in the IIS Manager for your virtual web directory.

  • Request Path will be : elmah.axd
  • Type will be: Elmah.ErrorLogPageFactory, Elmah
  • Name: Anything you want it to be identified with.

Note: This settings will be removed every time you publish changes from Visual Studio. So you will have to add it again.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文