Read json file inside a zip file without decompression remotely - c#

I am trying to read a zip file remotly from a url this bit works fine if its from disk but I want to read it remotly without unzipping the file first is that possible or would it make the file inacessable to others?.
public void GetMSFSAddonDetails(string zipFileUrl) {
using (ZipArchive archive = ZipFile.OpenRead(zipFileUrl))
{
var sample = archive.GetEntry("manifest.json");
if (sample != null)
{
using (var zipEntryStream = sample.Open())
{
// serializer = new XmlSerializer(typeof(SampleClass));
/// SampleClass deserialized =
// (SampleClass)serializer.Deserialize(zipEntryStream);
}
}
Edit 2
I am getting the following error when i try to donwload a zip file from the url
This is using android forms with the mainfest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
android:versionCode="1" android:versionName="1.0"
package="com.companyname.msfsaddonshub.forms" android:installLocation="auto">
<uses-sdk android:minSdkVersion="28" android:targetSdkVersion="29" />
<application android:label="MSFSAddonsHub.Forms.Android" android:theme="#style/MainTheme"></application>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
</manifest>
01-03 08:10:43.333 F/addonshub.form( 6899): java_vm_ext.cc:570] at
System.IO.Compression.ZipFile.Open (System.String archiveFileName,
System.IO.Compression.ZipArchiveMode mode) [0x00000] in
/Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/System.IO.Compression.ZipFile/src/System/IO/Compression/ZipFile.cs:81
01-03 08:10:43.333 F/addonshub.form( 6899): java_vm_ext.cc:570] at
System.IO.Compression.ZipFile.OpenRead (System.String archiveFileName)
[0x00000] in
/Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/System.IO.Compression.ZipFile/src/System/IO/Compression/ZipFile.cs:39
01-03 08:10:43.333 F/addonshub.form( 6899): java_vm_ext.cc:570] at
MSFSAddonsHub.BL.MSFSBL.GetMSFSAddonDetails (System.String zipFileUrl)
[0x00001] in
D:\GitMaster\MSFSAddonsHub\MSFSAddonsHub.BL\MSFSAddonsHub.BL\MSFSBL.cs:17
01-03 08:10:43.333 F/addonshub.form( 6899): java_vm_ext.cc:570] at
MSFSAddonsHub.BL.MSFSBL.DownloadTestFile () [0x00001] in
D:\GitMaster\MSFSAddonsHub\MSFSAddonsHub.BL\MSFSAddonsHub.BL\MSFSBL.cs:13
01-03 08:10:43.333 F/addonshub.form( 6899): java_vm_ext.cc:570] at
MSFSAddonsHub.Forms.Views.MainMenu..ctor () [0x0001a] in
D:\GitMaster\MSFSAddonsHub\MSFSAddonsHub.Forms\MSFSAddonsHub.Forms\MSFSAddonsHub.Forms\Views\MainMenu.xaml.cs:20
01-03 08:10:43.333 F/addonshub.form( 6899): java_vm_ext.cc:570] at
(wrapper managed-to-native)
System.Reflection.RuntimeConstructorInfo.InternalInvoke(System.Reflection.RuntimeConstructorInfo,object,object[],System.Exception&)
01-03 08:10:43.333 F/addonshub.form( 6899): java_vm_ext.cc:570] at
System.Reflection.RuntimeConstructorInfo.InternalInvoke (System.Object
obj, System.Object[] parameters, System.Boolean wrapExceptions)
[0x00005] in
/Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/corlib/System.Reflection/RuntimeMethodInfo.cs:936
01-03 08:10:43.333 F/addonshub.form( 6899): java_vm_ext.cc:570] ---
End of inner exception stack trace --- 01-03 08:10:43.333
F/addonshub.form( 6899): java_vm_ext.cc:570] at
System.Reflection.RuntimeConstructorInfo.InternalInvoke (System.Object
obj, System.Object[] parameters, System.Boolean wrapExceptions)
[0x00018] in
/Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/corlib/System.Reflection/RuntimeMethodInfo.cs:944
01-03 08:10:43.333 F/addonshub.form( 6899): java_vm_ext.cc:570] at
System.RuntimeType.CreateInstanceMono (System.Boolean nonPublic,
System.Boolean wrapExceptions) [0x00095] in
/Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/corlib/ReferenceSources/RuntimeType.cs:185
01-03 08:10:43.333 F/addonshub.form( 6899): java_vm_ext.cc:570] at
System.RuntimeType.CreateInstanceSlow (System.Boolean publicOnly,
System.Boolean wrapExceptions, System.Boolean skipCheckThis,
System.Boolean fillCache) [0x00009] in
/Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/corlib/ReferenceSources/RuntimeType.cs:155
01-03 08:10:43.333 F/addonshub.form( 6899): java_vm_ext.cc:570] at
System.RuntimeType.CreateInstanceDefaultCtor (System.Boolean
publicOnly, System.Boolean skipCheckThis, System.Boolean fillCache,
System.Boolean wrapExceptions, System.Threading.StackCrawlMark&
stackMark) [0x00027] in
/Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/referencesource/mscorlib/system/rttype.cs:5770
01-03 08:10:43.333 F/addonshub.form( 6899): java_vm_ext.cc:570] at
System.Activator.CreateInstance (System.Type type, System.Boolean
nonPublic, System.Boolean wrapExceptions) [0x00039] in
/Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/referencesource/mscorlib/system/activator.cs:206
01-03 08:10:43.333 F/addonshub.form( 6899): java_vm_ext.cc:570] at
System.Activator.CreateInstance (System.Type type, System.Boolean
nonPublic) [0x00000] in
/Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/referencesource/mscorlib/system/activator.cs:190
01-03 08:10:43.333 F/addonshub.form( 6899): java_vm_ext.cc:570] a

