ASP.NET MVC HandleErrorエラーをELMAHに渡すための投稿とコードを読み、コードをVBに変換しました。
Imports System
Imports System.Web
Imports System.Web.Mvc
Imports Elmah
Public Class HandleErrorAttribute
Inherits System.Web.Mvc.HandleErrorAttribute
Public Overrides Sub OnException(ByVal context As ExceptionContext)
MyBase.OnException(context)
Dim e As Exception = context.Exception
If Not context.ExceptionHandled OrElse RaiseErrorSignal(e) OrElse IsFiltered(context) Then
' if unhandled, will be logged anyhow
'prefer signaling, if possible
'filtered?
Else
LogException(e)
End If
End Sub
Private Function RaiseErrorSignal(ByVal e As Exception) As Boolean
Dim context = HttpContext.Current
If context Is Nothing Then Return False
Dim signal = ErrorSignal.FromContext(context)
If signal Is Nothing Then Return False
signal.Raise(e, context)
Return True
End Function
Private Function IsFiltered(ByVal context As ExceptionContext) As Boolean
Dim config As ErrorFilterConfiguration = context.HttpContext.GetSection("elmah/errorFilter")
If config Is Nothing Then Return False
Dim testContext = New ErrorFilterModule.AssertionHelperContext(context.Exception, HttpContext.Current)
Return config.Assertion.Test(testContext)
End Function
Private Sub LogException(ByVal e As Exception)
Dim context = HttpContext.Current
ErrorLog.GetDefault(context).Log(New Elmah.Error(e, context))
End Sub
End Class
ただし、コードをコンパイルしようとすると、VS2008から次のエラーが発生することに気付きました。
エラー3アセンブリを発行できません:参照されたアセンブリ'Elmah'には厳密な名前がありませんMain
現在、HandleErrorAttribute.vbは[SLNファイルのあるフォルダー] \ Main \ HandleErrorAttribute.vbにあり、ビュー、コントローラーなどはすべてメインフォルダーの下にあります。
元のC#コードを機能させることができた場合、コンパイル時のエラーをどのように回避しましたか?(そして、それをVBで動作させることができれば、それはさらに良いことです)
編集
私はすでにsn.exeで署名しようとしました:
C:\ Program Files \ Microsoft Visual Studio 9.0 \ VC> sn -R "C:\ Documents and Settings \ zchoy \ My Documents \ Burrow \ Code \ Main \ lib \ Elmah.dll "" C:\ document and settings \ z choy \ mydocuments \ burrow \ code \ code signing key.pfx " Microsoft(R).NETFrameworkストロングネームユーティリティバージョン3.5.30729.1 Copyright(c)MicrosoftCorporation。全著作権所有。 C:\ Documents and Settings \ zchoy \ My Documents \ Burrow \ Code \ Main \ lib\Elmah.dllは 厳密に名前が付けられたアセンブリを表すものではありません
明らかに役に立たない。