- Question 1: You got an error message like this:
System.InvalidOperationException Assembly ‘System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35’ does not contain a Web resource with name ‘jquery’.
Answer:
You are trying to load script from the System.Web.Extensions. Some auto-generated code such as:<asp:ScriptReference Name="jquery" />
will cause this error. Remove this kind of codes will solve this kind of questions.
- Question 2: You got error messages like these:
System.TypeLoadException
Could not load type ‘System.Web.UI.IScriptResourceDefinition’ from assembly ‘System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a’.
or
System.InvalidProgramException
Invalid IL code in System.Web.Handlers.ScriptModule:.ctor (): method body is empty.Answer:
You use the wrong version of some assemblies. Currently known, mono has its own version for the following assemblies:
System.Web.Extensions.dll
System.Web.Entity.dll
Remove them from your bin folder.
※ mono doesn’t support entity framework. - Question 3:
You got error messages like this while hosting an MVC web on Apache with mono:System.Web.HttpException
The resource cannot be found.
Description: HTTP 404.The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.
Details: Requested URL: someurlAnswer:
It seems like a routing error, files and folders are all there, why “NOT FOUND"???
You may find some solutions such as remove the targetFramework in Web.config, or ensure some libraries in the bin folder.
But, all that not work for me.
Finally, I found that this is a question relates to how you publish and deploy your site.
I use the publish function in VS 2015, and I checked the “Precompile during publishing".
Uncheck it, and publish again, everything done!!!
System.Web.Routing.dll is not required to be deployed in the bin folder.
- Question 4:
You got an error message like this:System.UnauthorizedAccessException
Access to the path “/etc/mono/registry" is denied.Answer:
Ensure that the “/etc/mono/registry" exists. If not, create it.sudo mkdir /etc/mono/registry
Change its privileges, and restart your apache.
sudo chmod uog+rw /etc/mono/registry
Question 5:
You got an error message like this:
Application Exception
System.NullReferenceException
Object reference not set to an instance of an object
Description: HTTP 500.Error processing request.
Details: Non-web exception. Exception origin (name of application or object): SID.
Exception stack trace:
at SID.Controllers.HomeController.Index () <IL 0x00046, 0x00127> at (wrapper dynamic-method) object.lambda_method (System.Runtime.CompilerServices.Closure,System.Web.Mvc.ControllerBase,object[]) <IL 0x00006, 0x0004c> at System.Web.Mvc.ActionMethodDispatcher.Execute
And there are apache error logs like this:
Stacktrace:
at <unknown> <0xffffffff>
at SID.Business.SIDRepository/<>c__DisplayClass4.<GetContentOfDay>b__3 () <IL 0x0000d, 0x00017>
at myQuiz.Caching.CacheRepository.Update<T> (string,System.Func`1<T>,System.DateTime,System.TimeSpan) <IL 0x00003, 0x00044>
at myQuiz.Caching.CacheRepository.Get<T> (string,System.Func`1<T>,System.DateTime,System.TimeSpan) <IL 0x00026, 0x000c3>
at myQuiz.Caching.CacheRepository.Get<T> (string,System.Func`1<T>,System.TimeSpan) <IL 0x0000a, 0x00053>
at SID.Business.SIDRepository.GetContentOfDay (int,int) <IL 0x00044, 0x00187>
at SID.Controllers.HomeController.Index () <IL 0x0002f, 0x000db>
at (wrapper dynamic-method) object.lambda_method (System.Runtime.CompilerServices.Closure,System.Web.Mvc.ControllerBase,object[]) <IL 0x00006, 0x0004c>
And, if you use some logging tool such as log4net, you may got this:
System.BadImageFormatException: Could not resolve field token 0x04000005
File name: 'SID.DataAccess'
at SID.Business.SIDRepository+<>c__DisplayClass4.<GetContentOfDay>b__3 () [0x00000] in <filename unknown>:0
at myQuiz.Caching.CacheRepository.Update[String] (System.String key, System.Func`1 act, DateTime absoluteExpiration, TimeSpan slidingExpiration) [0x00000] in <filename unknown>:0
Answer:
I write an ASP.NET MVC web application using MySQL connector to communicate with MySQL database. According to MSDN BadImageFormatException said, this is because the DLL is not valid. But what MSDN not said is WHY NOT VALID!!!
Finally, I found that this is a dependency problem. My SID.DataAccess.dll requires MySql.Data.dll to run properly, but the default compile & publish doesn’t output MySql.Data.dll into target bin folder.
So, simply change the “Copy Local" property of MySql.Data.dll to “True" will solve this question.


