私はVB.NETから無視したいELMAH例外を管理するカスタム構成セクションを作成しています/ASP.NETアプリ。ここに私のコードです。誰かが問題の診断に挑戦している場合は、空のコードファイルを貼り付けるのが簡単でした。私はエラーを取得しAn error occurred creating the configuration section handler for IgnoredExceptionSection: Could not load file or assembly 'WEB' or one of its dependencies.
VB.NET/ASP.NET 4.0のカスタム構成セクション:「構成セクションハンドラーの作成中にエラーが発生しました」
Dim section As ElmahExceptionHandling.IgnoredExceptionSection = ConfigurationManager.GetSection("IgnoredExceptionSection")
:私はこのコードを実行すると
<configSections>
<section name="IgnoredExceptionSection" type="ElmahExceptionHandling.IgnoredExceptionSection, WEB" />
</configSections>
<IgnoredExceptionSection>
<IgnoredExceptions>
<add Message="test exception" />
</IgnoredExceptions>
</IgnoredExceptionSection>
:
Imports System.Configuration
Namespace ElmahExceptionHandling
Public Class IgnoredExceptionSection : Inherits ConfigurationSection
<ConfigurationProperty("IgnoredExceptions")>
ReadOnly Property IgnoredExceptions As IgnoredExceptions
Get
Return TryCast(Me("IgnoredExceptions"), IgnoredExceptions)
End Get
End Property
Shared Function GetConfig() As IgnoredExceptionSection
Return TryCast(System.Configuration.ConfigurationManager.GetSection("IgnoredExceptionSection"), IgnoredExceptionSection)
End Function
End Class
<ConfigurationCollection(GetType(IgnoredException))>
Public Class IgnoredExceptions : Inherits ConfigurationElementCollection
Protected Overloads Overrides Function CreateNewElement() As System.Configuration.ConfigurationElement
Return New IgnoredException
End Function
Protected Overrides Function GetElementKey(element As System.Configuration.ConfigurationElement) As Object
Return TryCast(element, IgnoredException).Message
End Function
End Class
Public Class IgnoredException : Inherits ConfigurationElement
<ConfigurationProperty("Message")>
ReadOnly Property Message As String
Get
Return Me("Message")
End Get
End Property
End Class
End Namespace
そして、ここでは設定です。
Webユーティリティを使用してVB.NETからコードを変換した後、C#のコンソールテストアプリケーションでこれがすべて正常に動作することを心配しています。しかし、VB.NETコードを自分のWebアプリケーションからVB.NETコンソールテストアプリに貼り付けると、そこでは動作しないので、C#/ VBの問題であるようです。私はここで間違って何をしていますか?
にあなたが使用してこれをデバッグしたいと思う(http://msdn.microsoft.com/en-us/ [フュージョンログビューアを。]ライブラリ/ e74a18c4.aspx)デバッグを試みる前に、必ずadminとして実行し、ログをオンにして再起動してください。 CLRがアセンブリを探している場所とそのバージョンを表示し、そこから見つからない理由を判断します(インストールされていても)。 – Will
私は、このような方法で例外を排除する考えが人々には好きではないので、この質問は下落していると思います。 downvotersは、downvotes(Stack Exchangeには非常に非生産的なアプローチ)の理由を何も与えていない。 – bgmCoder