As far as I know the method ZipFile.OpenRead(String) does not handle URLs! It expects an archiveFileName and searches on the disk.
You would probably have to download the zip file and open it afterwards.

Related

System.IO.DirectoryNotFoundException: Could not find a parth of the path

I'm working with MRTK in Unity and I'm trying to access the namespace Microsoft.MixedReality in a script, but I get the error that MixedRealty doesn't exist at Microsoft namespace. However, at the MixedReality script all the namespaces are found, which troubles me for not knowing how to access the namespace.
At the same time, I'm getting this error at the console log:
System.IO.DirectoryNotFoundException: Could not find a part of the path 'C:\Users\User\Documents\cummins-loto\Library\PackageCache\com.microsoft.mixedreality.toolkit.foundation#a77cb7137a89-1660746982947\SDK\Experimental\InteractiveElement\Examples\Scripts\CustomStateExample\KeyboardState'.
at System.IO.__Error.WinIOError (System.Int32 errorCode, System.String maybeFullPath) [0x000f7] in <695d1cc93cca45069c528c15c9fdd749>:0
at System.IO.FileSystemEnumerableIterator1[TSource].HandleError (System.Int32 hr, System.String path) [0x00006] in <695d1cc93cca45069c528c15c9fdd749>:0 at System.IO.FileSystemEnumerableIterator1[TSource].CommonInit () [0x00054] in <695d1cc93cca45069c528c15c9fdd749>:0
at System.IO.FileSystemEnumerableIterator1[TSource]..ctor (System.String path, System.String originalUserPath, System.String searchPattern, System.IO.SearchOption searchOption, System.IO.SearchResultHandler1[TSource] resultHandler, System.Boolean checkHost) [0x000d6] in <695d1cc93cca45069c528c15c9fdd749>:0
at System.IO.FileSystemEnumerableFactory.CreateFileNameIterator (System.String path, System.String originalUserPath, System.String searchPattern, System.Boolean includeFiles, System.Boolean includeDirs, System.IO.SearchOption searchOption, System.Boolean checkHost) [0x00009] in <695d1cc93cca45069c528c15c9fdd749>:0
at System.IO.Directory.InternalGetFileDirectoryNames (System.String path, System.String userPathOriginal, System.String searchPattern, System.Boolean includeFiles, System.Boolean includeDirs, System.IO.SearchOption searchOption, System.Boolean checkHost) [0x00000] in <695d1cc93cca45069c528c15c9fdd749>:0
at System.IO.Directory.InternalGetFiles (System.String path, System.String searchPattern, System.IO.SearchOption searchOption) [0x00000] in <695d1cc93cca45069c528c15c9fdd749>:0
at System.IO.Directory.GetFiles (System.String path, System.String searchPattern) [0x0001c] in <695d1cc93cca45069c528c15c9fdd749>:0
at System.IO.DirectoryInfo.GetFiles (System.String searchPattern) [0x0000e] in <695d1cc93cca45069c528c15c9fdd749>:0
at System.IO.DirectoryInfo.GetFilesSubdirs (System.Collections.ArrayList l, System.String pattern) [0x00002] in <695d1cc93cca45069c528c15c9fdd749>:0
at (wrapper remoting-invoke-with-check) System.IO.DirectoryInfo.GetFilesSubdirs(System.Collections.ArrayList,string)
at System.IO.DirectoryInfo.GetFilesSubdirs (System.Collections.ArrayList l, System.String pattern) [0x0002f] in <695d1cc93cca45069c528c15c9fdd749>:0
at (wrapper remoting-invoke-with-check) System.IO.DirectoryInfo.GetFilesSubdirs(System.Collections.ArrayList,string)
at System.IO.DirectoryInfo.GetFilesSubdirs (System.Collections.ArrayList l, System.String pattern) [0x0002f] in <695d1cc93cca45069c528c15c9fdd749>:0
at (wrapper remoting-invoke-with-check) System.IO.DirectoryInfo.GetFilesSubdirs(System.Collections.ArrayList,string)
at System.IO.DirectoryInfo.GetFilesSubdirs (System.Collections.ArrayList l, System.String pattern) [0x0002f] in <695d1cc93cca45069c528c15c9fdd749>:0
at (wrapper remoting-invoke-with-check) System.IO.DirectoryInfo.GetFilesSubdirs(System.Collections.ArrayList,string)
at System.IO.DirectoryInfo.GetFilesSubdirs (System.Collections.ArrayList l, System.String pattern) [0x0002f] in <695d1cc93cca45069c528c15c9fdd749>:0
at (wrapper remoting-invoke-with-check) System.IO.DirectoryInfo.GetFilesSubdirs(System.Collections.ArrayList,string)
at System.IO.DirectoryInfo.GetFilesSubdirs (System.Collections.ArrayList l, System.String pattern) [0x0002f] in <695d1cc93cca45069c528c15c9fdd749>:0
at (wrapper remoting-invoke-with-check) System.IO.DirectoryInfo.GetFilesSubdirs(System.Collections.ArrayList,string)
at System.IO.DirectoryInfo.GetFilesSubdirs (System.Collections.ArrayList l, System.String pattern) [0x0002f] in <695d1cc93cca45069c528c15c9fdd749>:0
at (wrapper remoting-invoke-with-check) System.IO.DirectoryInfo.GetFilesSubdirs(System.Collections.ArrayList,string)
at System.IO.DirectoryInfo.GetFilesSubdirs (System.Collections.ArrayList l, System.String pattern) [0x0002f] in <695d1cc93cca45069c528c15c9fdd749>:0
at (wrapper remoting-invoke-with-check) System.IO.DirectoryInfo.GetFilesSubdirs(System.Collections.ArrayList,string)
at System.IO.DirectoryInfo.GetFilesSubdirs (System.Collections.ArrayList l, System.String pattern) [0x0002f] in <695d1cc93cca45069c528c15c9fdd749>:0
at System.IO.DirectoryInfo.GetFiles (System.String searchPattern, System.IO.SearchOption searchOption) [0x00017] in <695d1cc93cca45069c528c15c9fdd749>:0
at (wrapper remoting-invoke-with-check) System.IO.DirectoryInfo.GetFiles(string,System.IO.SearchOption)
at Microsoft.MixedReality.Toolkit.Utilities.Editor.OnLoadUtilities.FindShaderFolderInPackage () [0x0005f] in C:\Users\User\Documents\cummins loto\Library\PackageCache\com.microsoft.mixedreality.toolkit.standardassets#52286f91c474-1660746983015\EditorUtilities\OnLoadUtilities.cs:152
at Microsoft.MixedReality.Toolkit.Utilities.Editor.OnLoadUtilities.EnsureShaders (System.Boolean bypassIgnore) [0x00001] in C:\Users\User\Documents\cummins-loto\Library\PackageCache\com.microsoft.mixedreality.toolkit.standardassets#52286f91c474-1660746983015\EditorUtilities\OnLoadUtilities.cs:42
at Microsoft.MixedReality.Toolkit.Utilities.Editor.OnLoadUtilities..cctor () [0x00001] in C:\Users\User\Documents\cummins-loto\Library\PackageCache\com.microsoft.mixedreality.toolkit.standardassets#52286f91c474-1660746983015\EditorUtilities\OnLoadUtilities.cs:23
UnityEditor.EditorAssemblies:ProcessInitializeOnLoadAttributes (System.Type[])
I don't know what do I have to do to fix that error, I've tried reimporting all assets, regenerating project files, moving the script on which I need to access the namespace to another and erasing the Library folder, but hasn't worked. I hope someone knows a solution!
Thanks in advance.

