使用 EnvDTE.Property.set_Value 设置 ProjectItem FullPath 属性时出现问题
我有一个 Visual Studio 项目向导,它尝试配置 VC# 项目以覆盖模板中选定文件的 FullPath 属性。
中使用
以下代码在函数public void ProjectFinishedGenerate(Project project)
string path = "some file name";
project.ProjectItems.Item("some file").Properties.Item("FullPath").Value = path;
System.Reflection.TargetParameterCountException:参数数量无效。 (HRESULT 异常:0x8002000E (DISP_E_BADPARAMCOUNT)) 在 EnvDTE.Property.set_Value(Object lppvReturn)
我知道我有一个有效的 ProjectItem 对象,因为我可以显示原始值。
I have a Visual Studio Project Wizard that attempts to configure a VC# project to override the FullPath property for selected files from the template.
The following code is used from within function
public void ProjectFinishedGenerating(Project project)
string path = "some file name";
project.ProjectItems.Item("some file").Properties.Item("FullPath").Value = path;
System.Reflection.TargetParameterCountException: Invalid number of parameters. (Exception from HRESULT: 0x8002000E (DISP_E_BADPARAMCOUNT))
at EnvDTE.Property.set_Value(Object lppvReturn)
I know that I have a valid ProjectItem object because I can display the original value.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为问题在于 FullPath 属性是只读的。您可以通过查看 MSDN 中的定义来弄清楚这一点 - http: //msdn.microsoft.com/en-us/library/vslangproj.fileproperties.fullpath.aspx - 它只定义了一个 getter。
要调用 set_Value,您需要更新具有公共 setter 的属性。根据 FileProperties 界面上记录的属性,唯一可设置的属性是:
I think the problem is that the FullPath property is read-only. You can figure this out by looking at the definition in MSDN - http://msdn.microsoft.com/en-us/library/vslangproj.fileproperties.fullpath.aspx - it only has a getter defined.
To call set_Value, you need be updating a property that has a public setter. According to the properties documented on the FileProperties interface, the only settable properties are: