runtime: .NET Core 2 type load exception for "AssociatedMetadataTypeTypeDescriptionProvider" when using full .net framework dll in web api owin
We’ve developed an app on top of “Full .NET/Owin”. We managed to run that app on top of “Full .NET/ASP.NET Core” very easily. Then we started to test that on .net core 2 as it accepts referencing full .net assemblies. Interestingly lots of things are working (signalr, web api, static files middleware etc). Now we’re working on “ASP.NET Web API / OData” as it has no suitable equivalent in .net core world). In web api parts, we’ve used swagger, and by running its UI, I received an interesting exception:
"System.TypeLoadException","Message":"Could not load type
'System.ComponentModel.DataAnnotations.AssociatedMetadataTypeTypeDescriptionProvider' from assembly 'System.ComponentModel.DataAnnotations, Version=4.0.0.0, Culture=neutral, PublicKeyToke
n=31bf3856ad364e35'
This is a link of repository which contains the sample app you need to reproduce the problem: https://github.com/ysmoradi/WebApiOwinSwaggerProblemOnDotNetCore2Preview
Run http://localhost:5000/api/swagger and you’ll see that exception in console. Note that swagger itself works(!). You can fix this problem by commenting BadController class easily. You’ll see GoodController methods in swagger ui and you can invoke them.
I think there is a problem in .NET full shim in .NET Core 2.
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 20 (15 by maintainers)
Once you are successfully consuming bits you built yourself, you can add the type. You’d edit src\System.ComponentModel.Annotations\ref\System.ComponentModel.Annotations.cs to add the declaratoin, and put the implementation in src\System.ComponentModel.Annotations\src.
@ysmoradi OK, it wil lbe a bit of work if you’ve not previously got set up to contribute. You’ll want to clone this corefx repo, and then follow the docs (start here) to build it. Then follow the docs here to use the result. Hopefully the docs are accurate - if not please let us know and maybe submit a fix. Ping back if you get stuck.
It would be interesting to know the full set you need @ysmoradi … not sure how to find out though unless you want to add this type locally and see what happens,.
@AlexGhiondea what criteria did you use for selecting the S.CM types to port? We have some parts of eg System.ComponentModel.DataAnnotations.dll from 4.6.1 and not others.
Below are the concrete types In S.CM (except Composition) that are in 4.6.1 but not Core.