1
コーダー、私はVS2010用のアドインを開発しており、コードエディタで選択したテキストを取得しようとしています。今のところ、私は多くのWebページを検索しており、あなたのすべてが使用しているようですDTE.ActiveDocumentこれは私のコードにエラーを引き起こします。私はエディタで選択されたテキストを返すと仮定するメソッドの2つのバージョンを書いたが、私は何度も何度も同じエラーが発生する:非静的なフィールド、メソッド、または財産法の「EnvDTE._DTE.ActiveDocument.get」ここ としている私の二つのバージョン(のみ関連するコードがあるshowen):VS 2010 addin:エディタで選択したテキストを取得
using EnvDTE;
private string getSelectedText_V1()
{
string selectedText = string.Empty;
/*PROBLEM HERE: An object reference is required for the non-static field, method, or property 'EnvDTE._DTE.ActiveDocument.get'*/
Document doc = DTE.ActiveDocument;
return selectedText;
}
private string getSelectedText_V2()
{
string selectedText = string.Empty;
/*PROBLEM HERE: An object reference is required for the non-static field, method, or property 'EnvDTE._DTE.ActiveDocument.get'*/
EnvDTE.TextSelection TxtSelection = DTE.ActiveDocument.Selection;
return selectedText;
}
は、私は私のコードで間違っていたかを把握助けてください?
もhttp://channel9.msdn.com/blogs/vsipmarketing/vsx101-an-introduction-to-visual-studio-2010-extensibility – ealshabaan
作品見ますありがとう! PS:小さな構文エラーがあります。「as」の前に括弧がありません。それはあまりにも小さな変更なので、私はそれを編集することはできません。 –