简体   繁体   English

在 iOS 和 ArcGIS Runtime 上使用热重启 Xamarin Forms 应用程序崩溃

[英]App Crash using Hot Restart Xamarin Forms on iOS and the ArcGIS Runtime

Want to check if anyone has had success with the ArcGIS Runtime Xamarin Forms on iOS using Visual Studio hot restart?想检查是否有人使用 Visual Studio 热重启在 ArcGIS Runtime Xamarin Forms on iOS 上取得成功?

I created a new Xamarin Forms app for iOS in Visual Studio and added the following code in AppDelegate.cs我在 Visual Studio 中为 iOS 创建了一个新的 Xamarin Forms 应用程序,并在 AppDelegate.cs 中添加了以下代码

public override bool FinishedLaunching(UIApplication app, NSDictionary options)
{
  global::Xamarin.Forms.Forms.Init();
  LoadApplication(new App());
  Esri.ArcGISRuntime.ArcGISRuntimeEnvironment.Initialize();

  return base.FinishedLaunching(app, options);
}

The app launches and runs fine without the Initialize method on my iPhone.该应用程序在我的 iPhone 上没有 Initialize 方法的情况下启动并运行良好。 It feels like I'm missing a dependency.感觉就像我缺少依赖项。

This is the error I get with the Initialize method:这是我使用 Initialize 方法得到的错误:

[0:] An error occurred: 'CoreRT_ArcGISRuntimeEnvironment_setInstallDirectory assembly:<unknown assembly> type:<unknown type> member:(null)'. Callstack: '  at (wrapper managed-to-native) RuntimeCoreNet.GeneratedWrappers.CoreArcGISRuntimeEnvironment.CoreRT_ArcGISRuntimeEnvironment_setInstallDirectory(byte[],intptr&)
  at RuntimeCoreNet.GeneratedWrappers.CoreArcGISRuntimeEnvironment.SetInstallDirectory (System.String installPath) <0x138775060 + 0x00010> in <2a33546a5b934b588629d4e33895c554>:0 
  at Esri.ArcGISRuntime.ArcGISRuntimeEnvironment.InitNative () <0x1387748c8 + 0x00004> in <2a33546a5b934b588629d4e33895c554>:0 
  at Esri.ArcGISRuntime.ArcGISRuntimeEnvironment.Initialize () <0x138774538 + 0x00042> in <2a33546a5b934b588629d4e33895c554>:0 
  at App1.iOS.AppDelegate.FinishedLaunching (UIKit.UIApplication app, Foundation.NSDictionary options) [0x00013] in C:\Users\Chris\Documents\OnScene Xplorer\App1\App1.iOS\AppDelegate.cs:33 
  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/azdo/_work/1/s/xamarin-macios/src/UIKit/UIApplication.cs:86 
  at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x0000e] in /Users/builder/azdo/_work/1/s/xamarin-macios/src/UIKit/UIApplication.cs:65 
  at App1.iOS.Application.Main (System.String[] args) [0x00001] in C:\Users\Chris\Documents\OnScene Xplorer\App1\App1.iOS\Main.cs:17 
  at (wrapper managed-to-native) System.Reflection.RuntimeMethodInfo.InternalInvoke(System.Reflection.RuntimeMethodInfo,object,object[],System.Exception&)
  at System.Reflection.RuntimeMethodInfo.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x0006a] in /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/mcs/class/corlib/System.Reflection/RuntimeMethodInfo.cs:395 '

Looks like its attempting to make a call into a native method using DllImport per Reflector.看起来它试图使用每个 Reflector 的 DllImport 调用本机方法。

[DllImport("__Internal")]
private static extern void CoreRT_ArcGISRuntimeEnvironment_setInstallDirectory([In, Out, MarshalAs(UnmanagedType.LPArray)] byte[] installPath, out IntPtr outErrorHandle);

I also tried the sample app from ArcGIS and it also fails the same way once I enable hot restart on it.我还尝试了 ArcGIS 中的示例应用程序,一旦启用热重启,它也会以同样的方式失败。

More info...更多信息...

The exception being thrown is EntryPointNotFoundException which means that the native call can't be resolved.抛出的异常是 EntryPointNotFoundException,这意味着无法解析本机调用。

I did some sleuthing on my iPhone and found that runtimecore.dll and runtimecor.net.dll are not being copied to the deployment folder.我在我的 iPhone 上做了一些调查,发现 runtimecore.dll 和 runtimecor.net.dll 没有被复制到部署文件夹。 They also do not appear in the bin/Debug folder during build.它们在构建期间也不会出现在 bin/Debug 文件夹中。 I believe those 2 dlls are the target of the native calls in Esri.ArcGISRuntime.dll.我相信这 2 个 dll 是 Esri.ArcGISRuntime.dll 中本地调用的目标。

So I think I have to figure out how to convince Visual Studio to include those in the iOS build.所以我想我必须弄清楚如何说服 Visual Studio 将它们包含在 iOS 构建中。 I do see them being included in my UWP build.我确实看到它们包含在我的 UWP 构建中。

Any ideas for how to fix this?关于如何解决这个问题的任何想法?

A while back Microsoft broke support for native.frameworks in hot restart, and the ArcGIS Runtime relies on these, so unfortunately you'll need a Mac to deploy to a device.不久前,Microsoft 在热重启中中断了对 native.frameworks 的支持,而 ArcGIS Runtime 依赖于这些,因此不幸的是,您需要 Mac 才能部署到设备。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM