【问题标题】:Making problem in Health Mornitoring of asp.net在asp.net的健康监测中出现问题
【发布时间】:2011-02-10 07:52:21
【问题描述】:

我创建了一个继承 system.web.management.webeventprovider 的文件清理提供程序。

Public Class FileCleanupProvider
    Inherits System.Web.Management.WebEventProvider

    Private Const StateFIleFolderPath As String = "StateData/"


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


    Public Overrides Sub Flush()
        ' not required
    End Sub


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

        Dim DateTimeRaised As DateTime = raisedEvent.EventTime
        ' Remove files
        Dim FilePath As String = IO.Path.Combine(HttpRuntime.AppDomainAppPath, StateFIleFolderPath)
        For Each FileName In IO.Directory.GetFiles(FilePath)
            If (DateTimeRaised - IO.File.GetCreationTime(FileName)) > TimeSpan.FromHours(6) Then
                IO.File.Delete(FileName)
            End If
        Next

    End Sub


    Public Overrides Sub ShutDown()
        'Clean up on shut down
        Dim FilePath As String = IO.Path.Combine(HttpRuntime.AppDomainAppPath, StateFIleFolderPath)
        For Each FileName In IO.Directory.GetFiles(FilePath)
            IO.File.Delete(FileName)
        Next
    End Sub

End Class

我在 web.config 中配置了这个

<healthMonitoring enabled="true" heartbeatInterval="5">
      <providers>
        <add name="FileCleanupProvider" type="System.Web.Management.WebEventProvider"/>
      </providers>
      <profiles>
        <remove name="Default"/>
        <add name="Default" minInstances="1" maxLimit="Infinite" minInterval="00:01:00" custom=""/>
      </profiles>
      <eventMappings>
        <remove name="Heartbeats"/>
        <add name="Heartbeats" type="System.Web.Management.WebHeartbeatEvent,System.Web,Version=2.0.0.0,Culture=neutral,PublicKeyToken=b03f5f7f11d50a3a" startEventCode="0" endEventCode="2147483647" />
      </eventMappings>
      <!--<eventMappings>
        <add name="FileCleanupEvent" type="System.Web.Management.WebHeartbeatEvent" startEventCode="0" endEventCode="2147483647"/>
      </eventMappings>-->
      <rules>
        <clear/>
        <add name="FileCleanupRule" eventName="Heartbeats" provider="FileCleanupProvider" profile="Default"/>
      </rules>
    </healthMonitoring>

但我有一个问题。

我该如何解决?

【问题讨论】:

    标签: asp.net vb.net health-monitoring


    【解决方案1】:

    你需要在配置中指定你的类:

    <add name="FileCleanupProvider" type="YourNameSpace.FileCleanupProvider,AssemblyName,Version=0.0.0.0,Culture=neutral,PublicKeyToken=PublicKeyHere"/>
    

    .NET 正在动态创建该类的实例,因此该类必须是“有效的”。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多