Skip to content

Exception "Could not load file or assembly mscorlib" when combined with <PublishTrimmed>true</PublishTrimmed> #618

@owensearls

Description

@owensearls

Describe the bug
After upgrading to .NET Core 3 I added the true attribute to my project file, after which my application started crashing with the following error while starting up

Unhandled exception. System.IO.FileNotFoundException: Could not load file or assembly 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. The system cannot find the file specified.

File name: 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'

To Reproduce
With a working ASP.NET core project using the Datadog tracing 1.11.0 native library, add <PublishTrimmed>true</PublishTrimmed> attribute to your project file and try to start the application.

Expected behavior
The application launches, and tracing works.

Screenshots
If applicable, add screenshots to help explain your problem.

Runtime environment (please complete the following information):

  • Instrumentation mode: automatic
  • Tracer version: 1.11.0
  • OS: linux, docker image mcr.microsoft.com/dotnet/core/runtime:3.1
  • CLR:.NET Core 3.1

Additional context
I also tried this with .NET Core 3.0, and had the same result.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions