0

I have an MVC project that I'm running under mono. It has a reference to System.Web. If I inspect this package using the assembly browser in VS Mac 2019 I can see that it has the class System.Web.Security.AntiXss.AntiXssEncoder. When I insepct the properties of the System.Web package it's path is `/Library/Frameworks/Mono.framework/versions/6.10.0/lib/mono/4.8-api/System.Web.dll.

However when I run this project and request an api route I get a System.TypeLoadException:

Could not resolve type with token 010005dc from typeref (expected class 'System.Web.Security.AntiXss.AntiXssEncoder' in assembly 'System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a')

Thrown from System.ComponentModel.DataAnnotation.ValidationAttribute.IsValid

In the logs when it loads I can see that for some reason the assembly isn't loaded:

Loaded assembly: /Library/Frameworks/Mono.framework/Versions/6.10.0/lib/mono/gac/Microsoft.CSharp/4.0.0.0__b03f5f7f11d50a3a/Microsoft.CSharp.dll
Loaded assembly: /Library/Frameworks/Mono.framework/Versions/6.10.0/lib/mono/gac/System.Data/4.0.0.0__b77a5c561934e089/System.Data.dll
Loaded assembly: /Library/Frameworks/Mono.framework/Versions/6.10.0/lib/mono/gac/System.Web.Services/4.0.0.0__b03f5f7f11d50a3a/System.Web.Services.dll
Loaded assembly: /Library/Frameworks/Mono.framework/Versions/6.10.0/lib/mono/gac/System.Drawing/4.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
Loaded assembly: /Library/Frameworks/Mono.framework/Versions/6.10.0/lib/mono/gac/System.EnterpriseServices/4.0.0.0__b03f5f7f11d50a3a/System.EnterpriseServices.dll
Loaded assembly: /Library/Frameworks/Mono.framework/Versions/6.10.0/lib/mono/gac/System.IdentityModel/4.0.0.0__b77a5c561934e089/System.IdentityModel.dll
Loaded assembly: /Library/Frameworks/Mono.framework/Versions/6.10.0/lib/mono/gac/System.Runtime.Serialization/4.0.0.0__b77a5c561934e089/System.Runtime.Serialization.dll
Loaded assembly: /Library/Frameworks/Mono.framework/Versions/6.10.0/lib/mono/gac/System.Xaml/4.0.0.0__b77a5c561934e089/System.Xaml.dll
Loaded assembly: /Library/Frameworks/Mono.framework/Versions/6.10.0/lib/mono/gac/System.ServiceModel/4.0.0.0__b77a5c561934e089/System.ServiceModel.dll
Loaded assembly: /Library/Frameworks/Mono.framework/Versions/6.10.0/lib/mono/gac/System.ServiceModel.Web/4.0.0.0__31bf3856ad364e35/System.ServiceModel.Web.dll
Loaded assembly: /Library/Frameworks/Mono.framework/Versions/6.10.0/lib/mono/gac/System.Web.Extensions/4.0.0.0__31bf3856ad364e35/System.Web.Extensions.dll
Loaded assembly: /Library/Frameworks/Mono.framework/Versions/6.10.0/lib/mono/gac/System.Data.DataSetExtensions/4.0.0.0__b77a5c561934e089/System.Data.DataSetExtensions.dll
Loaded assembly: /Library/Frameworks/Mono.framework/Versions/6.10.0/lib/mono/gac/System.Xml.Linq/4.0.0.0__b77a5c561934e089/System.Xml.Linq.dll
Loaded assembly: /Library/Frameworks/Mono.framework/Versions/6.10.0/lib/mono/gac/System.ComponentModel.DataAnnotations/4.0.0.0__31bf3856ad364e35/System.ComponentModel.DataAnnotations.dll
Loaded assembly: /Library/Frameworks/Mono.framework/Versions/6.10.0/lib/mono/gac/System.Web.DynamicData/4.0.0.0__31bf3856ad364e35/System.Web.DynamicData.dll
Loaded assembly: /Library/Frameworks/Mono.framework/Versions/6.10.0/lib/mono/gac/System.Data.Linq/4.0.0.0__b77a5c561934e089/System.Data.Linq.dll
Loaded assembly: /Library/Frameworks/Mono.framework/Versions/6.10.0/lib/mono/gac/System.Web.ApplicationServices/4.0.0.0__31bf3856ad364e35/System.Web.ApplicationServices.dll
Loaded assembly: /Library/Frameworks/Mono.framework/Versions/6.10.0/lib/mono/gac/System.ComponentModel.Composition/4.0.0.0__b77a5c561934e089/System.ComponentModel.Composition.dll
Loaded assembly: /Library/Frameworks/Mono.framework/Versions/6.10.0/lib/mono/gac/System.Data.OracleClient/4.0.0.0__b77a5c561934e089/System.Data.OracleClient.dll
Loaded assembly: /Library/Frameworks/Mono.framework/Versions/6.10.0/lib/mono/gac/System.IO.Compression.FileSystem/4.0.0.0__b77a5c561934e089/System.IO.Compression.FileSystem.dll
Loaded assembly: /Library/Frameworks/Mono.framework/Versions/6.10.0/lib/mono/gac/System.Management/4.0.0.0__b03f5f7f11d50a3a/System.Management.dll
Loaded assembly: /Library/Frameworks/Mono.framework/Versions/6.10.0/lib/mono/gac/System.Net/4.0.0.0__b03f5f7f11d50a3a/System.Net.dll
Loaded assembly: /Library/Frameworks/Mono.framework/Versions/6.10.0/lib/mono/gac/System.Net.Http.WebRequest/4.0.0.0__b03f5f7f11d50a3a/System.Net.Http.WebRequest.dll
Loaded assembly: /Library/Frameworks/Mono.framework/Versions/6.10.0/lib/mono/gac/System.Numerics/4.0.0.0__b77a5c561934e089/System.Numerics.dll
Loaded assembly: /Library/Frameworks/Mono.framework/Versions/6.10.0/lib/mono/gac/System.Runtime.Caching/4.0.0.0__b03f5f7f11d50a3a/System.Runtime.Caching.dll
Loaded assembly: /Library/Frameworks/Mono.framework/Versions/6.10.0/lib/mono/gac/System.Security/4.0.0.0__b03f5f7f11d50a3a/System.Security.dll
Loaded assembly: /Library/Frameworks/Mono.framework/Versions/6.10.0/lib/mono/gac/System.ServiceProcess/4.0.0.0__b03f5f7f11d50a3a/System.ServiceProcess.dll
Loaded assembly: /Library/Frameworks/Mono.framework/Versions/6.10.0/lib/mono/gac/System.Transactions/4.0.0.0__b77a5c561934e089/System.Transactions.dll
Loaded assembly: /Library/Frameworks/Mono.framework/Versions/6.10.0/lib/mono/gac/WindowsBase/4.0.0.0__31bf3856ad364e35/WindowsBase.dll

So no sign of System.Web but System.Web.ApplicationServices (which includes a System.Web.Security namespace) is loaded. I can't tell why it wouldn't load the referenced assembly - is this XSP4 deciding which assemblies to load or mono??

Any ideas?

Robin Southgate
  • 487
  • 1
  • 5
  • 11
  • Give it up and go back to Windows. Mono does not have a 100% complete ASP.NET clone, and won't have that. If you really want to host your apps on Linux, ASP.NET Core is the only production environment. – Lex Li May 07 '20 at 04:56
  • @LexLi I agree - I wouldn't use it in production, but running locally on a mac as opposed to having to boot into windows is compelling. And even without complete compatibility it actualyl compiles and runs the rest of this pretty complex MVC app just fine. And since I can see the implementation of this AntiXssEncoder in the assembly browser I feel like this shouldn't be the bit that I fail at! I just need to load that assembly somehow - which it should be doing anyway :( – Robin Southgate May 07 '20 at 05:05

0 Answers0