I have created a new ASP.NET 5 MVC web application which hosts a razor class library with some .net blazor wasm components and a 3rd party library called Elsa. Everything seems to work OK, however when I try to load the Elsa homepage I get the following error:
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)
Kind of lost on this one...not sure why regular MVC pages are loading, but not the 3rd party MVC libs. I believe Elsa was compiled for .NET Standard 2.1.
I can't know for sure, but every time I have seen this error in combination with Elsa 1 and its Dashboard services being added, it had to do with the auto discovery of activity types in order for them to be registered with the dashboard.
The reason Elsa tries to auto-register activities is to avoid you to having to register not only the activities you want to enable for the workflow host, but also the activities you want made available through the workflow designer.
But as you can see from this comment, it has issues.
For Elsa 1, there are basically 2 workarounds:
The real fix however is provided by Elsa 2, which takes a completely different approach, by exposing the available activities via an API endpoint, which the workflow designer consumes to list activities from the activity picker. Which is clean, elegant, and robust.
To manually register activity types to be shown from the dashboard in Elsa 1, replace
services.AddElsaDashboard()
with:Not great, but fortunately this has been fixed in Elsa 2.