2012-05-02 28 views
-3

私は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の問題であるようです。私はここで間違って何をしていますか?

+1

にあなたが使用してこれをデバッグしたいと思う(http://msdn.microsoft.com/en-us/ [フュージョンログビューアを。]ライブラリ/ e74a18c4.aspx)デバッグを試みる前に、必ずadminとして実行し、ログをオンにして再起動してください。 CLRがアセンブリを探している場所とそのバージョンを表示し、そこから見つからない理由を判断します(インストールされていても)。 – Will

+0

私は、このような方法で例外を排除する考えが人々には好きではないので、この質問は下落していると思います。 downvotersは、downvotes(Stack Exchangeには非常に非生産的なアプローチ)の理由を何も与えていない。 – bgmCoder

答えて

1

設定ファイルには、型宣言の最後に不要な項目があります。この行を変更してみてください:

<configSections> 
    <section name="IgnoredExceptionSection" type="ElmahExceptionHandling.IgnoredExceptionSection, WEB" /> 
</configSections> 

この

<configSections> 
    <section name="IgnoredExceptionSection" type="ElmahExceptionHandling.IgnoredExceptionSection" /> 
</configSections> 
+0

これまでに試したことがありますが、まだエラーメッセージが表示されます。私の設定行は次のようになります: '

' – oscilatingcretin

+0

テストアプリケーションなどであなたのソリューションを試しましたか?簡単なコンソールアプリに貼り付けるのが簡単にできるようにコードを設定しました。それは私のC#アプリケーションで動作しますが、私のVB.NETアプリケーションでは動作しません。 – oscilatingcretin

+0

@ oscillatingcretin:私はあなたのコードでC#とVBウェブサイトの両方に失敗しました。それから私はマイクのコメントに従って、両方とも完璧です。あなたの問題は何か分かりません。あなたが以前にその解決策を試してみたかどうかは関係ありません。あなたの質問セクションには、間違っている情報が保持されています。このソリューションを試して、エラーメッセージを投稿してください。そうすれば、何が悪いのかを分析して確認するのに役立ちます。 – Esen

関連する問題