Using a class defined in App_Code in 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.
精彩评论