使用 EnvDTE.Property.set_Value 设置 ProjectItem FullPath 属性时出现问题

发布于 2024-10-05 08:41:04 字数 493 浏览 0 评论 0原文

我有一个 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

川水往事 2024-10-12 08:41:04

我认为问题在于 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:

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文