c# - ASP.NET 5 - TypeLoadException - 无法从程序集“Microsoft.JSInterop.WebAssembly”加载类型“WebAssembly.JSInterop.JSCallInfo”
问题描述
我创建了一个新的 ASP.NET 5 MVC Web 应用程序,它托管了一个带有一些 .net blazor wasm 组件的 razor 类库和一个名为 Elsa 的第 3 方库。一切似乎都正常,但是当我尝试加载 Elsa 主页时,出现以下错误:
TypeLoadException: Generic method or method in generic class is internal call, PInvoke, or is defined in a COM Import class.
Unknown location
TypeLoadException: Could not load type 'WebAssembly.JSInterop.JSCallInfo' from assembly 'Microsoft.JSInterop.WebAssembly, Version=5.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' because it contains an object field at offset 4 that is incorrectly aligned or overlapped by a non-object field.
Unknown location
ReflectionTypeLoadException: Unable to load one or more of the requested types.
Generic method or method in generic class is internal call, PInvoke, or is defined in a COM Import class.
Could not load type 'WebAssembly.JSInterop.JSCallInfo' from assembly 'Microsoft.JSInterop.WebAssembly, Version=5.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' because it contains an object field at offset 4 that is incorrectly aligned or overlapped by a non-object field.
System.Reflection.RuntimeModule.GetTypes(RuntimeModule module)
有点迷失在这个...不知道为什么常规 MVC 页面正在加载,但不是第 3 方 MVC 库。我相信 Elsa 是为 .NET Standard 2.1 编译的。
解决方案
对我来说,问题是我的客户端项目中缺少对 Microsoft.AspNetCore.Components.WebAssembly.DevServer 的引用。
我正在将一个 blazor 服务器项目升级到 WASM,并遇到了这个需要一段时间才能调试的错误。
推荐阅读
- c# - UWP 应用程序 - 将 SQL 表中的数据显示到数据网格或列表框
- python - 将 Pytorch 中实现的自定义优化器转换为 TensorFlow
- sql-server - 如何将 DACPAC 部署到事务复制数据库
- sockets - How send/receive a List of elements over socket?
- javascript - 滚动 div 在内容加载时卡在底部
- python - Django 从可以选择多个选项的下拉列表中获取值
- c++ - 如何在资源管理器中的文件拖动操作期间获取鼠标光标坐标
- flowtype - 像“数字”这样的流包装类型的目的是什么?
- typescript - 映射类型可以使属性成为可选的,但前提是满足条件?
- android - Embarcadero C++Builder Android 应用程序 SEGV_MAPERR 在特定手机上崩溃 (Galaxy A51)