How to upgrade to 3.2.1.0 in Mono - asp.net

Npgsql 3.1.9 is used in ASP.NET MVC4 application in Mono 4.4.1
Visual Studio Community Edition 2015 is used for develpment.
Ngpsql was upgraded to 3.2.1.0 from Nuget package manager.
It installed a lot of new .NET framework assemblies.
Application was re-compiled in Visual Studio and copied to Debian Linux into Mono.
Trying to run application in Mono now causes exception
Could not load type 'System.Net.HttpStatusDescription' from assembly 'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.
with stack trace below.
How to run this application in Mono using latest npgsql?
In windows from Visual Studio it runs OK.
Could not load type 'System.Net.HttpStatusDescription' from assembly 'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.
System.TypeLoadException: Could not load type 'System.Net.HttpStatusDescription' from assembly 'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.
at System.Web.Http.WebHost.HttpControllerHandler+<CopyResponseStatusAndHeadersAsync>d__31.MoveNext () <0x40bbf6b0 + 0x000eb> in <filename unknown>:0
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () <0x40bc12f0 + 0x00033> in <filename unknown>:0
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) <0x40bc0e60 + 0x0010b> in <filename unknown>:0
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) <0x40bc0cb0 + 0x000b3> in <filename unknown>:0
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) <0x413bc1b0 + 0x00042> in <filename unknown>:0
at System.Runtime.CompilerServices.TaskAwaiter`1[TResult].GetResult () <0x414e3410 + 0x0001a> in <filename unknown>:0
at System.Web.Http.WebHost.HttpControllerHandler+<CopyResponseAsync>d__7.MoveNext () <0x40bbebc0 + 0x002b5> in <filename unknown>:0
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () <0x40bc12f0 + 0x00033> in <filename unknown>:0
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) <0x40bc0e60 + 0x0010b> in <filename unknown>:0
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) <0x40bc0cb0 + 0x000b3> in <filename unknown>:0
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) <0x413bc1b0 + 0x00042> in <filename unknown>:0
at System.Runtime.CompilerServices.TaskAwaiter.GetResult () <0x414bdce0 + 0x0001a> in <filename unknown>:0
at System.Web.Http.WebHost.HttpControllerHandler+<ProcessRequestAsyncCore>d__0.MoveNext () <0x40b80500 + 0x006e9> in <filename unknown>:0
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () <0x40bc12f0 + 0x00033> in <filename unknown>:0
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) <0x40bc0e60 + 0x0010b> in <filename unknown>:0
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) <0x40bc0cb0 + 0x000b3> in <filename unknown>:0
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) <0x413bc1b0 + 0x00042> in <filename unknown>:0
at System.Runtime.CompilerServices.TaskAwaiter.GetResult () <0x414bdce0 + 0x0001a> in <filename unknown>:0
at System.Web.TaskAsyncResult.Wait (IAsyncResult result) <0x40bc1ce0 + 0x000c9> in <filename unknown>:0
at System.Web.HttpTaskAsyncHandler.System.Web.IHttpAsyncHandler.EndProcessRequest (IAsyncResult result) <0x40bc1cb0 + 0x00013> in <filename unknown>:0
at System.Web.HttpApplication.async_handler_complete_cb (IAsyncResult ar) <0x4158bc70 + 0x000ee> in <filename unknown>:0
Update
I uninstalled Netstandard.library package with dependencies using forced uninstall in nuget.
Added System.Net.Http.dll assemby to refences from .NET 4.6 framework assemblies with Copy Local true.
Removed and installed again Microsoft.AspNet.WebApi.Core package
Now running in mono causes error
System.InvalidProgramException
Invalid IL code in System.Net.Http.Headers.MediaTypeHeaderValue:.ctor (string): method body is empty.
Description: HTTP 500.Error processing request.
Details: Non-web exception. Exception origin (name of application or object): System.Net.Http.Formatting.
Exception stack trace:
at System.Net.Http.Formatting.MediaTypeConstants..cctor () <0x41e7fb00 + 0x00033> in <filename unknown>:0
Version Information: 4.4.1 (Nightly 4.4.1.0/4747417 K juuli 20 01:02:20 EEST 2016); ASP.NET Version: 4.0.30319.42000
I tried also to install System.Net.Http.dll nuget package but in this case exception described in start of this question occurs in Mono.

Related

Error with running ASP Web application in Mac

I have created Web application in Mac OS and able to build it.
On dnx web i get the following error:
System.DllNotFoundException: libc.dylib
at (wrapper managed-to-native) System.IO.KeventWatcher:kqueue ()
at System.IO.KeventWatcher.GetInstance (IFileWatcher& watcher) <0x105a29310 + 0x000f3> in <filename unknown>:0
at System.IO.FileSystemWatcher.InitWatcher () <0x105a28fa0 + 0x0012c> in <filename unknown>:0
at System.IO.FileSystemWatcher..ctor (System.String path, System.String filter) <0x105a28d00 + 0x00114> in <filename unknown>:0
at System.IO.FileSystemWatcher..ctor (System.String path) <0x105a28cc0 + 0x00023> in <filename unknown>:0
at (wrapper remoting-invoke-with-check) System.IO.FileSystemWatcher:.ctor (string)
at Microsoft.AspNet.FileProviders.PhysicalFilesWatcher..ctor (System.String root) <0x105a285b0 + 0x00154> in <filename unknown>:0
at Microsoft.AspNet.FileProviders.PhysicalFileProvider..ctor (System.String root) <0x105a282d0 + 0x000e4> in <filename unknown>:0
at Microsoft.AspNet.Hosting.HostingEnvironmentExtensions.Initialize (IHostingEnvironment hostingEnvironment, System.String applicationBasePath, IConfiguration config) <0x105a27f20 + 0x001ea> in <filename unknown>:0
at Microsoft.AspNet.Hosting.WebHostBuilder.Build () <0x105a1a860 + 0x000b8> in <filename unknown>:0
at Microsoft.AspNet.Hosting.WebApplication.Run (System.Type startupType, System.String[] args) <0x105560990 + 0x00216> in <filename unknown>:0
at Microsoft.AspNet.Hosting.WebApplication.Run (System.String[] args) <0x10555fef0 + 0x0001a> in <filename unknown>:0
at Microsoft.AspNet.Hosting.Program.Main (System.String[] args) <0x10555fec0 + 0x00014> in <filename unknown>:0
at Microsoft.AspNet.Server.Kestrel.Program.Main (System.String[] args) <0x10555fc90 + 0x000b5> in <filename unknown>:0
at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&)
at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) <0x1050027a0 + 0x000b7> in <filename unknown>:0
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () in <filename unknown>:line 0
at Microsoft.Dnx.Runtime.Common.EntryPointExecutor.Execute (System.Reflection.Assembly assembly, System.String[] args, IServiceProvider serviceProvider) in <filename unknown>:line 0
at Microsoft.Dnx.ApplicationHost.Program+<>c__DisplayClass3_0.<ExecuteMain>b__0 () in <filename unknown>:line 0
at System.Threading.Tasks.Task`1[TResult].InnerInvoke () in <filename unknown>:line 0
at System.Threading.Tasks.Task.Execute () in <filename unknown>:line 0
Unhandled Exception:
System.NullReferenceException: Object reference not set to an instance of an object
at System.IO.FileSystemWatcher.Stop () in <filename unknown>:line 0
at System.IO.FileSystemWatcher.Finalize () in <filename unknown>:line 0
I have tried the suggestion in the below question
dnx kestrel "System.EntryPointNotFoundException: uv_loop_size"
and set DYLD_FALLBACK_LIBRARY_PATH.
Yet unable to resolve the issue. Any ideas to resolve it.

