T4 Template failing - Could not load file or assembly System.Runtime
I'm trying out Rider because I'm having issues with VS. I'm really liking it but I'm having an issue with a T4 template. It works in VS but in Rider I'm getting
Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly 'System.Runtime, Version=4.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
at JetBrains.Rider.TextTemplating.GeneratedTextTransformation.<TransformText>g__GetParentProjectItem|1_1(<>c__DisplayClass1_0& )
at JetBrains.Rider.TextTemplating.GeneratedTextTransformation.TransformText()
at JetBrains.Rider.TextTemplating.ReSharperGeneratedTransformationExecutor.<>c__DisplayClass1_0.<PostRegisterMain>b__0(Lifetime lifetime)
at JetBrains.Lifetimes.Lifetime.UsingNested[T](Func`2 action)
at JetBrains.Rider.TextTemplating.ReSharperGeneratedTransformationExecutor.PostRegisterMain(String[] args)
at JetBrains.Rider.TextTemplating.ReSharperGeneratedTransformationExecutor.Main(String[] args)Process finished with exit code -532,462,766.
This is the start of the template
<#@ template language="C#" debug="true" hostspecific="true" #>
<#@ output extension=".cs" #>
<#@ assembly name="EnvDTE" #>
<#@ assembly name="System.Core" #>
<#@ assembly name="System.Linq" #>
<#@ assembly name="System.Runtime" #>
<#@ import namespace="System" #>
<#@ import namespace="System.Collections.Generic" #>
<#@ import namespace="System.IO" #>
<#@ import namespace="EnvDTE" #>
If I don't reference System.Runtime then I get
The type 'IEnumerable' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Runtime, Version=4.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
Please sign in to leave a comment.
Hello Lozzadude,
This issue is likely related to a known issue RIDER-112510 Error when running T4 template. Could you send us a sample of the full affected template so we could take a look at this?
You can send us the file privately using the Upload Service and let me know the Upload ID in this thread.
I've uploaded it
Upload id: 2025_06_04_5neEtD9QhqeG1Xc7vN3dLQ (file: RenderControllers.tt)
Hello Lozzadude,
This issue will be investigated further and resolved in the scope of RIDER-126918 Rider is unable to execute a specific T4 template (System.Runtime). Please consider following the linked issue to monitor progress. Regrettably, I cannot suggest any workarounds at this time.