为什么 EnvDTE.ProjectItem.FileCodeModel = Nothing?
我编写了一个 VMacro(在 VS2010 中),它解析解决方案并向 cpp 文件添加 try 和 catch 语句。到目前为止一直运行良好。我不得不重新格式化我的电脑并重新安装 VS2010,现在它崩溃了。这是宏的一个片段。
Sub Foo(ByVal file As EnvDTE.ProjectItem)
Dim fileCM As EnvDTE.FileCodeModel
fileCM = file.FileCodeModel
End Sub
我已检查该文件是否是有效对象,它确实指向 cpp 文件。但由于某种原因 file.FileCodeModel = Nothing。为什么 FileCodeModel 会什么都没有?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在 Visual Studio 中的多种情况下,
ProjectItem
不会返回FileCodeModel
对象。例如,如果ProjectItem
指向解决方案资源管理器中的文件夹或非代码文件项。您能否验证
ProjectItem
在这种情况下代表什么?特别There are several scenarios in Visual Studio where a
ProjectItem
will not return aFileCodeModel
object. For example if theProjectItem
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通常,当项目无法编译时会发生这种情况。您需要首先尝试构建解决方案。
Usually, it happens when the project is not compilable. You need to try to build the solution first.