我正在尝试这样做:
HttpContext.GetLocalResourceObject("~/Views/Shared/AnotherFolder/More/App_LocalResources/MyResourceFile.cshtml.resx", "myKey")
但我不断从控制器内部收到此错误:
The resource class for this page was not found. Please check if the resource file exists and try again.
那就是如果我将调用包装在 try 块中。否则,该函数将被弹出。
目录结构,Views
就在根文件夹之后:
我确定路径是正确的,因为我刚刚从资源文件的属性窗口中复制了它,但可能有什么问题?虚拟路径不正确?
这是调试输出:
A first chance exception of type 'System.InvalidOperationException' occurred in System.Web.dll
System.Data.SqlClient.SqlException (0x80131904): Could not find stored procedure 'ELMAH_LogError'.
at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)
at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)
at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource`1 completion, Int32 timeout, Task& task, Boolean asyncWrite)
at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSource`1 completion, String methodName, Boolean sendToPipe, Int32 timeout, Boolean asyncWrite)
at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
at Elmah.SqlErrorLog.Log(Error error)
at Elmah.ErrorLogModule.LogException(Exception e, HttpContext context)