FishBasketGordo
FishBasketGordo

Reputation: 23142

How to use custom directive in a T4 template?

I created a custom T4 directive processor in one project, and now I want to use the processor in a T4 template in another project, but I'm receiving the following error:

The type 'MyNamespace.MyCustomDirectiveProcessor' of the directive processor named 'MyCustomDirectiveProcessor' does not derive from Microsoft.VisualStudio.TextTemplating.DirectiveProcessor. The transformation will not be run.

My directive processor class is defined like this:

using Microsoft.VisualStudio.TextTemplating;

namespace MyNamespace
{
    public class MyCustomDirectiveProcessor : DirectiveProcessor
    {
        // etc.
    }
}

What do I need to do to make the custom directive work? I've followed the guidelines in this documentation to add the directive processor to the registry. I do so in the post build step of the project where I've defined my directive processor class, and I've made sure that the project is built and the registry keys are added.

Upvotes: 0

Views: 284

Answers (1)

FishBasketGordo
FishBasketGordo

Reputation: 23142

After a bit of digging around, I discovered the issue here. Turns out I was using an older version of Microsoft.VisualStudio.TextTemplating.dll. The version I had was 8.1.0.0, as listed in the Add Reference dialog.

Once I installed the Visual Studio 2008 SDK 1.0, I saw that I had a new version: 9.0.0.0. When I built my project linking to the new version of the .DLL, everything worked swimmingly.

Hope this helps some poor lost soul still on VS2008!

Upvotes: 1

Related Questions