Xamarin Forms Init crashes after adding FormsMaterial Init

I'm attempting to add Xamarin.Forms Material Visual to my app. I'm following the instructions here and after I add the Forms Material init, I get a crash in the Forms init. Here's the code...
public override bool FinishedLaunching(UIApplication app, NSDictionary options)
{
global::Xamarin.Forms.Forms.Init();
global::Xamarin.Forms.FormsMaterial.Init();
LoadApplication(new App());
return base.FinishedLaunching(app, options);
}
Without global::Xamarin.Forms.FormsMaterial.Init();, everything runs fine. When I add it, global::Xamarin.Forms.Forms.Init(); crashes with an exception "System.Reflection.CustomAttributeFormatException has been thrown" and "Could not find a property with name Priority". How does a line added after another cause an exception on the previous line? Anyone know what's going on?
Here's the stacktrace:
System.Reflection.CustomAttributeFormatException: Could not find a property with name Priority
at at (wrapper managed-to-native) System.MonoCustomAttrs.GetCustomAttributesInternal(System.Reflection.ICustomAttributeProvider,System.Type,bool)
at System.MonoCustomAttrs.GetCustomAttributesBase (System.Reflection.ICustomAttributeProvider obj, System.Type attributeType, System.Boolean inheritedOnly) [0x00013] in /Users/builder/jenkins/workspace/xamarin-macios/xamarin-macios/external/mono/mcs/class/corlib/System/MonoCustomAttrs.cs:128
at System.MonoCustomAttrs.GetCustomAttributes (System.Reflection.ICustomAttributeProvider obj, System.Type attributeType, System.Boolean inherit) [0x00037] in /Users/builder/jenkins/workspace/xamarin-macios/xamarin-macios/external/mono/mcs/class/corlib/System/MonoCustomAttrs.cs:163
at System.Reflection.RuntimeAssembly.GetCustomAttributes (System.Type attributeType, System.Boolean inherit) [0x00000] in /Users/builder/jenkins/workspace/xamarin-macios/xamarin-macios/external/mono/mcs/class/corlib/System.Reflection/RuntimeAssembly.cs:520
at Xamarin.Forms.Internals.Registrar.RegisterAll (System.Type[] attrTypes, Xamarin.Forms.ActivationFlags flags) [0x000a1] in D:\a\1\s\Xamarin.Forms.Core\Registrar.cs:331
at Xamarin.Forms.Internals.Registrar.RegisterAll (System.Type[] attrTypes) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\Registrar.cs:298
at Xamarin.Forms.Forms.Init () [0x0009d] in <f0489d3941b24a20a5b9223b572ec7c0>:0
at OSSM.iOS.AppDelegate.FinishedLaunching (UIKit.UIApplication app, Foundation.NSDictionary options) [0x00001] in /Users/rob5408/Work/OSSM/OSSM.iOS/AppDelegate.cs:25
at at (wrapper managed-to-native) UIKit.UIApplication.UIApplicationMain(int,string[],intptr,intptr)
at UIKit.UIApplication.Main (System.String[] args, System.IntPtr principal, System.IntPtr delegate) [0x00005] in /Library/Frameworks/Xamarin.iOS.framework/Versions/13.6.0.12/src/Xamarin.iOS/UIKit/UIApplication.cs:86
at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x0000e] in /Library/Frameworks/Xamarin.iOS.framework/Versions/13.6.0.12/src/Xamarin.iOS/UIKit/UIApplication.cs:65
at OSSM.iOS.Application.Main (System.String[] args) [0x00001] in /Users/rob5408/Work/OSSM/OSSM.iOS/Main.cs:18

MvvmCross Failed to construct and initialize ViewModel for type

