T4 template fails loading System.IAsyncDisposable in assembly 'System.Runtime

JetBrains Rider 2021.3 EAP 7 running a T4 template with a dotnet 6 app.

Whatever way I slice it and dice it System.IAsyncDisposable doesn't get resolved. Any ideas? Maybe the mono powering the template gen is to blame?

 

/Library/Frameworks/Mono.framework/Versions/6.12.0/bin/mono-sgen64 /Users/user/Documents/Thesaurus/Development/myapp-online-core-api/Library/obj/Debug/net6.0/TextTemplating/Library/Templating/AsyncEntityNavigation/GeneratedTransformation.exe /Users/user/Documents/Thesaurus/Development/myapp-online-core-api/Library/obj/Debug/net6.0/TextTemplating/Library/Templating/AsyncEntityNavigation/AsyncEntityNavigation.cs

Unhandled Exception:
System.TypeLoadException: Could not load type of field 'myapp.online.core.model.TemplateHelper:<Context>k__BackingField' (0) due to: Could not resolve type with token 0100004a from typeref (expected class 'System.IAsyncDisposable' in assembly 'System.Runtime, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a') assembly:System.Runtime, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a type:System.IAsyncDisposable member:(null)
at JetBrains.Rider.TextTemplating.ReSharperGeneratedTransformationExecutor+<>c__DisplayClass1_0.<PostRegisterMain>b__0 (JetBrains.Lifetimes.Lifetime lifetime) [0x00034] in <64986df0462f4b93a6be1c882b7f64aa>:0
at JetBrains.Lifetimes.Lifetime.UsingNested[T] (System.Func`2[T,TResult] action) [0x0001c] in <14b7b9a76aba4389914cf5afc44375c2>:0
at JetBrains.Rider.TextTemplating.ReSharperGeneratedTransformationExecutor.PostRegisterMain (System.String[] args) [0x00014] in <64986df0462f4b93a6be1c882b7f64aa>:0
at JetBrains.Rider.TextTemplating.ReSharperGeneratedTransformationExecutor.Main (System.String[] args) [0x00007] in <64986df0462f4b93a6be1c882b7f64aa>:0
[ERROR] FATAL UNHANDLED EXCEPTION: System.TypeLoadException: Could not load type of field 'myapp.online.core.model.TemplateHelper:<Context>k__BackingField' (0) due to: Could not resolve type with token 0100004a from typeref (expected class 'System.IAsyncDisposable' in assembly 'System.Runtime, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a') assembly:System.Runtime, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a type:System.IAsyncDisposable member:(null)
at JetBrains.Rider.TextTemplating.ReSharperGeneratedTransformationExecutor+<>c__DisplayClass1_0.<PostRegisterMain>b__0 (JetBrains.Lifetimes.Lifetime lifetime) [0x00034] in <64986df0462f4b93a6be1c882b7f64aa>:0
at JetBrains.Lifetimes.Lifetime.UsingNested[T] (System.Func`2[T,TResult] action) [0x0001c] in <14b7b9a76aba4389914cf5afc44375c2>:0
at JetBrains.Rider.TextTemplating.ReSharperGeneratedTransformationExecutor.PostRegisterMain (System.String[] args) [0x00014] in <64986df0462f4b93a6be1c882b7f64aa>:0
at JetBrains.Rider.TextTemplating.ReSharperGeneratedTransformationExecutor.Main (System.String[] args) [0x00007] in <64986df0462f4b93a6be1c882b7f64aa>:0
1 comment
Comment actions Permalink

Jonathan What you can try to do is reference this assembly from NuGet, to download it to the project. After it, add a reference in the T4 file to the assembly that was downloaded after NuGet restore. Does it help?

0

Please sign in to leave a comment.