5

I'm trying to run an MVC web project on my Mac with Visual Studio for Mac, but I get an error in the browser when it runs. The problem is that I don't fully understand, from the trace, what file causes the problem.

From what I could find on Google, the problem is that the application is built with different versions of the .NET framework (https://developer.xamarin.com/api/type/System.BadImageFormatException/ - bullet point 4) (?) - something that I do not know how to solve.

There is no error messages during completive, but at runtime I only get the error-view. The full text of the error view is below the line:


Application Exception

System.BadImageFormatException

Description: HTTP 500.Error processing request.

Details: Non-web exception.

Exception stack trace:

  at (wrapper managed-to-native) System.Reflection.Assembly:LoadFrom (string,bool)
  at System.Reflection.Assembly.LoadFrom (System.String assemblyFile) [0x00000] in /private/tmp/source-mono-2017-02/bockbuild-2017-02/profiles/mono-mac-xamarin/build-root/mono-x86/mcs/class/corlib/System.Reflection/Assembly.cs:536 
  at System.Web.Compilation.AssemblyBuilder.ReferenceAssembly (System.Collections.Generic.Dictionary`2[TKey,TValue] moduleGuidCache, System.Collections.Generic.List`1[T] assemblies, System.String asmLocation) [0x00000] in /private/tmp/source-mono-2017-02/bockbuild-2017-02/profiles/mono-mac-xamarin/build-root/mono-x86/mcs/class/System.Web/System.Web.Compilation/AssemblyBuilder.cs:906 
  at System.Web.Compilation.AssemblyBuilder.ReferenceAssemblies (System.Collections.Generic.Dictionary`2[TKey,TValue] moduleGuidCache, System.Collections.Generic.List`1[T] assemblies, System.Collections.Specialized.StringCollection references) [0x0001c] in /private/tmp/source-mono-2017-02/bockbuild-2017-02/profiles/mono-mac-xamarin/build-root/mono-x86/mcs/class/System.Web/System.Web.Compilation/AssemblyBuilder.cs:901 
  at System.Web.Compilation.AssemblyBuilder.BuildAssembly (System.Web.VirtualPath virtualPath, System.CodeDom.Compiler.CompilerParameters options) [0x001f9] in /private/tmp/source-mono-2017-02/bockbuild-2017-02/profiles/mono-mac-xamarin/build-root/mono-x86/mcs/class/System.Web/System.Web.Compilation/AssemblyBuilder.cs:809 
  at System.Web.Compilation.AssemblyBuilder.BuildAssembly (System.CodeDom.Compiler.CompilerParameters options) [0x00000] in /private/tmp/source-mono-2017-02/bockbuild-2017-02/profiles/mono-mac-xamarin/build-root/mono-x86/mcs/class/System.Web/System.Web.Compilation/AssemblyBuilder.cs:736 
  at System.Web.Compilation.AppCodeAssembly.Build (System.String[] binAssemblies) [0x003be] in /private/tmp/source-mono-2017-02/bockbuild-2017-02/profiles/mono-mac-xamarin/build-root/mono-x86/mcs/class/System.Web/System.Web.Compilation/AppCodeCompiler.cs:268 
  at System.Web.Compilation.AppCodeCompiler.Compile () [0x000a1] in /private/tmp/source-mono-2017-02/bockbuild-2017-02/profiles/mono-mac-xamarin/build-root/mono-x86/mcs/class/System.Web/System.Web.Compilation/AppCodeCompiler.cs:666 
  at System.Web.HttpApplicationFactory.InitType (System.Web.HttpContext context) [0x00219] in /private/tmp/source-mono-2017-02/bockbuild-2017-02/profiles/mono-mac-xamarin/build-root/mono-x86/mcs/class/System.Web/System.Web/HttpApplicationFactory.cs:455 
  at System.Web.HttpApplicationFactory.GetApplication (System.Web.HttpContext context) [0x00018] in /private/tmp/source-mono-2017-02/bockbuild-2017-02/profiles/mono-mac-xamarin/build-root/mono-x86/mcs/class/System.Web/System.Web/HttpApplicationFactory.cs:472 
  at System.Web.HttpRuntime.Process (System.Web.HttpWorkerRequest req) [0x00052] in /private/tmp/source-mono-2017-02/bockbuild-2017-02/profiles/mono-mac-xamarin/build-root/mono-x86/mcs/class/System.Web/System.Web/HttpRuntime.cs:452 

Version Information: 5.0.1.1 (2017-02/5077205 Thu May 18 16:11:37 EDT 2017); ASP.NET Version: 4.0.30319.42000

Powered by Mono

Lex Li
  • 60,503
  • 9
  • 116
  • 147
Henrik
  • 81
  • 5
  • If your project uses mixed mode assemblies (such as some SQLite ADO.NET provider assembly), then it cannot work on Mono. Review such and then you might locate the culprit. – Lex Li Jun 08 '17 at 13:44
  • @LexLi there is any solution for this problem ?? i use vs2019 and same error for my asp.net project on mac – OriEng Oct 30 '19 at 18:18
  • @OriEng give it up and only use ASP.NET Core on macOS. – Lex Li Oct 30 '19 at 20:33
  • @LexLi tnx but I have a project that creates on asp.net 4.5 and I have to run him ... there is any workaround for that? – OriEng Oct 31 '19 at 07:48
  • 1
    Please give it up (once again). There is no real workaround when the underlying technology is not fully cross platform, so don't waste your time there. – Lex Li Oct 31 '19 at 13:54

0 Answers0