I am trying to create a mobile application using MvvmCross v.4.4.0.
Application works correct. But if collapse application and lock the phone, and then unlock and press "Overview" android button application crash (only on the Xiaomi phone).
I think android kills activity and then unsuccessfully trying to recreate it.
Could you, please explain me, what I do wrong? How to fix it?
Stacktrace:
Android.Runtime.RaiseThrowableEventArgs MvvmCross.Platform.Exceptions.MvxException: Failed to construct and initialize ViewModel for type Test.Core.ViewModels.MainMenuViewModel from locator MvxDefaultViewModelLocator - check InnerException for more information ---> MvvmCross.Platform.Exceptions.MvxException: Problem creating viewModel of type MainMenuViewModel ---> MvvmCross.Platform.Exceptions.MvxIoCResolveException: Failed to construct MainMenuViewModel ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> Java.Lang.LinkageError: no static method "Landroid/text/Html;.fromHtml(Ljava/lang/String;I)Landroid/text/Spanned;" at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw ()
[0x0000c] in <89dd20b27a0b473a848558c84f1f086a>:0 at Java.Interop.JniEnvironment+StaticMethods.GetStaticMethodID (Java.Interop.JniObjectReference type, System.String name, System.String signature)
[0x00068] in :0 at Java.Interop.JniType.GetStaticMethod (System.String name, System.String signature)
[0x0000d] in :0 at Java.Interop.JniPeerMembers+JniStaticMethods.GetMethodInfo (System.String encodedMember)
[0x0003c] in :0 at Java.Interop.JniPeerMembers+JniStaticMethods.InvokeObjectMethod (System.String encodedMember, Java.Interop.JniArgumentValue* parameters)
[0x00001] in :0 at Android.Text.Html.FromHtml (System.String source, Android.Text.FromHtmlOptions flags)
[0x0003b] in :0 at Test.Droid.Providers.DialogProvider.ShowSnackbar () [0x00017] in <0fa1f44ee2f748fe816e790571c2153b>:0 at Test.Core.ViewModels.BaseViewModel..ctor ()
[0x0006d] in :0 at Test.Core.ViewModels.MainMenuViewModel..ctor (Test.Core.Managers.IExceptionManager exceptionManager)
[0x0000b] in :0 at (wrapper managed-to-native) System.Reflection.MonoCMethod:InternalInvoke (System.Reflection.MonoCMethod,object,object[],System.Exception&) at System.Reflection.MonoCMethod.InternalInvoke (System.Object obj, System.Object[] parameters)
[0x00002] in <89dd20b27a0b473a848558c84f1f086a>:0 --- End of inner exception stack trace --- at System.Reflection.MonoCMethod.InternalInvoke (System.Object obj, System.Object[] parameters)
[0x0001c] in <89dd20b27a0b473a848558c84f1f086a>:0 at System.Reflection.MonoCMethod.DoInvoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture)
[0x00089] in <89dd20b27a0b473a848558c84f1f086a>:0 at System.Reflection.MonoCMethod.Invoke (System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture)
[0x00000] in <89dd20b27a0b473a848558c84f1f086a>:0 at System.Reflection.ConstructorInfo.Invoke (System.Object[] parameters)
[0x00000] in <89dd20b27a0b473a848558c84f1f086a>:0 at MvvmCross.Platform.IoC.MvxSimpleIoCContainer.IoCConstruct (System.Type type)
[0x0003a] in <4ddde23419c5494288c799fcdbb0f189>:0 --- End of inner exception stack trace --- at MvvmCross.Platform.IoC.MvxSimpleIoCContainer.IoCConstruct (System.Type type)
[0x0005b] in <4ddde23419c5494288c799fcdbb0f189>:0 at MvvmCross.Platform.Mvx.IocConstruct (System.Type t)
[0x00005] in <4ddde23419c5494288c799fcdbb0f189>:0 at MvvmCross.Core.ViewModels.MvxDefaultViewModelLocator.Load (System.Type viewModelType, MvvmCross.Core.ViewModels.IMvxBundle parameterValues, MvvmCross.Core.ViewModels.IMvxBundle savedState)
[0x00000] in <69bce0378e8e413982d3b552d7e387a8>:0 --- End of inner exception stack trace --- at MvvmCross.Core.ViewModels.MvxDefaultViewModelLocator.Load (System.Type viewModelType, MvvmCross.Core.ViewModels.IMvxBundle parameterValues, MvvmCross.Core.ViewModels.IMvxBundle savedState)
[0x00027] in <69bce0378e8e413982d3b552d7e387a8>:0 at MvvmCross.Core.ViewModels.MvxViewModelLoader.LoadViewModel (MvvmCross.Core.ViewModels.MvxViewModelRequest request, MvvmCross.Core.ViewModels.IMvxBundle savedState, MvvmCross.Core.ViewModels.IMvxViewModelLocator viewModelLocator)
[0x00015] in <69bce0378e8e413982d3b552d7e387a8>:0 --- End of inner exception stack trace --- at MvvmCross.Core.ViewModels.MvxViewModelLoader.LoadViewModel (MvvmCross.Core.ViewModels.MvxViewModelRequest request, MvvmCross.Core.ViewModels.IMvxBundle savedState, MvvmCross.Core.ViewModels.IMvxViewModelLocator viewModelLocator)
[0x00046] in <69bce0378e8e413982d3b552d7e387a8>:0 at MvvmCross.Core.ViewModels.MvxViewModelLoader.LoadViewModel (MvvmCross.Core.ViewModels.MvxViewModelRequest request, MvvmCross.Core.ViewModels.IMvxBundle savedState)
[0x00020] in <69bce0378e8e413982d3b552d7e387a8>:0 at MvvmCross.Droid.Views.MvxAndroidViewsContainer.ViewModelFromRequest (MvvmCross.Core.ViewModels.MvxViewModelRequest viewModelRequest, MvvmCross.Core.ViewModels.IMvxBundle savedState)
[0x00005] in :0 at MvvmCross.Droid.Views.MvxAndroidViewsContainer.CreateViewModelFromIntent (Android.Content.Intent intent, MvvmCross.Core.ViewModels.IMvxBundle savedState)
[0x00027] in :0 at MvvmCross.Droid.Views.MvxAndroidViewsContainer.Load (Android.Content.Intent intent, MvvmCross.Core.ViewModels.IMvxBundle savedState, System.Type viewModelTypeHint)
[0x00089] in :0 at MvvmCross.Droid.Views.MvxActivityViewExtensions.LoadViewModel (MvvmCross.Droid.Views.IMvxAndroidView androidView, MvvmCross.Core.ViewModels.IMvxBundle savedState)
[0x0006a] in :0 at MvvmCross.Droid.Views.MvxActivityViewExtensions+<>c__DisplayClass1_0.b__1 ()
[0x0000a] in :0 at MvvmCross.Core.Views.MvxViewExtensionMethods.OnViewCreate (MvvmCross.Core.Views.IMvxView view, System.Func`1[TResult] viewModelLoader)
[0x00012] in <69bce0378e8e413982d3b552d7e387a8>:0 at MvvmCross.Droid.Views.MvxActivityViewExtensions.OnViewCreate (MvvmCross.Droid.Views.IMvxAndroidView androidView, Android.OS.Bundle bundle)
[0x00062] in :0 at MvvmCross.Droid.Views.MvxActivityAdapter.EventSourceOnCreateCalled (System.Object sender, MvvmCross.Platform.Core.MvxValueEventArgs`1[T] eventArgs)
[0x0000c] in :0 at (wrapper delegate-invoke) System.EventHandler`1[MvvmCross.Platform.Core.MvxValueEventArgs`1[Android.OS.Bundle]]:invoke_void_object_TEventArgs (object,MvvmCross.Platform.Core.MvxValueEventArgs`1) at MvvmCross.Platform.Core.MvxDelegateExtensionMethods.Raise[T] (System.EventHandler`1[TEventArgs] eventHandler, System.Object sender, T value)
[0x0000b] in <4ddde23419c5494288c799fcdbb0f189>:0 at MvvmCross.Platform.Droid.Views.MvxEventSourceActivity.OnCreate (Android.OS.Bundle bundle)
[0x00014] in <4230cf00b647458f9b3e211590e6cc9d>:0 at Test.Droid.Views.BaseView`1[TViewModel].OnCreate (Android.OS.Bundle bundle)
[0x00000] in <0fa1f44ee2f748fe816e790571c2153b>:0 at Test.Droid.Views.MainMenuView.OnCreate (Android.OS.Bundle bundle)
[0x00000] in <0fa1f44ee2f748fe816e790571c2153b>:0 at Android.App.Activity.n_OnCreate_Landroid_os_Bundle_ (System.IntPtr jnienv, System.IntPtr native__this, System.IntPtr native_savedInstanceState)
[0x00011] in :0 at (wrapper dynamic-method) System.Object:e6d6ef29-3746-4c8e-b037-c64f6dfe49f0 (intptr,intptr,intptr)
This is a linking issue. You have some kind of DialogProvider, which uses the Android.Text.Html.FromHtml method, which seems to be stripped out.
You can add expressions to LinkerPleaseInclude.cs to prevent the linker from removing code or you can add [Preserve(AllMembers = true)] attribute on your DialogProvider class.

Content view content update app crashes in xamarin iOS

I create the xamarin form project and update the content view content multiple time.
Its correctly update for android. But it not work for iOS
I have update the Contentview content when click the button like that
contentView.content = mVview;
Please find the stack trace
wrapper managed-to-native
at (wrapper managed-to-native) UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intptr)
at UIKit.UIApplication.Main (System.String[] args, System.IntPtr principal, System.IntPtr delegate) [0x00005] in /Users/builder/data/lanes/3969/7beaef43/source/xamarin-macios/src/UIKit/UIApplication.cs:79
at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName,`/lanes/3969/7beaef43/source/xamarin-macios/src/UIKi1
when i put try catch, i got this stack trace
at Xamarin.Forms.Platform.iOS.EditorRenderer.Dispose (System.Boolean disposing) [0x00003] in C:\BuildAgent2\work\ca3766cfc22354a1\Xamarin.Forms.Platform.iOS\Renderers\EditorRenderer.cs:28
at Foundation.NSObject.Dispose () [0x00000] in /Users/builder/data/lanes/3969/7beaef43/source/xamarin-macios/src/Foundation/NSObject2.cs:133
at Xamarin.Forms.Platform.iOS.ListViewRenderer.Dispose (System.Boolean disposing) [0x001c4] in C:\BuildAgent2\work\ca3766cfc22354a1\Xamarin.Forms.Platform.iOS\Renderers\ListViewRenderer.cs:153
at Foundation.NSObject.Dispose () [0x00000] in /Users/builder/data/lanes/3969/7beaef43/source/xamarin-macios/src/Foundation/NSObject2.cs:133
at Xamarin.Forms.Platform.iOS.Platform.DisposeModelAndChildrenRenderers (Xamarin.Forms.Element view) [0x00038] in C:\BuildAgent2\work\ca3766cfc22354a1\Xamarin.Forms.Platform.iOS\Platform.cs:322
at Xamarin.Forms.Platform.iOS.Platform.HandleChildRemoved (System.Object sender, Xamarin.Forms.ElementEventArgs e) [0x00007] in C:\BuildAgent2\work\ca3766cfc22354a1\Xamarin.Forms.Platform.iOS\Platform.cs:433
at Xamarin.Forms.Element.OnDescendantRemoved (Xamarin.Forms.Element child) [0x00008] in C:\BuildAgent2\work\ca3766cfc22354a1\Xamarin.Forms.Core\Element.cs:600
at Xamarin.Forms.Element.OnDescendantRemoved (Xamarin.Forms.Element child) [0x00022] in C:\BuildAgent2\work\ca3766cfc22354a1\Xamarin.Forms.Core\Element.cs:603
at Xamarin.Forms.Element.OnDescendantRemoved (Xamarin.Forms.Element child) [0x00022] in C:\BuildAgent2\work\ca3766cfc22354a1\Xamarin.Forms.Core\Element.cs:603
at Xamarin.Forms.Element.OnChildRemoved (Xamarin.Forms.Element child) [0x00021] in C:\BuildAgent2\work\ca3766cfc22354a1\Xamarin.Forms.Core\Element.cs:367
at Xamarin.Forms.VisualElement.OnChildRemoved (Xamarin.Forms.Element child) [0x00000] in C:\BuildAgent2\work\ca3766cfc22354a1\Xamarin.Forms.Core\VisualElement.cs:578
at Xamarin.Forms.Layout.OnInternalRemoved (Xamarin.Forms.View view) [0x00012] in C:\BuildAgent2\work\ca3766cfc22354a1\Xamarin.Forms.Core\Layout.cs:413
at Xamarin.Forms.Layout.InternalChildrenOnCollectionChanged (System.Object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) [0x0002f] in C:\BuildAgent2\work\ca3766cfc22354a1\Xamarin.Forms.Core\Layout.cs:377
at System.Collections.ObjectModel.ObservableCollection`1[T].OnCollectionChanged (System.Collections.Specialized.NotifyCollectionChangedEventArgs e) [0x00012] in /Users/builder/data/lanes/3969/7beaef43/source/xamarin-macios/_ios-build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/class/referencesource/System/compmod/system/collections/objectmodel/observablecollection.cs:288
at System.Collections.ObjectModel.ObservableCollection`1[T].OnCollectionChanged (System.Collections.Specialized.NotifyCollectionChangedAction action, System.Object item, System.Int32 index) [0x00000] in /Users/builder/data/lanes/3969/7beaef43/source/xamarin-macios/_ios-build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/class/referencesource/System/compmod/system/collections/objectmodel/observablecollection.cs:351
at System.Collections.ObjectModel.ObservableCollection`1[T].RemoveItem (System.Int32 index) [0x0002b] in /Users/builder/data/lanes/3969/7beaef43/source/xamarin-macios/_ios-build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/class/referencesource/System/compmod/system/collections/objectmodel/observablecollection.cs:205
at System.Collections.ObjectModel.Collection`1[T].Remove (T item) [0x0002d] in /Users/builder/data/lanes/3969/7beaef43/source/xamarin-macios/_ios-build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/class/referencesource/mscorlib/system/collections/objectmodel/collection.cs:113
at Xamarin.Forms.TemplateUtilities.OnContentChanged (Xamarin.Forms.BindableObject bindable, System.Object oldValue, System.Object newValue) [0x0001a] in C:\BuildAgent2\work\ca3766cfc22354a1\Xamarin.Forms.Core\TemplateUtilities.cs:63
at Xamarin.Forms.BindableObject.SetValueActual (Xamarin.Forms.BindableProperty property, Xamarin.Forms.BindableObject+BindablePropertyContext context, System.Object value, System.Boolean currentlyApplying, Xamarin.Forms.BindableObject+SetValueFlags attributes, System.Boolean silent) [0x00108] in C:\BuildAgent2\work\ca3766cfc22354a1\Xamarin.Forms.Core\BindableObject.cs:584
at Xamarin.Forms.BindableObject.SetValueCore (Xamarin.Forms.BindableProperty property, System.Object value, Xamarin.Forms.BindableObject+SetValueFlags attributes, Xamarin.Forms.BindableObject+SetValuePrivateFlags privateAttributes) [0x0014b] in C:\BuildAgent2\work\ca3766cfc22354a1\Xamarin.Forms.Core\BindableObject.cs:378
at Xamarin.Forms.BindableObject.SetValue (Xamarin.Forms.BindableProperty property, System.Object value, System.Boolean fromStyle, System.Boolean checkAccess) [0x0005f] in C:\BuildAgent2\work\ca3766cfc22354a1\Xamarin.Forms.Core\BindableObject.cs:531
at Xamarin.Forms.BindableObject.SetValue (Xamarin.Forms.BindableProperty property, System.Object value) [0x00000] in C:\BuildAgent2\work\ca3766cfc22354a1\Xamarin.Forms.Core\BindableObject.cs:83
at Xamarin.Forms.ContentView.set_Content (Xamarin.Forms.View value) [0x00000] in C:\BuildAgent2\work\ca3766cfc22354a1\Xamarin.Forms.Core\ContentView.cs:11
at EgnatiumFull.Pages.QuestionAnswerPage.UpdateTheQuestionLayout () [0x00144] in /Volumes/MS/prjects/Egnatium/EgnatiumFinal/EgnatiumFinal/EgnatiumFinal/Pages/QuestionAnswerPage.cs:539
at EgnatiumFull.Pages.QuestionAnswerPage+<OnAppearing>c__async1.MoveNext () [0x0007e] in /Volumes/MS/prjects/Egnatium/EgnatiumFinal/EgnatiumFinal/EgnatiumFinal/Pages/QuestionAnswerPage.cs:383
--- End of stack trace from previous location where exception was thrown ---
at (wrapper managed-to-native) UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intptr)
at UIKit.UIApplication.Main (System.String[] args, System.IntPtr principal, System.IntPtr delegate) [0x00005] in /Users/builder/data/lanes/3969/7beaef43/source/xamarin-macios/src/UIKit/UIApplication.cs:79
at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x00038] in /Users/builder/data/lanes/3969/7beaef43/source/xamarin-macios/src/UIKit/UIApplication.cs:63
at EgnatiumFinal.iOS.Application.Main (System.String[] args) [0x00008] in /Users/saifamily/Documents/14_2_17/EgnatiumFinal/EgnatiumFinal/EgnatiumFinal.iOS/Main.cs:17 xa
Finally I found the solution in my own way, i think i don't know is this correct way but in my case it work perfectly
I rendererd the list view for ios and overide the methods dispose with try/catch statement
protected override void Dispose()
{
try{
base.Dispose();
}
Catch(Exception ex)
{
return;
}
}

