1

Closed

Can't invoke T4 tt's from VS2012 Addin using latest beta

description

In VS2010 I was able to invoke my T4 tt's from within a Visual Studio Addin using the following technique:
TextReader tr = new StreamReader(ttFile);
string content = tr.ReadToEnd();
IServiceProvider serviceProvider = new ServiceProvider((Microsoft.VisualStudio.OLE.Interop.IServiceProvider)m_applicationObject.DTE);
ITextTemplating tt = serviceProvider.GetService(typeof(STextTemplating)) as ITextTemplating;
tt.ProcessTemplate(ttFile, content, (this as ITextTemplatingCallback), null);

I've moved to VS2012 and upgraded to the T4 3.0.8 beta, but calling ProcessTemplate now throws the Exception below. Any ideas? Thanks

System.InvalidCastException: Unable to cast object of type 'TMS.Tools.EntityModelGenerationAddIn.Connect' to type 'Microsoft.VisualStudio.TextTemplating.VSHost.TextTemplatingCallback'.

Server stack trace:
at T4Toolbox.VisualStudio.OutputFileManager.ValidateOutputEncoding(OutputFile output)
at T4Toolbox.VisualStudio.OutputFileManager.Validate()
at T4Toolbox.VisualStudio.TransformationContextProvider.T4Toolbox.ITransformationContextProvider.UpdateOutputFiles(String inputFile, OutputFile[] outputFiles)
at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Object[]& outArgs)
at System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg)

Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at T4Toolbox.ITransformationContextProvider.UpdateOutputFiles(String inputFile, OutputFile[] outputFiles)
at T4Toolbox.TransformationContext.Dispose(Boolean disposing)
at T4Toolbox.TransformationContext.Dispose()
at T4Toolbox.TransformationContext.Cleanup()
at Microsoft.VisualStudio.TextTemplatingBBC5941AFF35CB607B57D4FBA03DCD978AADFDDA89E562E9DF49429CDF6B7C038A1171C9E0AC04F7C7B0652CFCA988A67A0F06124756B10A734707EBF798AC79.GeneratedTextTransformation.Dispose(Boolean disposing)
at Microsoft.VisualStudio.TextTemplating.TextTransformation.Dispose()
at Microsoft.VisualStudio.TextTemplating.TransformationRunner.PerformTransformation()
at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Object[]& outArgs)
at System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg)

Exception rethrown at [1]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at Microsoft.VisualStudio.TextTemplating.IDebugTransformationRun.PerformTransformation()
at Microsoft.VisualStudio.TextTemplating.Engine.ProcessTemplateImplementation(TemplateProcessingSession session, String content, ITextTemplatingEngineHost host, String className, String classNamespace)
Closed Feb 6, 2013 at 1:56 AM by OlegSych
Resolved in build 11.2.0.0

comments

lagear wrote Apr 4, 2014 at 9:28 PM

Hi Oleg, where is the build 11.2.0.0 for download?

I try to run in VS2012 Ultimate and throw me this error:

Error 8 A processor named 'T4Toolbox.TransformationContextProcessor' could not be found for the directive named 'TransformationContext'. The transformation will not be run. The following Exception was thrown:
System.InvalidCastException: Failed to resolve type for directive processor T4Toolbox.TransformationContextProcessor.
at Microsoft.VisualStudio.TextTemplating.VSHost.TextTemplatingService.ResolveDirectiveProcessorFromRegistry(String processorName, OrchestratorPackage orchestratorPackage)
at Microsoft.VisualStudio.TextTemplating.VSHost.TextTemplatingService.ResolveDirectiveProcessor(String processorName)
at Microsoft.VisualStudio.TextTemplating.Engine.ProcessCustomDirectives(ITextTemplatingEngineHost host, TemplateProcessingSession session, IEnumerable`1 directivesToBeProcessed) C:\USERS\MARCELO.ROMERO\APPDATA\LOCAL\MICROSOFT\VISUALSTUDIO\11.0\EXTENSIONS\D4WTXNVH.AFN\Include\T4Toolbox.tt 1 4 Miscellaneous Files