2009-06-15 57 views
1

好吧,这看起来像一个非常简单的问题,但我似乎无法解决它。我几乎99%肯定这是Visual Studio本身的问题,但我希望能够快速进行完整性检查。配置问题Web.Config/Custom Providers

我正在为Asp.Net中的Health Monitoring创建一个自定义提供程序。我做了一个从BufferedWebEventProvider继承的非常简单的提供者。该代码位于我的网站的App_Code目录和如下:

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 

而且在web.config如下。

<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> 

每当我尝试编译,我得到这个错误:

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

我使用类型(即使它不应该被要求)的全称考虑,但由于这是一个网站(而不是一个Web应用程序)我不知道这是什么类型。

回答

0

我建议你不要使用网站“项目”,除了简单的网站。这可能是您的课程在名称空间中的一个问题,您不希望它位于该名称空间中。此类问题通常出现在网站“项目”中。

+0

我完全同意,但我得到由VS喜欢放到一个网站项目的增加“设计师”的文件有点懊恼。我不确定是否有一个标准网站在编译时会创建一个可预测的名称空间。 – Nathan 2009-06-16 12:06:19

+0

在一个web应用程序项目中,可能有多少.designer.cs文件并不重要,因为它们都被编译到应用程序的单个程序集中。我对网站“项目”的理解(可能有缺陷)是他们不使用名称空间。对于网站开发人员来说,命名空间显然太复杂了,因为想到那些造成这种混乱的微软的人。 – 2009-06-16 12:37:57

+0

但是,请使用对象浏览器来查看是否可以找到您的班级,并了解它的名称空间。对象浏览器具有您可能会觉得有帮助的搜索功能。 – 2009-06-16 12:39:07

1

我知道这可能听起来很奇怪,但我之前有过这个问题并修复它我不得不从我的web.config文件中删除(或注释掉)“问题”部分(在您的情况下,healthmonitoring部分),建立网站,将“问题”部分添加回来,然后重新构建。

奇怪的工作对我来说...

0

你配置你的配置文件来接受你的处理器?

I.E.在web.config文件的顶部添加了一个section条目到您的configSections系列。

<configSections> 
    <section name="healthMonitoringSection" type="fully qualified assembly path of handler" /> 
</configSections>