Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeLoadException only when running using dotnet run, apps works fine from published artifacts #8674

Closed
Antaris opened this issue Aug 2, 2017 · 2 comments

Comments

@Antaris
Copy link

Antaris commented Aug 2, 2017

I'm getting a TypeLoadException for one of my types defined in an assembly that is referenced transitively. My solution setup is as follows:

samples\SecurityWebSample\SecurityWebSample.csproj (netcoreapp2.0)
src\Fx.Security\Fx.Security.csproj (netstandard2.0)
src\Fx.Security.Abstractions\Fx.Security.Abstractions.csproj (netstandard2.0)
tests\Fx.Security.Tests\Fx.Security.Tests.csproj (netcoreapp2.0)

My Fx.Security library references one of my packages from an internal NuGet feed, Fx.Messaging.Abstractions, which contains my type MessageBuilder.
Fx.Messaging.Abstractions targets netstandard2.0 like all other projects.

My unit test project Fx.Security.Tests builds and executes tests fine (and they all pass too!)

BUT

When I run my ASP.NET Core project (SecurityWebSample) using dotnet run (or from Visual Studio 2017 [15.3 Preview 7.0]), it throws a TypeLoadException saying it can't load my type:

TypeLoadException: Could not load type 'Fx.Messaging.MessageBuilder' from assembly 'Fx.Messaging.Abstractions, Version=0.2.0.0, Culture=neutral, PublicKeyToken=91f42c97e4c34ea6'.

BUT

If I publish this app using dotnet publish and then run the app dotnet .\SecurityWebSample.dll, it all works fine.

I can't get any more information out of the exception (there is no InnerException set).

Any ideas on how I might go figuring this out?

@Antaris
Copy link
Author

Antaris commented Aug 3, 2017

Additionally, I've completely cleared my packages caches, and confirmed that I am running .NET Core 2.0.0-preview2-006497

@Antaris
Copy link
Author

Antaris commented Aug 3, 2017

Closing this out, as I had some stray build artifacts caused by simply coping the Web sample project from my Fx.Messaging solution to my Fx.Security solution. Nothing to see hear.

@Antaris Antaris closed this as completed Aug 3, 2017
@msftgits msftgits transferred this issue from dotnet/coreclr Jan 31, 2020
@ghost ghost locked as resolved and limited conversation to collaborators Dec 21, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant