如何在 iOS 设备上获取我的 Xamarin 应用程序 运行?
How do I get my Xamarin app running on an iOS device?
谁能帮帮我?
我正在 Visual Studio 2022 年在 Windows PC 上开发 Xamarin Forms 应用程序。我将 VS 连接到 MacinCloud Mac 并将 iPhone 连接到 Windows PC。
我的应用程序在 iPhone 上部署并启动,但是当我去登录时它崩溃了。
它崩溃的代码行正在调用 HttpClient.PostAsync 以回调我们的 API 进行身份验证。
错误和崩溃转储如下。
有什么想法吗?
谢谢,
保罗.
Foundation.MonoTouchException
Message=Objective-C exception thrown. Name: NSMallocException Reason: Failed to grow buffer
Native stack trace:
0 CoreFoundation 0x0000000180a35060 B2D21CFD-378C-36D5-BAF7-3F70599CFEFC + 626784
1 libobjc.A.dylib 0x00000001990a9f54 objc_exception_throw + 60
2 CoreFoundation 0x0000000180b42af0 B2D21CFD-378C-36D5-BAF7-3F70599CFEFC + 1731312
3 CoreFoundation 0x0000000180b3addc B2D21CFD-378C-36D5-BAF7-3F70599CFEFC + 1699292
4 CoreFoundation 0x00000001809cf28c __CFSafelyReallocate + 72
5 Foundation 0x00000001821f6a48 D59C6975-5AF2-37BC-93BE-43B80B4293A5 + 232008
6 Foundation 0x00000001821f26d4 D59C6975-5AF2-37BC-93BE-43B80B4293A5 + 214740
7 Xamarin.PreBuilt.iOS 0x00000001024e9c54 do_icall + 328
8 Xamarin.PreBuilt.iOS 0x00000001024e82e4 do_icall_wrapper + 296
9 Xamarin.PreBuilt.iOS 0x00000001024df1d8 interp_exec_method_full + 2740
10 Xamarin.PreBuilt.iOS 0x00000001024dd768 interp_runtime_invoke + 336
11 Xamarin.PreBuilt.iOS 0x000000010234ae70 mono_jit_runtime_invoke + 900
12 Xamarin.PreBuilt.iOS 0x00000001023f9188 mono_runtime_try_invoke + 156
13 Xamarin.PreBuilt.iOS 0x00000001023faddc mono_runtime_invoke + 100
14 Xamarin.PreBuilt.iOS 0x00000001022613e0 _ZL31native_to_managed_trampoline_11P11objc_objectP13objc_selectorPP11_MonoMethodj + 244
15 Xamarin.PreBuilt.iOS 0x00000001022a7db8 -[UIKit_UIControlEventProxy BridgeSelector] + 44
16 UIKitCore 0x000000018330abf0 8388EB03-002B-3B35-A78A-6A022894292E + 5016560
17 UIKitCore 0x0000000183436a4c 8388EB03-002B-3B35-A78A-6A022894292E + 6244940
18 UIKitCore 0x00000001831b22c8 8388EB03-002B-3B35-A78A-6A022894292E + 3605192
19 UIKitCore 0x000000018324eae0 8388EB03-002B-3B35-A78A-6A022894292E + 4246240
20 UIKitCore 0x00000001834e17c0 8388EB03-002B-3B35-A78A-6A022894292E + 6944704
21 UIKitCore 0x0000000182fa6d40 8388EB03-002B-3B35-A78A-6A022894292E + 1461568
22 UIKitCore 0x0000000182fd98c8 8388EB03-002B-3B35-A78A-6A022894292E + 1669320
23 UIKitCore 0x0000000182fe6a68 8388EB03-002B-3B35-A78A-6A022894292E + 1722984
24 UIKitCore 0x0000000183196318 8388EB03-002B-3B35-A78A-6A022894292E + 3490584
25 UIKitCore 0x0000000182fb9c30 8388EB03-002B-3B35-A78A-6A022894292E + 1539120
26 UIKitCore 0x0000000182faea1c 8388EB03-002B-3B35-A78A-6A022894292E + 1493532
27 UIKitCore 0x0000000182fb3ec8 8388EB03-002B-3B35-A78A-6A022894292E + 1515208
28 CoreFoundation 0x0000000180a57020 B2D21CFD-378C-36D5-BAF7-3F70599CFEFC + 765984
29 CoreFoundation 0x0000000180a67ce0 B2D21CFD-378C-36D5-BAF7-3F70599CFEFC + 834784
30 CoreFoundation 0x00000001809a1fe8 B2D21CFD-378C-36D5-BAF7-3F70599CFEFC + 24552
31 CoreFoundation 0x00000001809a77f4 B2D21CFD-378C-36D5-BAF7-3F70599CFEFC + 47092
32 CoreFoundation 0x00000001809bb3b8 CFRunLoopRunSpecific + 600
33 GraphicsServices 0x000000019c34b38c GSEventRunModal + 164
34 UIKitCore 0x000000018335b6a8 8388EB03-002B-3B35-A78A-6A022894292E + 5346984
35 UIKitCore 0x00000001830da7f4 UIApplicationMain + 2092
36 Xamarin.PreBuilt.iOS 0x00000001024e9bb0 do_icall + 164
37 Xamarin.PreBuilt.iOS 0x00000001024e82e4 do_icall_wrapper + 296
38 Xamarin.PreBuilt.iOS 0x00000001024df1d8 interp_exec_method_full + 2740
39 Xamarin.PreBuilt.iOS 0x00000001024dd768 interp_runtime_invoke + 336
40 Xamarin.PreBuilt.iOS 0x000000010234ae70 mono_jit_runtime_invoke + 900
41 Xamarin.PreBuilt.iOS 0x00000001023f7984 mono_runtime_invoke_checked + 148
42 Xamarin.PreBuilt.iOS 0x00000001023fe000 mono_runtime_try_invoke_array + 1272
43 Xamarin.PreBuilt.iOS 0x00000001023a74f0 ves_icall_InternalInvoke + 1036
44 Xamarin.PreBuilt.iOS 0x00000001023b7780 ves_icall_InternalInvoke_raw + 108
45 Xamarin.PreBuilt.iOS 0x00000001024e9bb0 do_icall + 164
46 Xamarin.PreBuilt.iOS 0x00000001024e82e4 do_icall_wrapper + 296
47 Xamarin.PreBuilt.iOS 0x00000001024df1d8 interp_exec_method_full + 2740
48 Xamarin.PreBuilt.iOS 0x00000001024dd768 interp_runtime_invoke + 336
49 Xamarin.PreBuilt.iOS 0x000000010234ae70 mono_jit_runtime_invoke + 900
50 Xamarin.PreBuilt.iOS 0x00000001023f7984 mono_runtime_invoke_checked + 148
51 Xamarin.PreBuilt.iOS 0x00000001023fcbf8 mono_runtime_exec_main_checked + 128
52 Xamarin.PreBuilt.iOS 0x000000010232f850 mono_jit_exec + 376
53 Xamarin.PreBuilt.iOS 0x00000001024db834 xamarin_main + 1944
54 Xamarin.PreBuilt.iOS 0x00000001022f74f4 main + 76
55 dyld 0x0000000102e71a24 start + 520
Source=Xamarin.iOS
StackTrace:
at ObjCRuntime.Runtime.ThrowNSException (System.IntPtr ns_exception) [0x00000] in /Users/builder/azdo/_work/1/s/xamarin-macios/src/ObjCRuntime/Runtime.cs:449
at ObjCRuntime.Runtime.throw_ns_exception (System.IntPtr exc) [0x00000] in /Users/builder/azdo/_work/1/s/xamarin-macios/runtime/Delegates.generated.cs:392
at (wrapper native-to-managed) ObjCRuntime.Runtime.throw_ns_exception(intptr)
我已经设法通过创建一个处理程序并将其传递给我的 Http 客户端的构造函数来解决这个问题。
var handler = new HttpClientHandler();
var httpClient = new HttpClient(handler);
我以为我之前已经尝试过这个解决方案但无济于事,但我找到了第二个地方,它正在创建客户端并在那里实现它,也解决了这个问题。
谁能帮帮我?
我正在 Visual Studio 2022 年在 Windows PC 上开发 Xamarin Forms 应用程序。我将 VS 连接到 MacinCloud Mac 并将 iPhone 连接到 Windows PC。
我的应用程序在 iPhone 上部署并启动,但是当我去登录时它崩溃了。
它崩溃的代码行正在调用 HttpClient.PostAsync 以回调我们的 API 进行身份验证。
错误和崩溃转储如下。
有什么想法吗?
谢谢,
保罗.
Foundation.MonoTouchException
Message=Objective-C exception thrown. Name: NSMallocException Reason: Failed to grow buffer
Native stack trace:
0 CoreFoundation 0x0000000180a35060 B2D21CFD-378C-36D5-BAF7-3F70599CFEFC + 626784
1 libobjc.A.dylib 0x00000001990a9f54 objc_exception_throw + 60
2 CoreFoundation 0x0000000180b42af0 B2D21CFD-378C-36D5-BAF7-3F70599CFEFC + 1731312
3 CoreFoundation 0x0000000180b3addc B2D21CFD-378C-36D5-BAF7-3F70599CFEFC + 1699292
4 CoreFoundation 0x00000001809cf28c __CFSafelyReallocate + 72
5 Foundation 0x00000001821f6a48 D59C6975-5AF2-37BC-93BE-43B80B4293A5 + 232008
6 Foundation 0x00000001821f26d4 D59C6975-5AF2-37BC-93BE-43B80B4293A5 + 214740
7 Xamarin.PreBuilt.iOS 0x00000001024e9c54 do_icall + 328
8 Xamarin.PreBuilt.iOS 0x00000001024e82e4 do_icall_wrapper + 296
9 Xamarin.PreBuilt.iOS 0x00000001024df1d8 interp_exec_method_full + 2740
10 Xamarin.PreBuilt.iOS 0x00000001024dd768 interp_runtime_invoke + 336
11 Xamarin.PreBuilt.iOS 0x000000010234ae70 mono_jit_runtime_invoke + 900
12 Xamarin.PreBuilt.iOS 0x00000001023f9188 mono_runtime_try_invoke + 156
13 Xamarin.PreBuilt.iOS 0x00000001023faddc mono_runtime_invoke + 100
14 Xamarin.PreBuilt.iOS 0x00000001022613e0 _ZL31native_to_managed_trampoline_11P11objc_objectP13objc_selectorPP11_MonoMethodj + 244
15 Xamarin.PreBuilt.iOS 0x00000001022a7db8 -[UIKit_UIControlEventProxy BridgeSelector] + 44
16 UIKitCore 0x000000018330abf0 8388EB03-002B-3B35-A78A-6A022894292E + 5016560
17 UIKitCore 0x0000000183436a4c 8388EB03-002B-3B35-A78A-6A022894292E + 6244940
18 UIKitCore 0x00000001831b22c8 8388EB03-002B-3B35-A78A-6A022894292E + 3605192
19 UIKitCore 0x000000018324eae0 8388EB03-002B-3B35-A78A-6A022894292E + 4246240
20 UIKitCore 0x00000001834e17c0 8388EB03-002B-3B35-A78A-6A022894292E + 6944704
21 UIKitCore 0x0000000182fa6d40 8388EB03-002B-3B35-A78A-6A022894292E + 1461568
22 UIKitCore 0x0000000182fd98c8 8388EB03-002B-3B35-A78A-6A022894292E + 1669320
23 UIKitCore 0x0000000182fe6a68 8388EB03-002B-3B35-A78A-6A022894292E + 1722984
24 UIKitCore 0x0000000183196318 8388EB03-002B-3B35-A78A-6A022894292E + 3490584
25 UIKitCore 0x0000000182fb9c30 8388EB03-002B-3B35-A78A-6A022894292E + 1539120
26 UIKitCore 0x0000000182faea1c 8388EB03-002B-3B35-A78A-6A022894292E + 1493532
27 UIKitCore 0x0000000182fb3ec8 8388EB03-002B-3B35-A78A-6A022894292E + 1515208
28 CoreFoundation 0x0000000180a57020 B2D21CFD-378C-36D5-BAF7-3F70599CFEFC + 765984
29 CoreFoundation 0x0000000180a67ce0 B2D21CFD-378C-36D5-BAF7-3F70599CFEFC + 834784
30 CoreFoundation 0x00000001809a1fe8 B2D21CFD-378C-36D5-BAF7-3F70599CFEFC + 24552
31 CoreFoundation 0x00000001809a77f4 B2D21CFD-378C-36D5-BAF7-3F70599CFEFC + 47092
32 CoreFoundation 0x00000001809bb3b8 CFRunLoopRunSpecific + 600
33 GraphicsServices 0x000000019c34b38c GSEventRunModal + 164
34 UIKitCore 0x000000018335b6a8 8388EB03-002B-3B35-A78A-6A022894292E + 5346984
35 UIKitCore 0x00000001830da7f4 UIApplicationMain + 2092
36 Xamarin.PreBuilt.iOS 0x00000001024e9bb0 do_icall + 164
37 Xamarin.PreBuilt.iOS 0x00000001024e82e4 do_icall_wrapper + 296
38 Xamarin.PreBuilt.iOS 0x00000001024df1d8 interp_exec_method_full + 2740
39 Xamarin.PreBuilt.iOS 0x00000001024dd768 interp_runtime_invoke + 336
40 Xamarin.PreBuilt.iOS 0x000000010234ae70 mono_jit_runtime_invoke + 900
41 Xamarin.PreBuilt.iOS 0x00000001023f7984 mono_runtime_invoke_checked + 148
42 Xamarin.PreBuilt.iOS 0x00000001023fe000 mono_runtime_try_invoke_array + 1272
43 Xamarin.PreBuilt.iOS 0x00000001023a74f0 ves_icall_InternalInvoke + 1036
44 Xamarin.PreBuilt.iOS 0x00000001023b7780 ves_icall_InternalInvoke_raw + 108
45 Xamarin.PreBuilt.iOS 0x00000001024e9bb0 do_icall + 164
46 Xamarin.PreBuilt.iOS 0x00000001024e82e4 do_icall_wrapper + 296
47 Xamarin.PreBuilt.iOS 0x00000001024df1d8 interp_exec_method_full + 2740
48 Xamarin.PreBuilt.iOS 0x00000001024dd768 interp_runtime_invoke + 336
49 Xamarin.PreBuilt.iOS 0x000000010234ae70 mono_jit_runtime_invoke + 900
50 Xamarin.PreBuilt.iOS 0x00000001023f7984 mono_runtime_invoke_checked + 148
51 Xamarin.PreBuilt.iOS 0x00000001023fcbf8 mono_runtime_exec_main_checked + 128
52 Xamarin.PreBuilt.iOS 0x000000010232f850 mono_jit_exec + 376
53 Xamarin.PreBuilt.iOS 0x00000001024db834 xamarin_main + 1944
54 Xamarin.PreBuilt.iOS 0x00000001022f74f4 main + 76
55 dyld 0x0000000102e71a24 start + 520
Source=Xamarin.iOS
StackTrace:
at ObjCRuntime.Runtime.ThrowNSException (System.IntPtr ns_exception) [0x00000] in /Users/builder/azdo/_work/1/s/xamarin-macios/src/ObjCRuntime/Runtime.cs:449
at ObjCRuntime.Runtime.throw_ns_exception (System.IntPtr exc) [0x00000] in /Users/builder/azdo/_work/1/s/xamarin-macios/runtime/Delegates.generated.cs:392
at (wrapper native-to-managed) ObjCRuntime.Runtime.throw_ns_exception(intptr)
我已经设法通过创建一个处理程序并将其传递给我的 Http 客户端的构造函数来解决这个问题。
var handler = new HttpClientHandler();
var httpClient = new HttpClient(handler);
我以为我之前已经尝试过这个解决方案但无济于事,但我找到了第二个地方,它正在创建客户端并在那里实现它,也解决了这个问题。