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

ProjectItemVisual Studio には、がオブジェクトを返さないシナリオがいくつかありFileCodeModelます。たとえば、ProjectItemがソリューション エクスプローラーでフォルダーまたは非コード ファイル項目を指している場合です。

ProjectItemこのシナリオで が何を表しているか確認できますか。特に

  • ファイルを指していますか?
  • これはどのタイプのプロジェクトですか (Web、コンソール アプリなど)?
于 2010-08-25T15:17:29.607 に答える