views:

282

answers:

3

Okay, this seems like a very simple issue, but I can't seem to get around it. I am almost 99% sure that this is an issue of Visual Studio itself, but I want to have a quick sanity check.

I am creating a custom provider for Health Monitoring in Asp.Net. I have made a very simple provider that inherits from the BufferedWebEventProvider. The code is located in the App_Code directory of my website and is as follows:

Public Class SQLApplicationExceptionProvider
Inherits System.Web.Management.BufferedWebEventProvider

Public Overrides Sub Initialize(ByVal name As String, ByVal config As System.Collections.Specialized.NameValueCollection)

 MyBase.Initialize(name, config)

End Sub

Public Overrides Sub ProcessEvent(ByVal eventRaised As System.Web.Management.WebBaseEvent)

 MyBase.ProcessEvent(eventRaised)
End Sub

Public Overrides Sub ProcessEventFlush(ByVal flushInfo As System.Web.Management.WebEventBufferFlushInfo)


End Sub

Public Overrides Sub Shutdown()
 Me.Flush()
End Sub

End Class

And the web.config is as follows.

     <healthMonitoring enabled="true" heartbeatInterval="100" >
  <providers>
   <add name="DBSExceptionProvider" type="SQLApplicationExceptionProvider" buffer="true" bufferMode="RegularNotification" />
  </providers>
  <rules>
   <add name="DBSErrors" eventName="All Errors" provider="DBSExceptionProvider" profile="Critical" />
  </rules>
  <bufferModes>
   <add name="RegularNotification"
    maxBufferSize="10"
    maxFlushSize="5"
    urgentFlushThreshold="2"
    regularFlushInterval="Infinite"
    urgentFlushInterval="00:00:30" />
  </bufferModes>
  <profiles>
   <add name="Default" minInstances="1" maxLimit="Infinite" minInterval="00:01:00" />
   <add name="Critical" minInstances="1" maxLimit="Infinite" minInterval="00:00:00" />
  </profiles>


 </healthMonitoring>

Whenever I try to compile, I get this error:

Error 2 Could not load type 'SQLApplicationExceptionProvider'. Path\web.config 90

For the life of me, I cannot understand why it does not compile. I considered using the full name of the Type (even though it should not be required) but since this is a WebSite (and not a web application) I am not sure what that type would be.

Any suggestions?

A: 

I suggest that you not use web site "projects", except for simple web sites. This is probably an issue with your class being in a namespace you didn't expect it to be in. Such issues often arise with web site "projects".

John Saunders
I completely agree, although I get a bit annoyed by the added "designer" files that VS likes to drop into a Website Project. I was not sure if there was a predictable namespace that a standard website would create when compiled.
Nathan
In a web application project, it doesn't matter how many .designer.cs files there may be, as they are all compiled into the single assembly for the application. My understanding (possibly flawed) of web site "projects" is that they don't use namespaces. Namespaces are apparently too complex for web site developers, in the thinking of those at Microsoft who created this mess.
John Saunders
However, please take a look with the Object Browser to see if you can find your class, and learn what namespace it's in. Object Browser has a search feature that you may find helpful.
John Saunders
+1  A: 

I know this might sound weird, but I've had this problem before and to fix it I had to remove (or comment out) the "problem" section from my web.config file (in your case the healthmonitoring section), build the website, add the "problem" section back, and build again.

Oddly works for me...

Steve Dignan
You are spot on. I actually did this exact thing, with success, for a while but it finally just quit working. Thanks.
Nathan
In that case, I would lean towards what @John Saunders mentions and investigate the namespace of the SQLApplicationExceptionProvider class; perhaps it has changed(?) ...
Steve Dignan
A: 

have you configured your config file to accept your handler?

I.E. added a section entry to your configSections collection at the top of the web.config file.

<configSections>
    <section name="healthMonitoringSection" type="fully qualified assembly path of handler" />
</configSections>
zonkflut
Health monitoring is a default feature of .Net and this section has already been added via the base web.config.
Nathan
cheers, I didn't realise that. But if you were creating a custom provider for it wouldn't you have to register it somewhere?
zonkflut