question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Compiler is unable to load 3rd-party assembly if Runtime&Design-Time component contains type inherited from type defined in 3rd-party assembly

See original GitHub issue

Description

When I add type OptionConverter inherited from JsonConverter that is defined inside Newtonsoft.Json.dll

open Newtonsoft.Json

type OptionConverter() =
    inherit JsonConverter() // Type from Newtonsoft.Json

to runtime&design time assemblies, compilation fails with error

error FS3031 : The type provider ‘/Users/sergey/github/SwaggerProvider2/src/SwaggerProvider.Runtime/bin/Debug/net45/SwaggerProvider.Runtime.dll’ reported an error : Assembly attribute ‘TypeProviderAssemblyAttribute’ refers to a designer assembly ‘SwaggerProvider.DesignTime.dll’ which cannot be loaded or doesn’t exist. Could not load file or assembly ‘Newtonsoft.Json, Version=11.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed’. The system cannot find the file specified. [/Users/sergey/github/SwaggerProvider2/tests/SwaggerProvider.Tests/SwaggerProvider.Tests.fsproj]

serialization_fs_ _swaggerprovider2

but when I comment class with inheritance OptionConverter but leave usage of Newtonsoft.Json.dll from other places - it loads Newtonsoft.Json.dll correctly.

There is an another error on the screenshot (but it is not related to dependency resolution) - this version is in inherit branch - https://github.com/sergey-tihon/SwaggerProvider2/commit/62a9d46880ffe51822facac3d82dceda9776dc75

serialization_fs_ _swaggerprovider2

Repro steps

  1. Clone repo https://github.com/sergey-tihon/tp-inherit-bug
  2. dotnet build

Expected behavior

Successful compilation

Actual behavior

error FS3031 : The type provider ‘/Users/sergey/github/SwaggerProvider2/src/SwaggerProvider.Runtime/bin/Debug/net45/SwaggerProvider.Runtime.dll’ reported an error : Assembly attribute ‘TypeProviderAssemblyAttribute’ refers to a designer assembly ‘SwaggerProvider.DesignTime.dll’ which cannot be loaded or doesn’t exist. Could not load file or assembly ‘Newtonsoft.Json, Version=11.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed’. The system cannot find the file specified. [/Users/sergey/github/SwaggerProvider2/tests/SwaggerProvider.Tests/SwaggerProvider.Tests.fsproj]

Known workarounds

I guess that it should be possible to define such types in another assembly and load as dependency… but i did not try it yer (I hope that @dsyme know the line when we forgot to remap types 😉 )

Related information

  • Operating system - macOS
  • latest master (2018-10-31)
  • dotnet 2.1.401, mono 5.12.0.309

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
Tarmilcommented, Nov 10, 2018

I get the same error when using an external type in the signature of a method in the TPDTC. Although in my case it’s a runtime method I don’t actually need in the TPDTC, so I can just #if it out.

0reactions
sergey-tihoncommented, Jun 2, 2020

Thank you @Tarmil, you are right, it works now.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Could not load type from assembly error
When I execute the test through the NUnit GUI I get: WindsorSample.ConcreteImplFixture.ResolvingConcreteImplShouldInitialiseValue: System.IO.
Read more >
The compiler is unable to type-check this expression ...
Full error: The compiler is unable to type-check this expression in reasonable time; try breaking up the expression into distinct sub-expressions
Read more >
RuntimeInitializeOnLoadMethod...
Static methods are not inherited, they always only belong to the type that defined them and are not part of any derived types....
Read more >
C# inherit from a class in a different DLL
In C# it makes no difference, whether a class inherits from a class in the same assembly or a class in another assembly....
Read more >
Need help filling a list with all classes that inherit from an ...
I want to be able to change/switch out these abilities easily in the future by just creating/deleting one of the ability classes. These...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found