2012-09-26 31 views
1

我一直在試圖讓一個簡單的視覺工作室添加工作。我只想在保存文檔時在文件上運行一個函數,但由於某種原因,事件不能解決網站問題。它在正常項目中按預期工作。爲什麼DocumentSaved事件沒有針對網站解決方案開火?

這是到目前爲止我的代碼:

DocumentEvents docEvents; 
    Events events; 

    public void OnConnection(object application, ext_ConnectMode connectMode, object addInInst, ref Array custom) 
    { 
     _applicationObject = (DTE2)application; 
     _addInInstance = (AddIn)addInInst; 

     events = _applicationObject.Events; 
     docEvents = events.DocumentEvents; 

     docEvents.DocumentSaved += new _dispDocumentEvents_DocumentSavedEventHandler(docEvents_DocumentSaved); 

    } 

    void docEvents_DocumentSaved(Document document) 
    { 
     //do something here (doesn't reach this) 
    } 

任何幫助,將不勝感激,甚至是一個指針,它指向DocumentSaved事件正在網站解決方案的簡單示例項目。

編輯:我使用Visual Studio 2010

回答

0

看這個(更新):

https://gordon-breuer.de/unknown/2010/08/19/visual-studio-2010-extension-unicode-converter-1-0-with-tutorial.html

看來,你必須註冊您的加載ID爲處理某些文件類型。

+2

Lone鏈接[被認爲是一個很差的答案](http://stackoverflow.com/faq#deletion),因爲它本身毫無意義,並且目標資源不能保證在將來活着。 [這將是最好的](http://meta.stackexchange.com/q/8259)在這裏包括答案的基本部分,並提供鏈接供參考。 – j0k

+2

此鏈接已死亡。 –

相關問題