GUID应包含32位与4破折号(XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX)在VS扩展性演练 [英] Guid should contain 32 digits with 4 dashes (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx) in VS Extensibility walkthrough

查看:9097
本文介绍了GUID应包含32位与4破折号(XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX)在VS扩展性演练的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的演练:第1部分 - 创建基本项目系统正是因为从网站写的 http://msdn.microsoft.com/en-us/library/cc512961.aspx ,并在管理软件包框架项目正是因为从 http://mpfproj11.codeplex.com/ 下载。我已经测试在Visual Studio 2013在多个开发机器的演练2010年和2012利用各自的SDK的我在Visual Studio中测试了这一点。 。同样的问题,按照提供自己在每个测试

I am using the Walkthrough: Part 1 - Creating a Basic Project System exactly as written from the website http://msdn.microsoft.com/en-us/library/cc512961.aspx and the Managed Package Framework for Projects exactly as downloaded from http://mpfproj11.codeplex.com/. I have tested the walkthrough on multiple development machines in Visual Studio 2013. I also tested this in Visual Studio 2010 and 2012 using their respective SDK’s. The same issues to follow presented themselves in each of the tests.

问题:我收到的类型System.FormatException的一个与异常异常发生在mscorlib.dll但在用户代码的附加信息的处理:GUID应包含32位与4破折号(XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX)在ProjectNode类方法:

Issue: I am receiving the exception- An exception of type 'System.FormatException' occurred in mscorlib.dll but was not handled in user code Additional information: Guid should contain 32 digits with 4 dashes (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx) in the ProjectNode class method:

private void SetProjectGuidFromProjectFile()
        {
            string projectGuid = this.GetProjectProperty(ProjectFileConstants.ProjectGuid);
            if (String.IsNullOrEmpty(projectGuid))
            {
                this.projectIdGuid = Guid.NewGuid();
            }
            else
            {
                Guid guid = new Guid(projectGuid);
                if (guid != this.projectIdGuid)
                {
                    this.projectIdGuid = guid;
                }
            }
        }

在该行的Guid GUID =新的GUID(projectGuid);

projectGuid将返回字符串$ GUID1 $,这是从< ProjectGuid> $ GUID1 $< / ProjectGuid> 在SimpleProject.myproj

projectGuid is returning the string "$guid1$" which is from <ProjectGuid>$guid1$</ProjectGuid> in SimpleProject.myproj.

在的Load方法破发点。 ProjectNode类说明

Break points in the Load method of the ProjectNode class shows that

this.projectIdGuid = Guid.NewGuid();



返回一个新的GUID,如{6d4b8668-51ca-40eb-b013-9e7f96b82b68}。

returns a new guid such as {6d4b8668-51ca-40eb-b013-9e7f96b82b68}.

在ProjectNode类的Reload方法方法 this.SetProjectGuidFromProjectFile()被激发,然后exeption是抛出如上所示。如果我拿出< ProjectGuid> $ GUID1 $< / ProjectGuid> 在SimpleProject.myproj,我通过对无一例外的应用程序中获取,但你将有关联的GUID该应用程序并收到一个错误,如果尝试访问新创建的应用程序的属性页。 .myproj可能无法正确注册?我花了一个星期研究通过各种博客和论坛这个话题。

In the Reload method of the ProjectNode class the method this.SetProjectGuidFromProjectFile() is fired and then the exeption is thrown as shown above. If I take out <ProjectGuid>$guid1$</ProjectGuid> in SimpleProject.myproj, I get through to the application without exception but you will have no guid associated with the application and will receive an error if an attempt to access the properties page of the newly created application. .myproj may not be registering correctly? I have spent a week researching this topic through various blogs and forums.

推荐答案

这个问题来自于事实,强积金(这是代码严重蹩脚的一块 - 不幸的是,它是唯一完全成熟的样本可用)实现了一个自定义模板参数,更换过程中(这里介绍一个Visual Studio,具体过程:的 http://msdn.microsoft.com/en-us/library/eehb4faa.aspx )只支持更换所有项目(子)项目,但不为项目项目本身。所以,你不能使用$ $ GUID1或者在xxxx.myproj文件中的任何其他$ $啄

The problem comes from the fact the MPF (which is a serious crappy piece of code - unfortunately, it's the only full-blown sample available) implements a custom template parameter replacement process (a Visual Studio-specific process described here: http://msdn.microsoft.com/en-us/library/eehb4faa.aspx) that only supports replacement for all project (sub) items, but not for the project item itself. So, you cannot use $guid1$ or any other $thingy$ in the xxxx.myproj file.

当你发现了,最简单的方法是只删除此$ GUID1 $参数,让它空白,为强积金确实支持空白的:

As you found out, the easiest way is to just remove this $guid1$ parameter, and let it blank, as the MPF does support a blank one:

<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    ...
    <ProjectGuid></ProjectGuid>
    ...
  </PropertyGroup>
  ...
</Project>

现在,出乎你的信念:)这工作正常。这台ProjectIDGuid ProjectNode的属性。

Now, contrary to your belief :) this works fine. This sets the ProjectIDGuid ProjectNode's property.

属性页你还后是一个完全不同的野兽。为了简化,Visual Studio将查询您的层次结构的 __VSHPROPID2.VSHPROPID_PropertyPagesCLSIDList 财产。默认情况下,强积金实现它是这样的:

The property page you're also after is a totally different beast. To simplify, Visual Studio will query your hierarchy for the __VSHPROPID2.VSHPROPID_PropertyPagesCLSIDList property. By default, the MPF implements it like this:

    /// <summary>
    /// List of Guids of the config independent property pages. It is called by the GetProperty for VSHPROPID_PropertyPagesCLSIDList property.
    /// </summary>
    /// <returns></returns>
    protected virtual Guid[] GetConfigurationIndependentPropertyPages()
    {
        return new Guid[] { Guid.Empty };
    }



Guid.Empty是一个糟糕的选择(他们可能只是发一个空数组) ,因为它会引发以下错误,是很难与标准的空GUID我们不知道它从何而来诊断:

Guid.Empty is a poor choice (they could just send an empty array), because it will raise the following error which is hard to diagnose with the standard empty guid we don't known where it comes from:

所以,你需要做的是覆盖GetConfigurationIndependentPropertyPages,给它的另一个GUID,它对应于从SettingsPage等衍生但这是另一个故事的一类。

So, what you need to do is override GetConfigurationIndependentPropertyPages and give it another Guid that correspond to a class that derive from SettingsPage, etc. but that's another story.

这篇关于GUID应包含32位与4破折号(XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX)在VS扩展性演练的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