Skip to content

DynamicTextTemplatingEngineHost does not implement IServiceProvider #3

Description

@pravinchandankhede

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions