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?

4

2 回答 2

0

通常,它发生在项目不可编译时。您需要先尝试构建解决方案。

于 2011-07-22T06:53:59.763 回答
0

在 Visual Studio 中有几种情况 aProjectItem不会返回FileCodeModel对象。例如,如果ProjectItem指向解决方案资源管理器中的文件夹或非代码文件项。

你能验证ProjectItem在这种情况下代表什么吗?尤其是

  • 它指向一个文件吗?
  • 这是什么类型的项目(Web、控制台应用程序等)?
于 2010-08-25T15:17:29.607 回答