--- In
vsnetaddin@yahoogroups.com, "noha_assem2030" <noha_assem2030@...>
wrote:
>
> i've an add-in to document classes in XML style, i'm trying to
determine
> the type of a CodeElement as follows:
>
> Dim fcmFileCodeModel As FileCodeModel =
> DTE.ActiveDocument.ProjectItem.FileCodeModel
>
> Dim editPoint As EditPoint =
> DTE.ActiveDocument.Selection.TopPoint.CreateEditPoint()
>
> Dim ceElement as CodeElement =
> editPoint.CodeElement(vsCMElement.vsCMElementProperty)
>
> on the previous line i get the error:
> editPoint.CodeElement(EnvDTE.vsCMElement.vsCMElementProperty)
> Overload resolution failed because no accessible 'CodeElement' is most
> specific for these arguments:
> 'Public Overridable ReadOnly Property CodeElement(Scope As
> EnvDTE.vsCMElement) As EnvDTE.CodeElement': Not most specific.
> 'Public Overridable ReadOnly Property CodeElement(Scope As
> EnvDTE.vsCMElement) As EnvDTE.CodeElement': Not most specific.
>
> and when i try to use the FileCodeModel object:
>
> ceElement =
>
fcmFileCodeModel.CodeElementFromPoint(DTE.ActiveDocument.Selection.Activ\
\
> ePoint, vsCMElement.vsCMElementProperty)
>
> i get the following exception:
> fcmFileCodeModel.CodeElementFromPoint(editPoint,
> vsCMElement.vsCMElementProperty) Run-time exception thrown :
> System.Runtime.InteropServices.COMException - Unspecified error
>
> And strange enough it works fine with Classes & Functions , What is
> missing??
I've found the solution in the following link:
HowTo: Get a code element at the cursor from a visual studio.net macro
or add-in <
http://www.mztools.com/articles/2006/MZ2006009.aspx>
[Non-text portions of this message have been removed]