System.Web.HttpException with "Type Service not found." in Mono ASP.NET Web Service

I am using mono v4.2.1 and apache2 in ubuntu 14.04
I managed to install my ASP.NET web service in the url: http://myurl/WebService/Service.asmx
But when I open it, I receive this error:
System.Web.HttpException
Type Service not found.
Description: HTTP 500.Error processing request.
Details: Error processing request.
Exception stack trace:
at System.Web.UI.SimpleWebHandlerParser.GetTypeFromBin (System.String tname) <0x40f053e0 + 0x00894> in <filename unknown>:0
at System.Web.Compilation.SimpleBuildProvider.LoadTypeFromBin (System.Web.Compilation.BaseCompiler compiler, System.Web.UI.SimpleWebHandlerParser parser) <0x40f053a0 + 0x00026> in <filename unknown>:0
at System.Web.Compilation.GenericBuildProvider`1[TParser].GetGeneratedType (System.CodeDom.Compiler.CompilerResults results) <0x40f05150 + 0x00085> in <filename unknown>:0
at System.Web.Compilation.BuildManagerCacheItem..ctor (System.Reflection.Assembly assembly, System.Web.Compilation.BuildProvider bp, System.CodeDom.Compiler.CompilerResults results) <0x40f04fc0 + 0x00101> in <filename unknown>:0
at System.Web.Compilation.BuildManager.StoreInCache (System.Web.Compilation.BuildProvider bp, System.Reflection.Assembly compiledAssembly, System.CodeDom.Compiler.CompilerResults results) <0x40f04a60 + 0x0009f> in <filename unknown>:0
at System.Web.Compilation.BuildManager.GenerateAssembly (System.Web.Compilation.AssemblyBuilder abuilder, System.Web.Compilation.BuildProviderGroup group, System.Web.VirtualPath vp, Boolean debug) <0x40f00ff0 + 0x00b94> in <filename unknown>:0
at System.Web.Compilation.BuildManager.BuildInner (System.Web.VirtualPath vp, Boolean debug) <0x40ee7490 + 0x00579> in <filename unknown>:0
at System.Web.Compilation.BuildManager.Build (System.Web.VirtualPath vp) <0x40ee6df0 + 0x00149> in <filename unknown>:0
at System.Web.Compilation.BuildManager.GetCompiledType (System.Web.VirtualPath virtualPath) <0x40ee6a30 + 0x000b7> in <filename unknown>:0
at System.Web.Compilation.BuildManager.GetCompiledType (System.String virtualPath) <0x40ee65c0 + 0x00024> in <filename unknown>:0
at System.Web.UI.WebServiceParser.GetCompiledType (System.String inputFile, System.Web.HttpContext context) <0x40ee65a0 + 0x00014> in <filename unknown>:0
at System.Web.Services.Protocols.WebServiceHandlerFactory.GetCompiledType (System.String url, System.Web.HttpContext context) <0x40ee6570 + 0x00022> in <filename unknown>:0
at System.Web.Services.Protocols.WebServiceHandlerFactory.GetHandler (System.Web.HttpContext context, System.String verb, System.String url, System.String filePath) <0x40edf510 + 0x0014a> in <filename unknown>:0
at System.Web.Script.Services.ScriptHandlerFactory.GetHandler (System.Web.HttpContext context, System.String requestType, System.String url, System.String pathTranslated) <0x40edf050 + 0x00241> in <filename unknown>:0
at System.Web.HttpApplication.GetHandler (System.Web.HttpContext context, System.String url, Boolean ignoreContextHandler) <0x40ed71f0 + 0x002f3> in <filename unknown>:0
at System.Web.HttpApplication.GetHandler (System.Web.HttpContext context, System.String url) <0x40ed71b0 + 0x00020> in <filename unknown>:0
at System.Web.HttpApplication+<Pipeline>c__Iterator1.MoveNext () <0x40ebcf60 + 0x02b62> in <filename unknown>:0
This is my Service.asmx:
<%# WebService Language="C#" Class="Service" %>
And the Service class is in a library which is added by reference:
using System.Web.Services;
[WebService(Namespace = "http://myurl/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class Service : WebService
{
public Service()
{
}
}
The point is it works completely OK in Microsoft Visual Studio but mono has a problem and I don't know where to look or what to do.
I figured out that it was because the root directory was not correctly set.
I used xsp4 instead of apache2 and it fixed.

Method 'HttpRequestBase.GetBufferlessInputStream' not found when using owin auth on mono

I deployed a Asp.Net Web API project onto my CentOS server running mono 4.3.0 (compiled from mono-4.2.1.36 branch released 2 days ago). I built the project using VS2015 enpty web api template and added owin authentication in an attempt to get a web api working with authentication using bearer tokens.
I'm hosting the project on apache server using mod_mono.
When running the project locally on my windows machine, everything works perfectly. On Linux, when I send a http POST to the /token endpoint, the server returns a 200 OK, but without any response payload (which would include the bearer token the client needs to authenticate subsequent requests). At the same time, the server logs an exception (following).
System.MissingMethodException: Method 'HttpRequestBase.GetBufferlessInputStream' not found.
at Microsoft.Owin.Host.SystemWeb.CallStreams.InputStream.get_Stream () <0xb0e339b8 + 0x00013> in <filename unknown>:0
at Microsoft.Owin.Host.SystemWeb.CallStreams.DelegatingStream.get_CanRead () <0xb0e45eb0 + 0x00013> in <filename unknown>:0
at System.IO.StreamReader..ctor (System.IO.Stream stream, System.Text.Encoding encoding, Boolean detectEncodingFromByteOrderMarks, Int32 bufferSize, Boolean leaveOpen) <0xb0e5d790 + 0x0005f> in <filename unknown>:0
at (wrapper remoting-invoke-with-check) System.IO.StreamReader:.ctor (System.IO.Stream,System.Text.Encoding,bool,int,bool)
at Microsoft.Owin.OwinRequest+<ReadFormAsync>d__0.MoveNext () <0xb0e33510 + 0x000f3> in <filename unknown>:0
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () <0xb0e34a68 + 0x0002b> in <filename unknown>:0
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) <0xb0e346d0 + 0x000bb> in <filename unknown>:0
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) <0xb0e34588 + 0x0007f> in <filename unknown>:0
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) <0xb270df98 + 0x00033> in <filename unknown>:0
at System.Runtime.CompilerServices.TaskAwaiter`1[TResult].GetResult () <0xb270e1d0 + 0x00017> in <filename unknown>:0
at Microsoft.Owin.Security.OAuth.OAuthAuthorizationServerHandler+<InvokeTokenEndpointAsync>d__22.MoveNext () <0xb0e2f118 + 0x00463> in <filename unknown>:0
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () <0xb0e34a68 + 0x0002b> in <filename unknown>:0
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) <0xb0e346d0 + 0x000bb> in <filename unknown>:0
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) <0xb0e34588 + 0x0007f> in <filename unknown>:0
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) <0xb270df98 + 0x00033> in <filename unknown>:0
at System.Runtime.CompilerServices.TaskAwaiter.GetResult () <0xb270df70 + 0x00013> in <filename unknown>:0
at Microsoft.Owin.Security.OAuth.OAuthAuthorizationServerHandler+<InvokeAsync>d__0.MoveNext () <0xb270e790 + 0x007a7> in <filename unknown>:0
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () <0xb0e34a68 + 0x0002b> in <filename unknown>:0
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) <0xb0e346d0 + 0x000bb> in <filename unknown>:0
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) <0xb0e34588 + 0x0007f> in <filename unknown>:0
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) <0xb270df98 + 0x00033> in <filename unknown>:0
at System.Runtime.CompilerServices.TaskAwaiter`1[TResult].GetResult () <0xb270f5b0 + 0x00013> in <filename unknown>:0
at Microsoft.Owin.Security.Infrastructure.AuthenticationMiddleware`1+<Invoke>d__0[TOptions].MoveNext () <0xb270b2a0 + 0x0030f> in <filename unknown>:0
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () <0xb0e34a68 + 0x0002b> in <filename unknown>:0
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) <0xb0e346d0 + 0x000bb> in <filename unknown>:0
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) <0xb0e34588 + 0x0007f> in <filename unknown>:0
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) <0xb270df98 + 0x00033> in <filename unknown>:0
at System.Runtime.CompilerServices.TaskAwaiter.GetResult () <0xb270df70 + 0x00013> in <filename unknown>:0
at Microsoft.Owin.Host.SystemWeb.IntegratedPipeline.IntegratedPipelineContextStage+<RunApp>d__5.MoveNext () <0xb270aa98 + 0x00173> in <filename unknown>:0
After googling I found that this exception has been fixed in another namespace, but note this originates in Microsoft.Owin.Host.SystemWeb.
Is there a workaround to get rid of the exception, and does anyone have information on if that exception is the reason for the behavior I'm facing or is there something else I can try in order to get bearer token based authentication working?
In my AuthorizationServerProvider I implement the following methods:
(also, when running on Linux the response headers do not include Access-Control-Allow-Origin like they do on Windows)
public override Task ValidateClientAuthentication(OAuthValidateClientAuthenticationContext context)
{
context.OwinContext.Response.Headers.Add("Access-Control-Allow-Origin", new[] { "*" });
context.Validated();
return Task.FromResult<object>(null);
}
public override async Task GrantResourceOwnerCredentials(OAuthGrantResourceOwnerCredentialsContext context)
{
//check credentials
var identity = new ClaimsIdentity(context.Options.AuthenticationType);
identity.AddClaim(new Claim(ClaimTypes.Name, context.UserName)); //etc
var props = new AuthenticationProperties(new Dictionary<string, string>
{
{ "as:client_id", (context.ClientId == null) ? string.Empty : context.ClientId },
{ "userName", context.UserName }
});
var ticket = new AuthenticationTicket(identity, props);
context.Validated(ticket);
}
public override Task TokenEndpoint(OAuthTokenEndpointContext context)
{
foreach (KeyValuePair<string, string> property in context.Properties.Dictionary)
{
context.AdditionalResponseParameters.Add(property.Key, property.Value);
}
return Task.FromResult<object>(null);
}
My Startup.cs looks like this:
public void Configuration(IAppBuilder app)
{
ConfigureOAuth(app);
HttpConfiguration config = new HttpConfiguration();
config.Filters.Add(new AuthorizeAttribute());
WebApiConfig.Register(config);
GlobalConfiguration.Configuration.IncludeErrorDetailPolicy = IncludeErrorDetailPolicy.Always;
GlobalConfiguration.Configuration.Filters.Add(new AuthorizeAttribute());
app.UseCors(Microsoft.Owin.Cors.CorsOptions.AllowAll);
app.UseWebApi(config);
}
public void ConfigureOAuth(IAppBuilder app)
{
OAuthAuthorizationServerOptions OAuthServerOptions = new OAuthAuthorizationServerOptions()
{
AllowInsecureHttp = true,
TokenEndpointPath = new PathString("/token"),
AccessTokenExpireTimeSpan = TimeSpan.FromMinutes(15),
Provider = new BoaAuthorizationServerProvider(),
RefreshTokenProvider = new BoaRefreshTokenProvider(),
ApplicationCanDisplayErrors = true,
};
// Enable the application to use bearer tokens to authenticate users
app.UseOAuthBearerTokens(OAuthServerOptions);
}
EDIT:
Some more information on this:
I tried the old remove-the-problematic-dll -trick, and I no longer get that exception, but however I do get a 500 Internal Server Error, when sending a http POST to the token endpoint (the same that works on windows).
This is the exception:
System.Web.HttpException
Method 'POST' is not allowed when accessing file '/webapitest/token'
Description: HTTP 500.Error processing request.
Details: Error processing request.
Exception stack trace:
at System.Web.DefaultHttpHandler.BeginProcessRequest (System.Web.HttpContext context, System.AsyncCallback callback, System.Object state) in <filename unknown>:line 0
at System.Web.HttpApplication+<Pipeline>c__Iterator1.MoveNext () in <filename unknown>:line 0
at System.Web.HttpApplication.Tick () in <filename unknown>:line 0
Note the Startup configuration above, is there anything there that mono does not support? If not, this seems like either a configuration problem or a bug in mono as someone previously commented that they get the same MissingMethodException about GetBufferlessInputStream that happens on Ubuntu. That comment has then been removed.
This error is still reproduced on mono builds downloaded from official repos(seems like correct GetBufferlessInputStream & GetBufferedInputStream were implemented in that commit:
303d876370017774445c71736cf34e851e5cb037).
The easiest way for me was to update dependent libraries from nightlybuild repo(not need to compile whole project and to update only required libraries for disk space saving).
Update instructions for Debian:
echo "deb http://download.mono-project.com/repo/debian nightly main" | sudo tee /etc/apt/sources.list.d/mono-nightly.list
sudo apt-get update
sudo apt-get install libmono-system-net-http-webrequest4.0-cil
(any other libmono http library should work too, list of needed packages will be composed automatically)

