微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Xamarin 热重载未初始化失败

如何解决Xamarin 热重载未初始化失败

在 Visual Studio 版本 16.9.x 和更新到 Xamarin.Forms 5.0 的最后一次更新后,热重载不起作用。

这是我在启动应用程序时得到的输出

Hot Reload IDE Extension Loaded
(FinansovoPregledi.Android) XAML Hot Reload is using 'changes only' mode
XAML Hot Reload initializing...
WARN: (FinansovoPregledi.Android) UnkNown Breakpoint Hit: Android.Runtime.jnienv.RegisterJniNatives( typeName_ptr,int typeName_len,jniClass,methods_ptr,int methods_len)
ERROR: Caught exception in AgentStatusChangedHandler at 268: Xamarin.HotReload.EvaluatorException: Failed to Inject Assembly ---> Mono.Debugging.Evaluation.EvaluatorException: Method `Load' not found in type `System.Reflection.Assembly'.
   at Mono.Debugging.soft.softDebuggerAdaptor.OverloadResolveMulti(SoftEvaluationContext ctx,TypeMirror type,String methodName,ArgumentType[] genericTypeArgs,TypeMirror returnType,ArgumentType[] argTypes,List`1 candidates,Boolean throwIfNotFound,Boolean tryCasting) in C:\A\1\216\s\external\debugger-libs\Mono.Debugging.soft\SoftDebuggerAdaptor.cs:line 2619
   at Mono.Debugging.soft.softDebuggerAdaptor.OverloadResolveMulti(SoftEvaluationContext ctx,Boolean allowInstance,Boolean allowStatic,Boolean tryCasting) in C:\A\1\216\s\external\debugger-libs\Mono.Debugging.soft\SoftDebuggerAdaptor.cs:line 2511
   at Mono.Debugging.soft.softDebuggerAdaptor.RuntimeInvoke(EvaluationContext ctx,Object targettype,Object target,Object[] genericTypeArgs,Object[] argTypes,Object[] argValues,Boolean enableOutArgs,Object[]& outArgs) in C:\A\1\216\s\external\debugger-libs\Mono.Debugging.soft\SoftDebuggerAdaptor.cs:line 2304
   at Mono.Debugging.soft.softDebuggerAdaptor.RuntimeInvoke(EvaluationContext ctx,Object[] argValues) in C:\A\1\216\s\external\debugger-libs\Mono.Debugging.soft\SoftDebuggerAdaptor.cs:line 2281
   at Xamarin.HotReload.HotReloadSharedBridge.InjectAndLoadAssembly(IProject project,SoftEvaluationContext context,String assemblyPath) in D:\a\1\s\HotReload\Source\Xamarin.HotReload.Bridge\HotReloadSharedBridge.cs:line 359
--- End of stack trace from prevIoUs location where exception was thrown ---
   at Microsoft.VisualStudio.Telemetry.WindowsErrorReporting.WatsonReport.GetClrWatsonExceptionInfo(Exception exceptionObject)
   --- End of inner exception stack trace ---
   at Xamarin.HotReload.HotReloadSharedBridge.InjectAndLoadAssembly(IProject project,String assemblyPath) in D:\a\1\s\HotReload\Source\Xamarin.HotReload.Bridge\HotReloadSharedBridge.cs:line 374
   at Xamarin.HotReload.HotReloadBridge.<InitializeAgent>d__47.MoveNext() in D:\a\1\s\HotReload\Source\Xamarin.HotReload.Bridge\HotReloadBridge.cs:line 140
--- End of stack trace from prevIoUs location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Xamarin.HotReload.HotReloadBridge.<<Debugger_TargetHitBreakpoint>b__50_0>d.MoveNext() in D:\a\1\s\HotReload\Source\Xamarin.HotReload.Bridge\HotReloadBridge.cs:line 242
   at Xamarin.HotReload.HotReloadSharedBridge.InjectAndLoadAssembly(IProject project,String assemblyPath) in D:\a\1\s\HotReload\Source\Xamarin.HotReload.Bridge\HotReloadSharedBridge.cs:line 374
   at Xamarin.HotReload.HotReloadBridge.<InitializeAgent>d__47.MoveNext() in D:\a\1\s\HotReload\Source\Xamarin.HotReload.Bridge\HotReloadBridge.cs:line 140
--- End of stack trace from prevIoUs location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Xamarin.HotReload.HotReloadBridge.<<Debugger_TargetHitBreakpoint>b__50_0>d.MoveNext() in D:\a\1\s\HotReload\Source\Xamarin.HotReload.Bridge\HotReloadBridge.cs:line 242
XAML Hot Reload encountered a problem and Failed to start. Use Help -> Report a Problem if the issues persists.
Stopping All Hot Reload sessions due to Failed ...
(FinansovoPregledi.Android) Stopping a Hot Reload session due to Failed ...
Stopped Hot Reload session.
ERROR: (FinansovoPregledi.Android) Caught exception in Debugger_TargetHitBreakpoint at 246: Xamarin.HotReload.EvaluatorException: Failed to Inject Assembly ---> Mono.Debugging.Evaluation.EvaluatorException: Method `Load' not found in type `System.Reflection.Assembly'.
   at Mono.Debugging.soft.softDebuggerAdaptor.OverloadResolveMulti(SoftEvaluationContext ctx,String assemblyPath) in D:\a\1\s\HotReload\Source\Xamarin.HotReload.Bridge\HotReloadSharedBridge.cs:line 374
   at Xamarin.HotReload.HotReloadBridge.<InitializeAgent>d__47.MoveNext() in D:\a\1\s\HotReload\Source\Xamarin.HotReload.Bridge\HotReloadBridge.cs:line 140
--- End of stack trace from prevIoUs location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Xamarin.HotReload.HotReloadBridge.<<Debugger_TargetHitBreakpoint>b__50_0>d.MoveNext() in D:\a\1\s\HotReload\Source\Xamarin.HotReload.Bridge\HotReloadBridge.cs:line 242

有人遇到同样的问题吗?我尝试了所有平台的所有内容,还选择刷新整个页面,但没有解决我的问题。没有热重载就太难了。

解决方法

在您的 Android 和 iOS 版本设置中,检查链接器是否设置为“不链接”或“无链接”。 有关 Xamarin.Forms 的 XAML 热重载的更多详细信息,您可以查看:

https://docs.microsoft.com/en-us/xamarin/xamarin-forms/xaml/hot-reload

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。