I wrote a method to submit an error-report via HTTP POST. I run OSX-Lion and MonoDevelop. The code works when the application is called from MonoDevelop. When I run the .app it throws an exception:
System.TypeInitializationException: An exception was thrown by the type initializer for System.Net.WebRequest ---> System.DllNotFoundException: libc.dylib
at (wrapper managed-to-native) System.Platform:uname (intptr)
at System.Platform.get_IsMacOS () [0x00000] in <filename unknown>:0
at System.Net.WebRequest..cctor () [0x00000] in <filename unknown>:0
--- End of inner exception stack trace ---
at ch.fangorn.LIF.Access.SubmitCrash.Submit (Int32 projectId) [0x00000] in <filename unknown>:0
At the moment I call the Submit method directly not via a catch. Since it works when a debugger is attached I'm stranded. What I so far tried:
Build a mono application bundle (Create mac installer)
Build everything with Platform target x86
The beta version of Mono and MonoDevelop
The code that IMO causes the crash.
HttpWebRequest hwr = WebRequest.Create(turi) as HttpWebRequest;
string authInfo = user + ":" + password;
authInfo = Convert.ToBase64String(Encoding.Default.GetBytes(authInfo));
hwr.Headers["Authorization"] = "Basic " + authInfo;
hwr.Method = "POST";
hwr.ContentType = "text/xml";
hwr.ContentLength = encData.Length;
Stream send = hwr.GetRequestStream();
send.Write(encData, 0, encData.Length);
send.Close();
hwr.GetResponse();
MonoDevelop: 2.8.5
Mono: 2.10.8
Symptom: System libraries not found (System.DllNotFoundException: libc.dylib)
when a mono created .app is started outside of MonoDevelop.
In the wrapper-script created by mono develop: MyApp.app/Contents/MacOS/MyApp
DYLD_FALLBACK_LIBRARY_PATH is set without including default. Since an empty
DYLD_FALLBACK_LIBRARY_PATH means the default this will remove default. System
libraries cannot be found.
In my opition the line should be:
export DYLD_FALLBACK_LIBRARY_PATH="$MONO_FRAMEWORK_PATH/lib:$DYLD_FALLBACK_LIBRARY_PATH:$(HOME)/lib:/usr/local/lib:/lib:/usr/lib"
Or a check if DYLD_FALLBACK_LIBRARY_PATH is empty would be even better.
I filed a bug-report: http://bugzilla.xamarin.com/show_bug.cgi?id=2727
Related
I created an apk file and installed into my device. Afterwards, I try running my emulator on visual studio but it does not work anymore. It kept showing me errors. Does anyone know how to solve this issue?
Severity Code Description Project File Line Suppression State
Error
Mono.Linker.MarkException: Error processing method: 'System.Void Xfx.Controls.Droid.Renderers.XfxCardViewRendererDroid::Xamarin.Forms.Platform.Android.IVisualElementRenderer.add_LayoutChange(System.EventHandler`1<Android.Views.View/LayoutChangeEventArgs>)' in assembly: 'Xfx.Controls.Droid.dll' ---> Mono.Cecil.ResolutionException: Failed to resolve System.Void Xamarin.Forms.Platform.Android.IVisualElementRenderer::add_LayoutChange(System.EventHandler`1<Android.Views.View/LayoutChangeEventArgs>)
at Mono.Linker.Steps.MarkStep.HandleUnresolvedMethod(MethodReference reference)
at Mono.Linker.Steps.MarkStep.MarkMethod(MethodReference reference)
at Mono.Linker.Steps.MarkStep.ProcessMethod(MethodDefinition method)
at Mono.Linker.Steps.MarkStep.ProcessQueue()
--- End of inner exception stack trace ---
at Mono.Linker.Steps.MarkStep.ProcessQueue()
at Mono.Linker.Steps.MarkStep.ProcessPrimaryQueue()
at Mono.Linker.Steps.MarkStep.Process()
at Mono.Linker.Steps.MarkStep.Process(LinkContext context)
at MonoDroid.Tuner.MonoDroidMarkStep.Process(LinkContext context)
at Mono.Linker.Pipeline.ProcessStep(LinkContext context, IStep step)
at Mono.Linker.Pipeline.Process(LinkContext context)
at MonoDroid.Tuner.Linker.Process(LinkerOptions options, ILogger logger, LinkContext& context)
at Xamarin.Android.Tasks.LinkAssemblies.Execute(DirectoryAssemblyResolver res)
at Xamarin.Android.Tasks.LinkAssemblies.RunTask()
at Xamarin.Android.Tasks.AndroidTask.Execute() iSmart_ProductionApp.Android
I am choosing Empty template while creating a new asp.net core web application (.net core 3) as a option.
When I run project, I face with this error
System.TypeInitializationException: 'The type initializer for 'Microsoft.Extensions.Logging.EventSource.LoggingEventSource' threw an exception.'
Stack Trace:
at Microsoft.Extensions.Hosting.Host.<>c.<CreateDefaultBuilder>b__1_2(HostBuilderContext hostingContext, ILoggingBuilder logging)
at Microsoft.Extensions.Hosting.HostingHostBuilderExtensions.<>c__DisplayClass4_1.<ConfigureLogging>b__1(ILoggingBuilder builder)
at Microsoft.Extensions.DependencyInjection.LoggingServiceCollectionExtensions.AddLogging(IServiceCollection services, Action`1 configure)
at Microsoft.Extensions.Hosting.HostingHostBuilderExtensions.<>c__DisplayClass4_0.<ConfigureLogging>b__0(HostBuilderContext context, IServiceCollection collection)
at Microsoft.Extensions.Hosting.HostBuilder.CreateServiceProvider()
at Microsoft.Extensions.Hosting.HostBuilder.Build()
at WebApplication2.Program.Main(String[] args) in D:\WebApplication2\WebApplication2\Program.cs:line 16
Stack Trace in Inner Exception:
at System.Globalization.CompareInfo.CompareString(ReadOnlySpan`1 string1, ReadOnlySpan`1 string2, CompareOptions options)
at System.Globalization.CompareInfo.Compare(String string1, String string2, CompareOptions options)
at System.Globalization.TextInfo.PopulateIsAsciiCasingSameAsInvariant()
at System.Globalization.TextInfo.ChangeCaseCommon[TConversion](String source)
at System.Globalization.TextInfo.ToUpper(String str)
at System.String.ToUpperInvariant()
at System.Diagnostics.Tracing.EventSource.GetGuid(Type eventSourceType)
at System.Diagnostics.Tracing.EventSource..ctor(EventSourceSettings settings, String[] traits)
at System.Diagnostics.Tracing.EventSource..ctor(EventSourceSettings settings)
at Microsoft.Extensions.Logging.EventSource.LoggingEventSource..cctor()
What is this and how can I resolve it.
Thanks.
The problem was solved for me when I run the application on IIS instead of IIS Express.
I'm writing a VB.Net app in VS2015 which connects to a socket and listens for data. It works perfectly on Windows but when I try to run it under Mono 3.2.8 I get an unusual behaviour.
Here is a simplified version of my code. This works on Windows:
Module Module1
Sub Main()
' Declare client socket and client stream to get data from the dongle etc
Dim clientSocket As New TcpClient()
Dim clientStream As NetworkStream
' Connect to socket
clientSocket.ExclusiveAddressUse = False
clientSocket.LingerState.LingerTime = 0
' Try to connect to socket
Try
clientSocket.Connect("127.0.0.1", 30003)
Catch ex As Exception
' write error
Console.WriteLine("Exception: " & ex.ToString())
End Try
' Tie server stream to socket
clientStream = clientSocket.GetStream()
End Sub
End Module
The error message thrown is:
Unhandled Exception:
System.InvalidOperationException: Bind has already been called for this socket
at System.Net.Sockets.Socket.set_ExclusiveAddressUse (Boolean value) [0x00000] in :0
at System.Net.Sockets.TcpClient.set_ExclusiveAddressUse (Boolean value) [0x00000] in :0
at ConsoleApplication1.Module1.Main () [0x00000] in :0
[ERROR] FATAL UNHANDLED EXCEPTION: System.InvalidOperationException: Bind has already been called for this socket
at System.Net.Sockets.Socket.set_ExclusiveAddressUse (Boolean value) [0x00000] in :0
at System.Net.Sockets.TcpClient.set_ExclusiveAddressUse (Boolean value) [0x00000] in :0
at ConsoleApplication1.Module1.Main () [0x00000] in :0
As I'm setting clientSocket.ExclusiveAddressUse = False before I specify the IP address and port I can't see why it's failing.
Looking around on the web I can see mentions of this as a bug back in 2010 but nothing more recent. I've searched the release notes of all releases after 3.2.8 but there is no mention so it looks like this is still a bug ?
If it is, is there a work around ?
I'm about ready to pull my hair out over this problem because all the guides show the same one or two solutions, which seem to be working for everyone but myself.
I'm using SignalR in a Mono application, using Owin. I've set EnableCrossDomain = true in my HubConfiguration. I've set up a simple test page using javascript to connect. The negotiate and ping urls are loading without issue and seem to be replying correctly. However I get a cross domain error on the connect call.
It's definitely using my EnableCrossDomain setting because if I set that to false, negotiate doesn't work.
Here's my Javascript to connect (and yes I'm including the /signalr/hubs script which returns the appropriate javascript):
$.connection.hub.url = 'http://localhost:7001/signalr';
$.connection.hub.logging = true;
$.connection.hub.start()
.done(function () { alert("Now connected!"); })
.fail(function () { alert("Could not Connect!"); });
Also I've tried jQuery.support.cors = true; as well but it doesn't make any difference.
I also tried connecting to a regular PersistantConnection like so, with the same problem, so it doesn't appear to be directly related to hubs:
var connection = $.connection('/raw');
connection.url = 'http://localhost:7001/signalr';
connection.start()
.done(function () { alert("Now connected!"); })
.fail(function () { alert("Could not Connect!"); });
What am I doing wrong here? Why do ping and negotiate work but not connect?
EDIT: Also to make matters weirder, I added some logging and verified that the SignalR CallHandler class is adding the Access-Control-Allow-Origin header for all requests, including the connect request. So it should be working.
EDIT 2: So actually thanks to curl it looks like the server is returning a 500 response code, and since it's not also including the header (this must be happening after the code block I added the logging to), Chrome complains about cross site, when really there's probably an exception being thrown somewhere in the server. Hopefully I'll have this figured out shortly and will post an answer here.
So it actually turned out to have nothing to do with cross site access, and everything to do with Mono incompatibilities.
After I enabled exception logging for SignalR (https://stackoverflow.com/a/16577890/299262) I got the following exception instead of just a blank http 500 error:
System.InvalidOperationException: The connection id is in the incorrect format.
at Microsoft.AspNet.SignalR.PersistentConnection.GetConnectionId (Microsoft.AspNet.SignalR.Hosting.HostContext context, System.String connectionToken) [0x00000] in <filename unknown>:0
at Microsoft.AspNet.SignalR.PersistentConnection.ProcessRequest (Microsoft.AspNet.SignalR.Hosting.HostContext context) [0x00000] in <filename unknown>:0
at Microsoft.AspNet.SignalR.Hubs.HubDispatcher.ProcessRequest (Microsoft.AspNet.SignalR.Hosting.HostContext context) [0x00000] in <filename unknown>:0
at Microsoft.AspNet.SignalR.Owin.CallHandler.Invoke (IDictionary`2 environment) [0x00000] in <filename unknown>:0
at Microsoft.AspNet.SignalR.Owin.Handlers.HubDispatcherHandler.Invoke (IDictionary`2 environment) [0x00000] in <filename unknown>:0
at Microsoft.AspNet.SignalR.Owin.Handlers.PersistentConnectionHandler.Invoke (IDictionary`2 environment) [0x00000] in <filename unknown>:0
at Microsoft.Owin.Diagnostics.ShowExceptionsMiddleware.Invoke (IDictionary`2 environment) [0x00000] in <filename unknown>
That led me to find this ticket on the SignalR repo issues list: https://github.com/SignalR/SignalR/issues/1914
So in the end, the fix was to comment out the following line in HostDependencyResolverExtensions.cs:
resolver.InitializePerformanceCounters(instanceName, hostShutdownToken);
I have a simple code
byte[] buffer = Encoding.UTF8.GetBytes("abracadabra");
MemoryStream ms = new MemoryStream();
DeflateStream ds = new DeflateStream(ms, CompressionMode.Compress, false);
ms.Write(buffer, 0, buffer.Length);
DeflateStream ds2 = new DeflateStream(ms, CompressionMode.Decompress, false);
byte[] buffer2 = new byte[ms.Length];
ds2.Read(buffer2, 0, (int)ms.Length);
Console.WriteLine(Encoding.UTF8.GetString(buffer2));
And when reading from ds2, i have the following:
Stacktrace:
at (wrapper managed-to-native)
System.IO.Compression.DeflateStream.ReadZStream
(intptr,intptr,int) <0x00004>
at (wrapper managed-to-native)
System.IO.Compression.DeflateStream.ReadZStream
(intptr,intptr,int) <0x00004>
at
System.IO.Compression.DeflateStream.ReadInternal
(byte[],int,int) [0x00031] in
C:\cygwin\tmp\monobuild\build\BUILD\mono-2.6.3\mcs\class\System\System.IO.Compression\DeflateStream.cs:192
at
System.IO.Compression.DeflateStream.Read
(byte[],int,int) [0x00086] in
C:\cygwin\tmp\monobuild\build\BUILD\mono-2.6.3\mcs\class\System\System.IO.Compression\DeflateStream.cs:214
at testtesttest.MainClass.Main
(string[]) [0x00041] in
C:\Users\ilukyanov\Desktop\Cassini\GZipDemo\Main.cs:27
at (wrapper runtime-invoke)
.runtime_invoke_void_object
(object,intptr,intptr,intptr)
This application has requested the
Runtime to terminate it in an unusual
way. Please contact the application's
support team for more information.
This problem appears in Mono 2.6.1 & 2.6.3...
Is there any known way to successfully read from DeflateStream in Mono? Or maybe there are some third-party open-source assemblies with the same functionality?
You can call zlib natively using Interop with DllImport.
Only trick is to use the right size in the structures and to include the shared library in the LD_LIBRARY_PATH, if you are on a Unix platform.
Please file a bug against Mono. If you do so, it might get fixed in time for 2.6.4.