You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Xamarin Forms UWP项目Hot Reload时出现System.Runtime模块发射失败错误

问题现象

在使用Xamarin Forms 5.0.0.2125开发UWP项目时,Debug模式部署应用后提示 Xaml Hot Reload connected,但触发Hot Reload时弹出Edit and Continue错误,错误列表出现如下报错:

CS7038: Failed to emit module 'ProjectName': Changing the version of an assembly reference is not allowed during debugging:
'System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' changed version to '4.1.2.0'.
排查解决步骤
  • 配置程序集绑定重定向:在UWP项目的App.config文件的<runtime>节点下添加如下配置,强制统一System.Runtime的引用版本:
<dependentAssembly>
  <assemblyIdentity name="System.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
  <bindingRedirect oldVersion="0.0.0.0-4.1.2.0" newVersion="4.1.2.0" />
</dependentAssembly>
  • 清理项目缓存:关闭Visual Studio,删除解决方案根目录下所有项目的bin、obj文件夹,再删除本地路径%LocalAppData%\Xamarin\HotReload下的全部缓存文件,重新打开Visual Studio执行重建操作。
  • 统一NuGet包版本:检查解决方案内所有项目的NuGet引用,确保System.Runtime、Xamarin.Forms的版本在所有项目中完全一致,禁止共享项目和UWP项目引用不同版本的依赖包。
  • 调整调试设置:打开Visual Studio的「工具>选项>调试>常规」,取消勾选「启用编辑并继续」,再到「工具>选项>调试>热重载」,确认已勾选「启用XAML热重载」以及UWP平台的热重载支持选项。
  • 升级Visual Studio:当前问题属于Xamarin.Forms 5.x版本与旧版Visual Studio的已知兼容问题,升级到Visual Studio 2022 17.2及以上稳定版可直接修复该版本冲突错误。
  • 临时触发方案:修改XAML文件后无需手动点击热重载图标,直接保存文件即可触发自动热重载,可避开Edit and Continue的版本校验逻辑。

内容的提问来源于stack exchange,提问作者Damyant Jain

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.09.24 16:45:05