これが私の拡張方法です:
Public Module HtmlExtensions
System.Runtime.CompilerServices.Extension
Public Function ReverseMapPath(ByVal html As HtmlHelper, ByVal path As String) As String
Dim appPath = HttpContext.Current.Server.MapPath("~")
Dim res As String = String.Format("{0}", path.Replace(appPath, "/").Replace("\", "/"))
Return res
End Function
End Module
私の web.config には私の名前空間のエントリがあります
すべてがうまく機能していました。プロジェクトにさらにコードを追加し始めたところ、拡張メソッドを 2 回読み込んでいるように見えるエラーが表示されましたが、その理由がわかりません。エラーは次のとおりです。
path.page.vbhtml(9): error BC30521: Overload resolution failed because no accessible 'FunctionName' is most specific for these arguments:
Extension method 'Public Function FunctionName(path As String) As String' defined in 'namespace.Extensions.HtmlExtensions': Not most specific.
Extension method 'Public Function FunctionName((path As String) As String' defined in 'namespace.Extensions.HtmlExtensions': Not most specific.
なぜこれが忍び寄ったのか理解できません。明らかに何かを変更しましたが、すべてを元に戻しても役に立ちません。エラーは、.net フレームワークの背後にあるようです。何か案は?