首页 > 解决方案 > 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 编译的。

标签: c#asp.net-coreasp.net-core-mvcasp.net-core-5.0elsa-workflows

解决方案


对我来说,问题是我的客户端项目中缺少对 Microsoft.AspNetCore.Components.WebAssembly.DevServer 的引用。

我正在将一个 blazor 服务器项目升级到 WASM,并遇到了这个需要一段时间才能调试的错误。


推荐阅读