在 iOS 和 ArcGIS Runtime 上使用热重启 Xamarin Forms 的应用程序崩溃
App Crash using Hot Restart Xamarin Forms on iOS and the ArcGIS Runtime
想要检查是否有人使用 Visual Studio 热重启在 iOS 上成功使用 ArcGIS Runtime Xamarin Forms?
我在 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);
}
我的 iPhone 上没有 Initialize 方法,应用程序启动并运行良好。感觉少了一个依赖
这是我使用 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 '
看起来它正在尝试使用 DllImport per Reflector 调用本机方法。
[DllImport("__Internal")]
private static extern void CoreRT_ArcGISRuntimeEnvironment_setInstallDirectory([In, Out, MarshalAs(UnmanagedType.LPArray)] byte[] installPath, out IntPtr outErrorHandle);
我还尝试了 ArcGIS 中的示例应用程序,但在启用热重启后它也以同样的方式失败。
更多信息...
抛出的异常为EntryPointNotFoundException,表示无法解析原生调用。
我对我的 iPhone 做了一些调查,发现 runtimecore.dll 和 runtimecorenet.dll 没有被复制到部署文件夹。它们在构建期间也不会出现在 bin/Debug 文件夹中。我相信这 2 个 dll 是 Esri.ArcGISRuntime.dll.
中本机调用的目标
所以我想我必须弄清楚如何说服 Visual Studio 将它们包含在 iOS 构建中。我确实看到它们包含在我的 UWP 构建中。
有什么解决办法吗?
不久前,Microsoft 在热重启中中断了对本机 .frameworks 的支持,而 ArcGIS Runtime 依赖于这些,因此不幸的是,您需要 Mac 才能部署到设备。
想要检查是否有人使用 Visual Studio 热重启在 iOS 上成功使用 ArcGIS Runtime Xamarin Forms?
我在 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);
}
我的 iPhone 上没有 Initialize 方法,应用程序启动并运行良好。感觉少了一个依赖
这是我使用 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 '
看起来它正在尝试使用 DllImport per Reflector 调用本机方法。
[DllImport("__Internal")]
private static extern void CoreRT_ArcGISRuntimeEnvironment_setInstallDirectory([In, Out, MarshalAs(UnmanagedType.LPArray)] byte[] installPath, out IntPtr outErrorHandle);
我还尝试了 ArcGIS 中的示例应用程序,但在启用热重启后它也以同样的方式失败。
更多信息...
抛出的异常为EntryPointNotFoundException,表示无法解析原生调用。
我对我的 iPhone 做了一些调查,发现 runtimecore.dll 和 runtimecorenet.dll 没有被复制到部署文件夹。它们在构建期间也不会出现在 bin/Debug 文件夹中。我相信这 2 个 dll 是 Esri.ArcGISRuntime.dll.
中本机调用的目标所以我想我必须弄清楚如何说服 Visual Studio 将它们包含在 iOS 构建中。我确实看到它们包含在我的 UWP 构建中。
有什么解决办法吗?
不久前,Microsoft 在热重启中中断了对本机 .frameworks 的支持,而 ArcGIS Runtime 依赖于这些,因此不幸的是,您需要 Mac 才能部署到设备。