Hi, I am trying to create a custom scaffolder that will use the EnvDTE bject in T4 to do some useful stuff. However, while trying to get this.Host in my T4, I get the InvalidCastException on below line -
<#
IServiceProvider serviceProvider = (IServiceProvider)this.Host;
DTE dte = serviceProvider.GetService(typeof(DTE)) as DTE;
>
Here Host is an instance of DynamicTextTemplatingEngineHost which does not implement IServiceProvider and hence the type casting is null.
Below is the error -
error : Running transformation: System.InvalidCastException: Unable to cast transparent proxy to type 'System.IServiceProvider'
I have attached my sample project here. Visual Studio Enterprise 2015 Update 2.
TestApp.zip