2012-04-17 44 views
0

我在一個項目中創建一個自定義的T4指令處理器,現在我想使用的處理器在另一個項目T4模板,但我收到以下錯誤:如何在T4模板中使用自定義指令?

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

我的指令處理器類像這樣定義:

using Microsoft.VisualStudio.TextTemplating; 

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

我需要做些什麼來使定製指令工作?我遵循this documentation中的指導原則將指令處理器添加到註冊表中。我在項目的後期構建步驟中這樣做,我已經定義了我的指令處理器類,並且確保項目已構建並添加了註冊表項。

回答

1

經過一番挖掘,我發現這裏的問題。原來我使用的是舊版本的Microsoft.VisualStudio.TextTemplating.dll。我的版本是8.1.0.0,如添加引用對話框中所列。

一旦我安裝了Visual Studio 2008 SDK 1.0,我看到我有一個新版本:9.0.0.0。當我建立我的項目鏈接到新版本的.DLL時,一切都運行良好。

希望這可以幫助一些可憐的失去靈魂仍然VS2008!

相關問題