Could not load file or assembly Microsoft.VisualStudio.Interop.dll
We recently migrated from .net framework 4.8 to .net 6. We've found our existing .tt files do not generate.
We have added this extension and attempted to run but get the following errors: Severity Code Description Project File Line Suppression State Error Something went wrong executing the template in .NET Core: System.IO.FileNotFoundException: Could not load file or assembly 'd:\Repos\Hvcc.Ips\Src\Server\Hvcc.Ips.Host\Entities\Autogenerated\Microsoft.VisualStudio.Interop.dll'. The system cannot find the file specified. File name: 'd:\Repos\Hvcc.Ips\Src\Server\Hvcc.Ips.Host\Entities\Autogenerated\Microsoft.VisualStudio.Interop.dll' at System.Runtime.Loader.AssemblyLoadContext.LoadFromAssemblyPath(String assemblyPath) at RdJNL.TemplateExecute.LibraryLoadContext.LoadLibrary(String library) in C:\Dev\TextTemplatingCore\TemplateExecute\LibraryLoadContext.cs:line 24 at RdJNL.TemplateExecute.Program.Main(String[] args) in C:\Dev\TextTemplatingCore\TemplateExecute\Program.cs:line 68 Hvcc.Ips.Host d:\Repos\Hvcc.Ips\Src\Server\Hvcc.Ips.Host\Entities\Autogenerated\Entities.tt 1
I did manage to find a package to obtain the Microsoft.VisualStudio.Interop.dll, but then found it needed to be copied into several places in our solution. Which then gave us a new error below: Severity Code Description Project File Line Suppression State Error Something went wrong executing the template in .NET Core: System.IO.FileNotFoundException: Could not load file or assembly 'd:\Repos\Hvcc.Ips\Src\Server\Hvcc.Ips.Host\Entities\Autogenerated%VSAPPIDDIR%EntityFramework.dll'. The system cannot find the file specified. File name: 'd:\Repos\Hvcc.Ips\Src\Server\Hvcc.Ips.Host\Entities\Autogenerated%VSAPPIDDIR%EntityFramework.dll' at System.Runtime.Loader.AssemblyLoadContext.LoadFromAssemblyPath(String assemblyPath) at RdJNL.TemplateExecute.LibraryLoadContext.LoadLibrary(String library) in C:\Dev\TextTemplatingCore\TemplateExecute\LibraryLoadContext.cs:line 24 at RdJNL.TemplateExecute.Program.Main(String[] args) in C:\Dev\TextTemplatingCore\TemplateExecute\Program.cs:line 68 Hvcc.Ips.Host d:\Repos\Hvcc.Ips\Src\Server\Hvcc.Ips.Host\Entities\Autogenerated\Entities.tt 1
Any ideas?
Thanks, Craig.
What assembly references do you have in the T4 file?
Also having simular issue. I'm migrating from framework 4.6.1 to net6.0 and found your extension. I get an error when running one of my templates ..
Severity Code Description Project File Line Suppression State
Error Something went wrong executing the template in .NET Core: System.IO.FileNotFoundException: Could not load file or assembly 'C:\src\vusionpackages-core\Shakespeare.Data\System.Xml.dll'. The system cannot find the file specified.
File name: 'C:\src\vusionpackages-core\Shakespeare.Data\System.Xml.dll'
at System.Runtime.Loader.AssemblyLoadContext.LoadFromAssemblyPath(String assemblyPath)
at RdJNL.TemplateExecute.LibraryLoadContext.LoadLibrary(String library) in C:\Dev\TextTemplatingCore\TemplateExecute\LibraryLoadContext.cs:line 24
at RdJNL.TemplateExecute.Program.Main(String[] args) in C:\Dev\TextTemplatingCore\TemplateExecute\Program.cs:line 68 Shakespeare.Data C:\src\vusionpackages-core\Shakespeare.Data\AgentRunTemplate_GENERATED.tt 1
I am referencing several of my own assemblies and several system ones including system.xml.dll
<#@ assembly Name="System.Xml.dll" #>
This assembly should be in the GAC .. not 'C:\src\vusionpackages-core\Shakespeare.Data' (which is not even the output folder of my project).
If the assembly name ends in .dll, the tool will assume it's a path (either absolute or relative to the template).
.NET 6 does not have a GAC, so that's not gonna work. I don't think you should need a System.Xml assembly at all, TBH. I think it's included in the .NET 6 runtime by default.