好吧,这看起来像一个非常简单的问题,但我似乎无法解决它。我几乎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应用程序)我不知道这是什么类型。
我完全同意,但我得到由VS喜欢放到一个网站项目的增加“设计师”的文件有点懊恼。我不确定是否有一个标准网站在编译时会创建一个可预测的名称空间。 – Nathan 2009-06-16 12:06:19
在一个web应用程序项目中,可能有多少.designer.cs文件并不重要,因为它们都被编译到应用程序的单个程序集中。我对网站“项目”的理解(可能有缺陷)是他们不使用名称空间。对于网站开发人员来说,命名空间显然太复杂了,因为想到那些造成这种混乱的微软的人。 – 2009-06-16 12:37:57
但是,请使用对象浏览器来查看是否可以找到您的班级,并了解它的名称空间。对象浏览器具有您可能会觉得有帮助的搜索功能。 – 2009-06-16 12:39:07