I'm creating an app using xamarin Cross Platform. Everything is working in debug, but when i bulid app in release version, app crashes. Application output:
ERROR:
[mono] Unhandled Exception: [mono] System.MissingMethodException:
Method not found: 'System.Net.Http.HttpClient.GetAsync'.
[mono] at System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[<LoadData>d__0] (POSSector.Mobile.<LoadData>d__0& stateMachine)
[0x00000] in <filename unknown>:0
[mono] at POSSector.Mobile.LoginViewModel.LoadData ()
[0x00000] in <filename unknown>:0
[mono] at POSSector.Mobile.LoginCommand+<Bind>d__3.MoveNext () [0x00000] in <filename unknown>:0
[mono] --- End of stack trace from previous location where exception was thrown --- [mono] at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw ()
[0x00000] in <filename unknown>:0 [mono] at System.Runtime.CompilerServices.TaskAwaiter.GetResult ()
[0x00000] in <filename unknown>:0 [mono] at POSSector.Mobile.LoginCommand+<Execute>d__0.MoveNext ()
[0x00000] in <filename unknown>:0
[mono-rt] [ERROR] FATAL UNHANDLED EXCEPTION: System.MissingMethodException: Method not found: 'System.Net.Http.HttpClient.GetAsync'.
In Options - Android Build- Linker / I set Don link and my App work !
Info for problem
Related
I have a native Xamarin.Android app I've built a few years back and I've been maintaining it since then. Lately, I tried to build a new release but the app keeps crashing. I did tens of releases in the past using the same project and compilation settings. Here's an exemple of a stack trace I get in release:
[mono-rt] [ERROR] FATAL UNHANDLED EXCEPTION: System.IO.FileNotFoundException: Could not load file or assembly 'System.Core, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e' or one of its dependencies.
[mono-rt] at System.Threading.Tasks.TaskFactory`1[TResult].FromAsyncCoreLogic (System.IAsyncResult iar, System.Func`2[T,TResult] endFunction, System.Action`1[T] endAction10-21 13:24:49.970 F/mono-rt (15785): File name: 'System.Core, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e'
[mono-rt] at Java.Interop.JniEnvironmentInfo..ctor () [0x00006] in :0
[mono-rt] at Java.Interop.JniEnvironment+c.b__35_0 () [0x00000] in :0
[mono-rt] at System.Threading.ThreadLocal`1[T].GetValueSlow () [0x00031] in :0
[mono-rt] at System.Threading.ThreadLocal`1[T].get_Value () [0x0003e] in :0
[mono-rt] at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback () [0x00000] in :0ds.CallStaticObjectMethod (Java.Interop.JniObjectReference type, Java.Interop.JniMethodInfo method, Java.Interop.JniArgumentValue* args) [0x0002d] in :0
[mono-rt] at Java.Interop.JniPeerMembers+JniStaticMethods.InvokeObjectMethod (System.String encodedMember, Java.Interop.JniArgumentValue* parameters) [0x00018] in :0
[mono-rt] at Java.Interop.JniEnvironment+StaticMet10-21 13:24:49.970 F/mono-rt (15785): at Android.OS.Looper.get_MainLooper () [0x0000a] in :0
[mono-rt] at Android.Runtime.AndroidEnvironment.GetDefaultSyncContext () [0x00000] in :0
[mono-rt] at System.AndroidPlatform.GetDefaultSyncContext () [0x00000] in :0
[mono-rt] at System.Threading.SynchronizationContext.GetThreadLocalContext () [0x00005] in :0
[mono-rt] at System.Threading.Tasks.SynchronizationContextAwaitTaskContinuation.Run (System.Threading.Tasks.Task ignored, System.Boolean canInlineContinuationTask) [0x00003] in :0
[mono-rt] at System.Threading.Tasks.Task.FinishStageThree () [0x0003c] in :0
[mono-rt] at System.Threading.Tasks.Task`1[TResult].TrySetResult (TResult result) [0x0004f] in :0
[mono-rt] at System.Threading.Tasks.TaskFactory`1+c__DisplayClass38_0`1[TResult,TArg1].b__0 (System.IAsyncResult iar) [0x00008] in :0
[mono-rt] at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback () [0x00000] in 10-21 13:24:49.970 F/mono-rt (15785): at (wrapper managed-to-native) System.Runtime.Remoting.Messaging.AsyncResult.Invoke(System.Runtime.Remoting.Messaging.AsyncResult)
[mono-rt] at System.Runtime.Remoting.Messaging.AsyncResult.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem () [0x00000] in :0
[mono-rt] at System.Threading.ThreadPoolWorkQueue.Dispatch () [0x00074] in :0
From the stack trace, I have a feeling it might be a problem with the linker, but I have tried all 3 settings (Don't link, link SDK assemblies only, link all). When changing some code here and there, I have sometimes slightly different stack traces, but nothing really helpful. Here's the compilation settings I'm using:
From time to time, the app will launch successfully without changing anytime special. It will only work once.
What I'm I missing?
I am pretty sure that you have some weird behavior in release. Since you use mono on android you may call an await function somewhere that return a Task<T> you must not use the await but .GetAwaiter().Result.
https://github.com/xamarin/xamarin-android/issues/6409
Make sure your .NET framework is patched. Microsoft released patches to .NET to allow Portable Class Libraries to properly find the appropriate runtime (KB2468871). If you are seeing the above exception (or something like it), it means you’re missing the latest .NET framework patches.
You can read more about Portable Class Libraries on MSDN.
I'm having a problems building a PCL in Xamarin Studio on the Mac. It works fine in debug mode but fody throws an exception in Release Mode.
Exception during build is listed below.
Error: Fody: An unhandled exception occurred:
Exception:
Symbol file `XXX/obj/Release/XXX.dll.mdb' does not match assembly `XXX/obj/Release/XXX.dll'
StackTrace:
at Mono.CompilerServices.SymbolWriter.MonoSymbolFile.CheckGuidMatch (Guid other, System.String filename, System.String assembly) [0x00000] in <filename unknown>:0
at Mono.CompilerServices.SymbolWriter.MonoSymbolFile..ctor (System.String filename, Mono.Cecil.ModuleDefinition module) [0x00000] in <filename unknown>:0
at Mono.CompilerServices.SymbolWriter.MonoSymbolFile.ReadSymbolFile (Mono.Cecil.ModuleDefinition module, System.String filename) [0x00000] in <filename unknown>:0
at Mono.Cecil.Mdb.MdbReaderProvider.GetSymbolReader (Mono.Cecil.ModuleDefinition module, System.String fileName) [0x00000] in <filename unknown>:0
at Mono.Cecil.ModuleReader.ReadSymbols (Mono.Cecil.ModuleDefinition module, Mono.Cecil.ReaderParameters parameters) [0x00000] in <filename unknown>:0
at Mono.Cecil.ModuleReader.CreateModuleFrom (Mono.Cecil.PE.Image image, Mono.Cecil.ReaderParameters parameters) [0x00000] in <filename unknown>:0
at Mono.Cecil.ModuleDefinition.ReadModule (System.IO.Stream stream, Mono.Cecil.ReaderParameters parameters) [0x00000] in <filename unknown>:0
at Mono.Cecil.ModuleDefinition.ReadModule (System.String fileName, Mono.Cecil.ReaderParameters parameters) [0x00000] in <filename unknown>:0
at InnerWeaver.ReadModule () [0x00000] in <filename unknown>:0
at InnerWeaver.Execute () [0x00000] in <filename unknown>:0
Source:
Mono.Cecil.Mdb
TargetSite:
Void CheckGuidMatch(System.Guid, System.String, System.String)
Fody needs the debug information (*.mdb file) associated with the outputted assembly to perform the weaving step. Release builds by default turn off the Debug Information field within Build -> Compiler in a projects settings.
Having this build option set to None disables debug symbolication and results in the mdb file getting out of sync, hence the Symbol file 'XXX/obj/Release/XXX.dll.mdb' does not match assembly XXX/obj/Release/XXX.dll exception.
Therefore you need to enable Symbols Only or Full when you build projects in release mode when Fody is integrated into the build process:
You may have already, but I'd start with this if it was me:
Right click on your solution
Properties
Configuration Properties / Configuration
In the "Configuration" drop down in the top left, check that the "Debug" configuration (re: Platform | Build | Deploy) matches "Release".
We are busy with an application on a rasp pi where we retrieve a google calendar with the Google Calendar API. We wrote it in C# and tested it on Windows where i works fine. When we compile it on the Rasp PI (xbuild) we don't get any errors, but when we run (mono) it we get the following error:
Unhandled Exception: Google.GData.Client.GDataRequestException: Execution of request failed: http://www.google.com/calendar/feeds/USERNAME#gmail.com/private/full?start-min=2013-10-29T14:11:41Z ---> System.Net.WebException: The remote server returned an error: (401) Authorization required.
at System.Net.HttpWebRequest.CheckFinalStatus (System.Net.WebAsyncResult result) [0x00000] in <filename unknown>:0
at System.Net.HttpWebRequest.SetResponseData (System.Net.WebConnectionData data) [0x00000] in <filename unknown>:0
--- End of inner exception stack trace ---
at Google.GData.Client.GDataRequest.Execute () [0x00000] in <filename unknown>:0
at Google.GData.Client.GDataGAuthRequest.Execute (Int32 retryCounter) [0x00000] in <filename unknown>:0
[ERROR] FATAL UNHANDLED EXCEPTION: Google.GData.Client.GDataRequestException: Execution of request failed: http://www.google.com/calendar/feeds/USERNAME#gmail.com/private/full?start-min=2013-10-29T14:11:41Z ---> System.Net.WebException: The remote server returned an error: (401) Authorization required.
at System.Net.HttpWebRequest.CheckFinalStatus (System.Net.WebAsyncResult result) [0x00000] in <filename unknown>:0
at System.Net.HttpWebRequest.SetResponseData (System.Net.WebConnectionData data) [0x00000] in <filename unknown>:0
--- End of inner exception stack trace ---
at Google.GData.Client.GDataRequest.Execute () [0x00000] in <filename unknown>:0
at Google.GData.Client.GDataGAuthRequest.Execute (Int32 retryCounter) [0x00000] in <filename unknown>:0
Could someone help us, we don't see a solution.
We solved the authentification problem with running the following code:
mozroots --import --ask-remove
this is because Mono (by default) doesn't allow outside connections, so you have add it to the certificate list.
I am having problems with MVC4 on Mono 3. I am using the latest version in Xamarin Studio with the latest updates but when trying a HTTP POST to the web server it is returning the following error. I am using the DLL's for MVC4 from windows as the guides suggest and the Mono version of System.Web 4.0.0.0.
Any ideas how to resolve this issue or am I just better reverting to MVC3?
System.TypeLoadException
Could not load type 'System.Web.UnvalidatedRequestValuesBase' from assembly 'System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
Description: HTTP 500.Error processing request.
Details: Non-web exception. Exception origin (name of application or object): System.Web.Mvc.
Exception stack trace:
at System.Web.Mvc.UnvalidatedRequestValuesWrapper.get_Form () [0x00000] in <filename unknown>:0 at System.Web.Mvc.FormValueProvider..ctor (System.Web.Mvc.ControllerContext controllerContext, IUnvalidatedRequestValues unvalidatedValues) [0x00000] in <filename unknown>:0 at System.Web.Mvc.FormValueProviderFactory.GetValueProvider (System.Web.Mvc.ControllerContext controllerContext) [0x00000] in <filename unknown>:0 at System.Web.Mvc.ValueProviderFactoryCollection+<>c__DisplayClassc.<GetValueProvider>b__7 (System.Web.Mvc.ValueProviderFactory factory) [0x00000] in <filename unknown>:0 at System.Linq.Enumerable+<CreateSelectIterator>c__Iterator25`2[System.Web.Mvc.ValueProviderFactory,<>f__AnonymousType2`2[System.Web.Mvc.ValueProviderFactory,System.Web.Mvc.IValueProvider]].MoveNext () [0x00059] in /private/tmp/source/bockbuild-xamarin/profiles/mono-mac-xamarin/build-root/mono-3.2.3/mcs/class/System.Core/System.Linq/Enumerable.cs:2269 at System.Linq.Enumerable+<CreateWhereIterator>c__Iterator33`1[<>f__AnonymousType2`2[System.Web.Mvc.ValueProviderFactory,System.Web.Mvc.IValueProvider]].MoveNext () [0x0006f] in /private/tmp/source/bockbuild-xamarin/profiles/mono-mac-xamarin/build-root/mono-3.2.3/mcs/class/System.Core/System.Linq/Enumerable.cs:3120 at System.Linq.Enumerable+<CreateSelectIterator>c__Iterator25`2[<>f__AnonymousType2`2[System.Web.Mvc.ValueProviderFactory,System.Web.Mvc.IValueProvider],System.Web.Mvc.IValueProvider].MoveNext () [0x00059] in /private/tmp/source/bockbuild-xamarin/profiles/mono-mac-xamarin/build-root/mono-3.2.3/mcs/class/System.Core/System.Linq/Enumerable.cs:2269 at System.Collections.Generic.List`1[System.Web.Mvc.IValueProvider].AddEnumerable (IEnumerable`1 enumerable) [0x00013] in /private/tmp/source/bockbuild-xamarin/profiles/mono-mac-xamarin/build-root/mono-3.2.3/mcs/class/corlib/System.Collections.Generic/List.cs:134 at System.Collections.Generic.List`1[System.Web.Mvc.IValueProvider]..ctor (IEnumerable`1 collection) [0x0002f] in /private/tmp/source/bockbuild-xamarin/profiles/mono-mac-xamarin/build-root/mono-3.2.3/mcs/class/corlib/System.Collections.Generic/List.cs:69 at System.Linq.Enumerable.ToList[IValueProvider] (IEnumerable`1 source) [0x00006] in /private/tmp/source/bockbuild-xamarin/profiles/mono-mac-xamarin/build-root/mono-3.2.3/mcs/class/System.Core/System.Linq/Enumerable.cs:2951 at System.Web.Mvc.ValueProviderFactoryCollection.GetValueProvider (System.Web.Mvc.ControllerContext controllerContext) [0x00000] in <filename unknown>:0 at System.Web.Mvc.ControllerBase.get_ValueProvider () [0x00000] in <filename unknown>:0 at System.Web.Mvc.ControllerActionInvoker.GetParameterValue (System.Web.Mvc.ControllerContext controllerContext, System.Web.Mvc.ParameterDescriptor parameterDescriptor) [0x00000] in <filename unknown>:0 at System.Web.Mvc.ControllerActionInvoker.GetParameterValues (System.Web.Mvc.ControllerContext controllerContext, System.Web.Mvc.ActionDescriptor actionDescriptor) [0x00000] in <filename unknown>:0 at System.Web.Mvc.Async.AsyncControllerActionInvoker+<>c__DisplayClass25.<BeginInvokeAction>b__1e (System.AsyncCallback asyncCallback, System.Object asyncState) [0x00000] in <filename unknown>:0
Version Information: 3.2.3 ((no/8d3b4b7 Mon Sep 16 23:46:28 EDT 2013); ASP.NET Version: 4.0.30319.17020
Since I had the same error with MVC 3 Razor like you I solved my problem by
copying following DLL's from a MVC 3 Razor Visual Studio project to my mono project.
System.Web.Helpers.dll
System.Web.Mvc.dll
System.Web.Razor.dll
System.Web.WebPages.dll
System.Web.WebPages.Deployment.dll
System.Web.WebPages.Razor.dll
This might help as well:
http://blog.yojimbocorp.com/2012/08/27/asp-net-mvc3-with-razor-view-engine-using-monodevelop-and-ubuntu-12-04/
I've recently came across the blog article Monovation: Assembly Injection into Live Processes of Miguel de Icaza.
I've tried to reproduce it with no luck. My command line was
'csharp --attach 5612'
where 5612 was the pid of a simple running mono 'Hello World' console application.
I've got an exception (see the stack trace above).
What I've tried so far:
using Mono 2.10.8 (csharp and csharp2 commands for .NET 4 and 2 )
using Mono 3.2.3 (only csharp command exists)
Q1: Missed I something?
Q2: Is it possible that this virtual machine attach facility (see Monovation: Assembly Injection into Live Processes) is available only in Linux installations? (I am using Windows 7) It sounds an easy answer, but Miguel does not mention platform restriction in his article, and the whole point of mono is the multiplatform, is not it? So I can not believe it so easy.
Q3: What about Mac? Is there any chance it will work in a Mac, or we must look elsewhere?
Thx in advance
Stack trace:
Unhandled Exception:
System.TypeInitializationException: An exception was thrown by the type initializer for Mono.Unix.Native.Syscall ---> System.EntryPointNotFoundException: Mono_Posix_Syscall_get_at_fdcwd
at (wrapper managed-to-native) Mono.Unix.Native.Syscall:get_at_fdcwd ()
at Mono.Unix.Native.Syscall..cctor () [0x00000] in <filename unknown>:0
--- End of inner exception stack trace ---
at Mono.Unix.UnixUserInfo.GetRealUserId () [0x00000] in <filename unknown>:0
at Mono.Unix.UnixUserInfo.GetRealUser () [0x00000] in <filename unknown>:0
at Mono.Attach.VirtualMachine.Attach (System.String agent, System.String args) [0x00000] in <filename unknown>:0
at Mono.ClientCSharpShell..ctor (Mono.CSharp.Evaluator evaluator, Int32 pid) [0x00000] in <filename unknown>:0
at Mono.Driver.Main (System.String[] args) [0x00000] in <filename unknown>:0
[ERROR] FATAL UNHANDLED EXCEPTION: System.TypeInitializationException: An exception was thrown by the type initializer for Mono.Unix.Native.Syscall ---> System.EntryPointNotFoundException: Mono_Posix_Syscall_get_at_fdcwd
at (wrapper managed-to-native) Mono.Unix.Native.Syscall:get_at_fdcwd ()
at Mono.Unix.Native.Syscall..cctor () [0x00000] in <filename unknown>:0
--- End of inner exception stack trace ---
at Mono.Unix.UnixUserInfo.GetRealUserId () [0x00000] in <filename unknown>:0
at Mono.Unix.UnixUserInfo.GetRealUser () [0x00000] in <filename unknown>:0
at Mono.Attach.VirtualMachine.Attach (System.String agent, System.String args) [0x00000] in <filename unknown>:0
at Mono.ClientCSharpShell..ctor (Mono.CSharp.Evaluator evaluator, Int32 pid) [0x00000] in <filename unknown>:0
at Mono.Driver.Main (System.String[] args) [0x00000] in <filename unknown>:0