Issue after updating to mono 4.0.1 on Ubuntu

I just upgraded to the just released Mono version 4.0.1 on my ubuntu machines. The previous installed version of mono was 3.2.7 (if I remember correctly).
Now the issue:
My first issue is regarding SignalR and self-hosting. I have a .NET 4.5.1 console application in which I self host NancyFx, Web Api and SignalR using OWIN. When running on mono 3.2.7 there was no issues to my knowledge but when I try to start the application on mono 4.0.1 I get the following stack trace:
Unhandled Exception:
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.InvalidProgramException: Invalid IL code in (wrapper delegate-invoke) <Module>:invoke_callvirt_CancellationTokenRegistration_CancellationToken&_Action`1<object>_object (System.Threading.CancellationToken&,System.Action`1<object>,object): IL_0057: castclass 0x00000007
at Microsoft.AspNet.SignalR.Infrastructure.CancellationTokenExtensions.SafeRegister (CancellationToken cancellationToken, System.Action`1 callback, System.Object state) [0x00000] in <filename unknown>:0
at Microsoft.AspNet.SignalR.Hosting.HostDependencyResolverExtensions.InitializeResolverDispose (IDependencyResolver resolver, CancellationToken hostShutdownToken) [0x00000] in <filename unknown>:0
at Microsoft.AspNet.SignalR.Hosting.HostDependencyResolverExtensions.InitializeHost (IDependencyResolver resolver, System.String instanceName, CancellationToken hostShutdownToken) [0x00000] in <filename unknown>:0
at Owin.OwinExtensions.UseSignalRMiddleware[HubDispatcherMiddleware] (IAppBuilder builder, System.Object[] args) [0x00000] in <filename unknown>:0
at Owin.OwinExtensions.RunSignalR (IAppBuilder builder, Microsoft.AspNet.SignalR.HubConfiguration configuration) [0x00000] in <filename unknown>:0
at Owin.OwinExtensions+<>c__DisplayClass1.<MapSignalR>b__0 (IAppBuilder subApp) [0x00000] in <filename unknown>:0
at Owin.MapExtensions.Map (IAppBuilder app, PathString pathMatch, System.Action`1 configuration) [0x00000] in <filename unknown>:0
at Owin.MapExtensions.Map (IAppBuilder app, System.String pathMatch, System.Action`1 configuration) [0x00000] in <filename unknown>:0
at Owin.OwinExtensions.MapSignalR (IAppBuilder builder, System.String path, Microsoft.AspNet.SignalR.HubConfiguration configuration) [0x00000] in <filename unknown>:0
at Owin.OwinExtensions.MapSignalR (IAppBuilder builder, Microsoft.AspNet.SignalR.HubConfiguration configuration) [0x00000] in <filename unknown>:0
at Owin.OwinExtensions.MapSignalR (IAppBuilder builder) [0x00000] in <filename unknown>:0
I have no clue to what this error could mean and I'm greatful for all assistance. I'm using Microsoft ASP.NET SignalR Self Host package version 2.2.0.
And as a side note, I've compiled all my assemblies on the new mono version.
Kind regards,
Simon
This turned out to be a Mono issue which was recently fixed: https://bugzilla.xamarin.com/show_bug.cgi?id=29665

Mono - ASP.NET Application in domain Subfolder

I have an Apache server with mod_mono hooked up to a legacy ASP.NET application. I can't seem to get this application to work if I move it from a top level folder.
For example, the following mono .webapp successfully works at http://localhost/Service.asmx (as my web app is in folder2):
<apps>
<web-application>
<name>Test</name>
<vpath>/</vpath>
<path>/srv/aspnettest/folder1/folder2</path>
<vhost>localhost</vhost>
</web-application>
</apps>
However, due to a legacy URL, I need my web application to exist two subfolders deeper like so:
<apps>
<web-application>
<name>Test</name>
<vpath>/</vpath>
<path>/srv/aspnettest/</path>
<vhost>localhost</vhost>
</web-application>
</apps>
If I try to go to http://localhost/folder1/folder2/Service.asmx it fails with
HTTP 500. Error processing request.
Stack Trace:
System.Web.HttpException: Type MyType.Service not found.
at System.Web.UI.SimpleWebHandlerParser.GetTypeFromBin (System.String tname) [0x00000] in <filename unknown>:0
at System.Web.Compilation.SimpleBuildProvider.LoadTypeFromBin (System.Web.Compilation.BaseCompiler compiler, System.Web.UI.SimpleWebHandlerParser parser) [0x00000] in <filename unknown>:0
at System.Web.Compilation.GenericBuildProvider`1[TParser].GetGeneratedType (System.CodeDom.Compiler.CompilerResults results) [0x00000] in <filename unknown>:0
at System.Web.Compilation.BuildManagerCacheItem..ctor (System.Reflection.Assembly assembly, System.Web.Compilation.BuildProvider bp, System.CodeDom.Compiler.CompilerResults results) [0x00000] in <filename unknown>:0
at System.Web.Compilation.BuildManager.StoreInCache (System.Web.Compilation.BuildProvider bp, System.Reflection.Assembly compiledAssembly, System.CodeDom.Compiler.CompilerResults results) [0x00000] in <filename unknown>:0
at System.Web.Compilation.BuildManager.GenerateAssembly (System.Web.Compilation.AssemblyBuilder abuilder, System.Web.Compilation.BuildProviderGroup group, System.Web.VirtualPath vp, Boolean debug) [0x00000] in <filename unknown>:0
at System.Web.Compilation.BuildManager.BuildInner (System.Web.VirtualPath vp, Boolean debug) [0x00000] in <filename unknown>:0
at System.Web.Compilation.BuildManager.Build (System.Web.VirtualPath vp) [0x00000] in <filename unknown>:0
at System.Web.Compilation.BuildManager.GetCompiledType (System.Web.VirtualPath virtualPath) [0x00000] in <filename unknown>:0
at System.Web.Compilation.BuildManager.GetCompiledType (System.String virtualPath) [0x00000] in <filename unknown>:0
at System.Web.Services.Protocols.WebServiceHandlerFactory.GetHandler (System.Web.HttpContext context, System.String verb, System.String url, System.String filePath) [0x00000] in <filename unknown>:0
at System.Web.HttpApplication.GetHandler (System.Web.HttpContext context, System.String url, Boolean ignoreContextHandler) [0x00000] in <filename unknown>:0
at System.Web.HttpApplication.GetHandler (System.Web.HttpContext context, System.String url) [0x00000] in <filename unknown>:0
at System.Web.HttpApplication+<Pipeline>c__Iterator2.MoveNext () [0x00000] in <filename unknown>:0
How can I successfully get a web app in subfolders? Thanks.
Turns out this was an Apache configuration issue that was unrelated but caused this as a side effect. I had my VirtualHost setup incorrectly.

Resources