views:

70

answers:

1

I wrote a VSMacro (in VS2010) that parses a solution and adds try and catch statements to cpp files. It's been working fine up until now. I had to reformat my pc and reinstall VS2010 and now it crashes. Here's a snippet from the macro.

Sub Foo(ByVal file As EnvDTE.ProjectItem)
    Dim fileCM As EnvDTE.FileCodeModel
    fileCM = file.FileCodeModel
End Sub

I've checked to see if that file is a valid object, and it does point to a cpp file. But for some reason file.FileCodeModel = Nothing. Why would FileCodeModel be Nothing?

A: 

There are several scenarios in Visual Studio where a ProjectItem will not return a FileCodeModel object. For example if the ProjectItem points to a folder or a non-code file item in solution explorer.

Can you verify what the ProjectItem represents in this scenario. In particular

  • Is it pointing to a file?
  • What type of project is this in (Web, console app, etc ...)?
JaredPar
like i said in my question, the `ProjectItem` points to a cpp file.
Ernesto Rojo Jr
@Ernesto, what type of C++ project is this. Native, pure managed, C++/CLI, etc ...
JaredPar