Google API-change, results in a MONO error: Invalid IL code in System.Net.Http.HttpClientHandler:.ctor (): method body is empty

I had to change the auth system behind the Google Analytics API following the old auth system becoming defunct. As a result of a SO post, my auth file went from:
protected override void Load(ContainerBuilder builder)
{
builder.Register(c =>
{
var service = new AnalyticsService("mrfreeman.com");
service.setUserCredentials("robot#mrfreeman.com", "jellyfish");
return service;
});
builder.RegisterType<AnalyticsNewsletterTrackingSource>().As<INewsletterTrackingSource>();
builder.RegisterType<AnalyticsSearchTrackingSource>().As<ISearchTrackingSource>();
builder.RegisterType<AnalyticsEmailLinkTracker>().As<IEmailLinkTracker>();
}
To:
private const string ServiceAccountEmail = "blabla#developer.gserviceaccount.com";
private static readonly string KeyPath = System.IO.Path.Combine(AppDomain.CurrentDomain.SetupInformation.PrivateBinPath ?? AppDomain.CurrentDomain.BaseDirectory, "Key.p12");
private static readonly X509Certificate2 Certificate = new X509Certificate2(KeyPath, "notasecret", X509KeyStorageFlags.Exportable);
private readonly ServiceAccountCredential _credential = new ServiceAccountCredential(
new ServiceAccountCredential.Initializer(ServiceAccountEmail)
{
Scopes = new[] { "https://www.googleapis.com/auth/analytics" }
}.FromCertificate(Certificate));
protected override void Load(ContainerBuilder builder)
{
builder.Register(c =>
{
_credential.RequestAccessTokenAsync(System.Threading.CancellationToken.None).Wait();
var service = new AnalyticsService("mrfreeman.com");
var requestFactory = new GDataRequestFactory("shazbot2.0");
requestFactory.CustomHeaders.Add(string.Format("Authorization: Bearer {0}", _credential.Token.AccessToken));
service.RequestFactory = requestFactory;
return service;
});
builder.RegisterType<AnalyticsNewsletterTrackingSource>().As<INewsletterTrackingSource>();
builder.RegisterType<AnalyticsSearchTrackingSource>().As<ISearchTrackingSource>();
builder.RegisterType<AnalyticsEmailLinkTracker>().As<IEmailLinkTracker>();
}
Doing all the necessary boiler plate of copying the generated developer email address and P12 key into the project.
The problem is this: It works on Windows but throws problems with the services running on mono and are dependant on the Analytics module. Currently using 4.0.2 version of Mono.
What I've tried:
Using old and new versions of mono - 3.10 and 4.2.0 pre-release to run the service (which is itself built by Visual Studio) and check if exception is produced.
Import System.Net.Http and copy to local (currently not referenced in service) - still produces same exception
At this stage I'm cornered into learning the new Google Analytics API and re-writing everything from scratch as I tried to use the old API but update the Auth API with little luck, but feel this a blunt-instrument type solution.
The stack trace is the same on any version and is:
FATAL Unhandled exception occurred.
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.InvalidProgramException: Invalid IL code in System.Net.Http.HttpClientHandler:.ctor (): method body is empty.
at Google.Apis.Http.HttpClientFactory.CreateHandler (Google.Apis.Http.CreateHttpClientArgs args) <0x40280100 + 0x0003b> in <filename unknown>:0
at Google.Apis.Http.HttpClientFactory.CreateHttpClient (Google.Apis.Http.CreateHttpClientArgs args) <0x4027ff90 + 0x0002d> in <filename unknown>:0
at Google.Apis.Auth.OAuth2.ServiceAccountCredential..ctor (Google.Apis.Auth.OAuth2.Initializer initializer) <0x4027f6d0 + 0x00438> in <filename unknown>:0
at jellyfish.Analytics.AnalyticsModule..ctor () <0x4027ed00 + 0x00103> in <filename unknown>:0
at (wrapper managed-to-native) System.Reflection.MonoCMethod:InternalInvoke (System.Reflection.MonoCMethod,object,object[],System.Exception&)
at System.Reflection.MonoCMethod.InternalInvoke (System.Object obj, System.Object[] parameters) <0x7f8257b94780 + 0x0003f> in <filename unknown>:0
--- End of inner exception stack trace ---
at System.Reflection.MonoCMethod.InternalInvoke (System.Object obj, System.Object[] parameters) <0x7f8257b94780 + 0x00079> in <filename unknown>:0
at System.RuntimeType.CreateInstanceMono (Boolean nonPublic) <0x7f82579c1ec0 + 0x00116> in <filename unknown>:0
at System.RuntimeType.CreateInstanceSlow (Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, System.Threading.StackCrawlMark& stackMark) <0x7f82579c1e70 + 0x00049> in <filename unknown>:0
at System.RuntimeType.CreateInstanceDefaultCtor (Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, System.Threading.StackCrawlMark& stackMark) <0x7f82579c1c10 + 0x0005c> in <filename unknown>:0
at System.Activator.CreateInstance[T] () <0x7f82578dfb70 + 0x0008a> in <filename unknown>:0
at Autofac.ModuleRegistrationExtensions.RegisterModule[TModule] (IModuleRegistrar registrar) <0x40273470 + 0x0004f> in <filename unknown>:0
at Autofac.ModuleRegistrationExtensions.RegisterModule[TModule] (Autofac.ContainerBuilder builder) <0x40273330 + 0x0006b> in <filename unknown>:0
at jellyfish.Cron.Program.BuildContainer (ILog log) <0x402730e0 + 0x0005f> in <filename unknown>:0
at jellyfish.Cron.Program.ExecuteJob (System.Type jobType) <0x4021abe0 + 0x0007b> in <filename unknown>:0
Unknown errno: Protocol error
Unhandled Exception:
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.InvalidProgramException: Invalid IL code in System.Net.Http.HttpClientHandler:.ctor (): method body is empty.
at Google.Apis.Http.HttpClientFactory.CreateHandler (Google.Apis.Http.CreateHttpClientArgs args) <0x40280100 + 0x0003b> in <filename unknown>:0
at Google.Apis.Http.HttpClientFactory.CreateHttpClient (Google.Apis.Http.CreateHttpClientArgs args) <0x4027ff90 + 0x0002d> in <filename unknown>:0
at Google.Apis.Auth.OAuth2.ServiceAccountCredential..ctor (Google.Apis.Auth.OAuth2.Initializer initializer) <0x4027f6d0 + 0x00438> in <filename unknown>:0
at jellyfish.Analytics.AnalyticsModule..ctor () <0x4027ed00 + 0x00103> in <filename unknown>:0
at (wrapper managed-to-native) System.Reflection.MonoCMethod:InternalInvoke (System.Reflection.MonoCMethod,object,object[],System.Exception&)
at System.Reflection.MonoCMethod.InternalInvoke (System.Object obj, System.Object[] parameters) <0x7f8257b94780 + 0x0003f> in <filename unknown>:0
--- End of inner exception stack trace ---
at System.Reflection.MonoCMethod.InternalInvoke (System.Object obj, System.Object[] parameters) <0x7f8257b94780 + 0x00079> in <filename unknown>:0
at System.RuntimeType.CreateInstanceMono (Boolean nonPublic) <0x7f82579c1ec0 + 0x00116> in <filename unknown>:0
at System.RuntimeType.CreateInstanceSlow (Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, System.Threading.StackCrawlMark& stackMark) <0x7f82579c1e70 + 0x00049> in <filename unknown>:0
at System.RuntimeType.CreateInstanceDefaultCtor (Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, System.Threading.StackCrawlMark& stackMark) <0x7f82579c1c10 + 0x0005c> in <filename unknown>:0
at System.Activator.CreateInstance[T] () <0x7f82578dfb70 + 0x0008a> in <filename unknown>:0
at Autofac.ModuleRegistrationExtensions.RegisterModule[TModule] (IModuleRegistrar registrar) <0x40273470 + 0x0004f> in <filename unknown>:0
at Autofac.ModuleRegistrationExtensions.RegisterModule[TModule] (Autofac.ContainerBuilder builder) <0x40273330 + 0x0006b> in <filename unknown>:0
at jellyfish.Cron.Program.BuildContainer (ILog log) <0x402730e0 + 0x0005f> in <filename unknown>:0
at jellyfish.Cron.Program.ExecuteJob (System.Type jobType) <0x4021abe0 + 0x0007b> in <filename unknown>:0
[ERROR] FATAL UNHANDLED EXCEPTION: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.InvalidProgramException: Invalid IL code in System.Net.Http.HttpClientHandler:.ctor (): method body is empty.
at Google.Apis.Http.HttpClientFactory.CreateHandler (Google.Apis.Http.CreateHttpClientArgs args) <0x40280100 + 0x0003b> in <filename unknown>:0
at Google.Apis.Http.HttpClientFactory.CreateHttpClient (Google.Apis.Http.CreateHttpClientArgs args) <0x4027ff90 + 0x0002d> in <filename unknown>:0
at Google.Apis.Auth.OAuth2.ServiceAccountCredential..ctor (Google.Apis.Auth.OAuth2.Initializer initializer) <0x4027f6d0 + 0x00438> in <filename unknown>:0
at jellyfish.Analytics.AnalyticsModule..ctor () <0x4027ed00 + 0x00103> in <filename unknown>:0
at (wrapper managed-to-native) System.Reflection.MonoCMethod:InternalInvoke (System.Reflection.MonoCMethod,object,object[],System.Exception&)
at System.Reflection.MonoCMethod.InternalInvoke (System.Object obj, System.Object[] parameters) <0x7f8257b94780 + 0x0003f> in <filename unknown>:0
--- End of inner exception stack trace ---
at System.Reflection.MonoCMethod.InternalInvoke (System.Object obj, System.Object[] parameters) <0x7f8257b94780 + 0x00079> in <filename unknown>:0
at System.RuntimeType.CreateInstanceMono (Boolean nonPublic) <0x7f82579c1ec0 + 0x00116> in <filename unknown>:0
at System.RuntimeType.CreateInstanceSlow (Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, System.Threading.StackCrawlMark& stackMark) <0x7f82579c1e70 + 0x00049> in <filename unknown>:0
at System.RuntimeType.CreateInstanceDefaultCtor (Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, System.Threading.StackCrawlMark& stackMark) <0x7f82579c1c10 + 0x0005c> in <filename unknown>:0
at System.Activator.CreateInstance[T] () <0x7f82578dfb70 + 0x0008a> in <filename unknown>:0
at Autofac.ModuleRegistrationExtensions.RegisterModule[TModule] (IModuleRegistrar registrar) <0x40273470 + 0x0004f> in <filename unknown>:0
at Autofac.ModuleRegistrationExtensions.RegisterModule[TModule] (Autofac.ContainerBuilder builder) <0x40273330 + 0x0006b> in <filename unknown>:0
at jellyfish.Cron.Program.BuildContainer (ILog log) <0x402730e0 + 0x0005f> in <filename unknown>:0
at jellyfish.Cron.Program.ExecuteJob (System.Type jobType) <0x4021abe0 + 0x0007b> in <filename unknown>:0
I was having similar issue, So thought try removing and adding the following DLLS to fix it.
Removed System.net.http, OkHttp, ModernClient. Found the issue was with ModernClientHttp and OkHttp dlls added under references.
I have removed OkHttp and ModernClientHttp and added the ModernClientHttp via Nuget and that works for me.
Give a try if that helps.

Categories