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 issueDescription
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]
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
Repro steps
- Clone repo https://github.com/sergey-tihon/tp-inherit-bug
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:
- Created 5 years ago
- Comments:5 (5 by maintainers)
Top GitHub Comments
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.Thank you @Tarmil, you are right, it works now.