Assembly references in T4 in Visual Studio 2012 .NET 4.5

1

I am having problems using the T4 tool in Visual Studio 2012. My .tt-files have an assembly directive to a 64-bit .DLL built in the same solution. This is the output from debugging the tt file:

Error 308 The host threw an exception while trying to resolve the assembly reference '$(TargetDir)\DCSGenerator.dll'. The transformation will not be run. The following Exception was thrown: System.IO.FileLoadException: The given assembly name or codebase was invalid. (Exception from HRESULT: 0x80131047) at System.Reflection.AssemblyName.nInit(RuntimeAssembly& assembly, Boolean forIntrospection, Boolean raiseResolveEvent) at System.Reflection.AssemblyName..ctor(String assemblyName) at Microsoft.VisualStudio.TextTemplating.GlobalAssemblyCacheHelper.GetLocation(String strongName) at Microsoft.VisualStudio.TextTemplating.VSHost.TextTemplatingService.ResolveAssemblyReference(String assemblyReference) at Microsoft.VisualStudio.TextTemplating.Engine.ResolveAssemblyReferences(ITextTemplatingEngineHost host, TemplateProcessingSession session) C:\TFS\Dev01\CorePlatform\CoreServices\ImportExport.NET\ImportExport.NET\DicomInterface\TemplateUtilFunctions.tt 0 0 ImportExport.NET (CoreServices\ImportExport.NET\ImportExport.NET)

Is anyone else having problems with this?

Best Regards,

UPDATE 2012-11-14 09:17 (CET): Visual Studio and hence the T4 generator runs as a 32-bit application and my assemblies are built as 64bit DLLs. This might be a source of the problem.

UPDATE 2012-11-14 09:43 (CET): Tried to reference the assembly using the full path but this didn't solve the problem.

c#
visual-studio-2012
t4
.net-4.5
asked on Stack Overflow Nov 13, 2012 by qstebom • edited Nov 14, 2012 by qstebom

1 Answer

0

As I suspected, the problem was solved by building the dependency assemblies with PlatformTarget AnyCPU. Now the generated DLLs are both 32- and 64-bit assembly compatible.

answered on Stack Overflow Nov 14, 2012 by qstebom

User contributions licensed under CC BY-SA 3.0