无法识别元素<Project>下面的元素<#text> - 小众知识

无法识别元素<Project>下面的元素<#text>

2015-06-04 04:49:18 苏内容
  标签: CS
阅读:9126

今天尝试了下Microsoft Ribbon for WPF的例程
vsWPFRibbonApplication.csproj
直接打开的时候竟然显示:无法识别元素 <Project> 下面的元素 <#text>

百度一下解决方法一:
关于项目文件导入打开报:无法识别元素 <Target> 中的属性“Returns”错误解决方法
产生问题的现象:

我的项目是原来在另外一台电脑上写的,上面的环境是VS2008和VS2010,而我现在又将该项目在另外一台电脑上打开,这台电脑在没有安装VS2010时,是可以用VS2008正常打开的,当后来我安装了VS2010后,再打开该项目文件就会报:无法识别元素 <Target> 中的属性“Returns”错误解决方法,这个错误

产生问题的原因:

用记事本打开相关的项目文件就是报错的那个.csproj文件,在

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

行里面会发现,当前项目的工具版本为4.0的,出错原因就在这里

解决问题的办法:

由于是用vs2008打开的,所以只要将4.0改成3.5就解决了

若编译时还报错,则检查项目文件中是否存在

<TargetFrameworkProfile />

这一行,存在则删掉

暂时无法解决

自己查看:发现工程文件vsWPFRibbonApplication.csproj很多都是用的$运算符,去掉,可以成功读入
把源代码中的$也都去掉后,基本解决,还剩下以下问题:

错误 CS1577: 程序集生成失败 -- 发出“System.Runtime.InteropServices.GuidAttribute”特性时出错 --“UUID 格式不正确。”

编译完成 -- 1 个错误,0 个警告

解决方法一:
Incorrect UUID format in component c#
I need help with the next code, that throws the exception Error emitting 'System.Runtime.InteropServices.GuidAttribute' attribute -- 'Incorrect UUID format.'

[GuidAttribute(Discover.CLASS_DiscoverPlugin)]
public class Discover : TCustomDiscoverPlugin
{

    public const string CLASS_TenderDialogePlugin = "{CB19D13D-C194-49f1-B1A0-75B49283CFC8}";
    public const string CLASS_DiscoverPlugin = "{6111098C-B821-432d-9EC3-146BF5D1C276}";

    public override Object PluginGUIDs()
    {
        string[] classIDs = new string[1];
        classIDs[1] = CLASS_TenderDialogePlugin;
        return classIDs;
    }
}

Get rid of the braces - this compiles with no problems:

[GuidAttribute("CB19D13D-C194-49f1-B1A0-75B49283CFC8")]
It's a shame the accepted formats aren't documented, mind you :(

好像不是这个问题。。。

GUID还是使用$guid1$,好像可以生成新的UUID,不过编译还是提示UUID 格式不正确。


MSDN上:
错误消息
发出“attribute”属性时出错 --“reason”
下面的示例生成 CS0647:
// CS0647.cs
using System.Runtime.InteropServices;

[Guid("z")]   // CS0647, incorrect uuid format.
// try the following line instead
// [Guid("00000000-0000-0000-0000-000000000001")]
public class MyClass
{
   public static void Main()
   {
   }
}

扩展阅读
相关阅读
© CopyRight 2010-2021, PREDREAM.ORG, Inc.All Rights Reserved. 京ICP备13045924号-1