开发者

Using a class defined in App_Code in web.config

开发者 https://www.devze.com 2023-04-02 17:00 出处:网络
I have a class named CustomWebAuditEvent defined in App_Code/CustomWebAuditEvent.vb and I\'m trying to use it in a eventMappings of my Web.Config

I have a class named CustomWebAuditEvent defined in App_Code/CustomWebAuditEvent.vb and I'm trying to use it in a eventMappings of my Web.Config

<healthMonitoring enabled="true">
  <eventMappings>
    <clear />
    <add name="HandeledException"
         type="CustomWebAuditEvent"
     />
  </eventMappings>
....

I got the error message:

Could not load type 'CustomWebAuditEvent'

So I tried

  • type="CustomWebAuditEvent, App_Code"
  • type="CustomWebAuditEvent, App_Code.CustomWebAuditEvent"
  • type="CustomWebAuditEvent, __Code"开发者_Go百科
  • type="CustomWebAuditEvent, __Code.CustomWebAuditEvent"

and all I got is this error message :

Could not load file or assembly 'App_Code' or one of its dependencies. The system cannot find the file specified.

How could I make this work?


Try moving CustomWebAuditEvent out of App_code and just placing the class in the same directory as web.config. Then in web.config, reference it as ClassName.CustomWebAuditEvent

I have seen this happen before, although I don't know what causes App_Code to not be recognized.


I moved my CustomWebAuditEvent class into a separated class library and put the compiled assembly in my bin folder.

Note: I found this other question that describe the exact same problem.

0

精彩评论

暂无评论...
验证码 换一张
取 消