首页 > 解决方案 > Xamarin Hot Reload 没有初始化失败

问题描述

在 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, TypeMirror type, String methodName, ArgumentType[] genericTypeArgs, TypeMirror returnType, ArgumentType[] argTypes, Boolean allowInstance, Boolean allowStatic, Boolean throwIfNotFound, 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, String methodName, 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 targetType, Object target, String methodName, Object[] genericTypeArgs, Object[] argTypes, 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, SoftEvaluationContext context, 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, SoftEvaluationContext context, 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, 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, TypeMirror type, String methodName, ArgumentType[] genericTypeArgs, TypeMirror returnType, ArgumentType[] argTypes, Boolean allowInstance, Boolean allowStatic, Boolean throwIfNotFound, 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, String methodName, 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 targetType, Object target, String methodName, Object[] genericTypeArgs, Object[] argTypes, 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, SoftEvaluationContext context, 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, SoftEvaluationContext context, 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

有没有人有同样的问题?我尝试了所有平台的一切,还选择刷新整个页面,但没有解决我的问题。没有 Hot Reload 太难了。

标签: c#visual-studioxamarinxamarin.formshot-reload

解决方案


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

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


推荐阅读