加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

c# – 无效的Resx文件.无法加载类型错误为什么?

发布时间:2020-12-16 00:10:07 所属栏目:百科 来源:网络整理
导读:我在代码上遇到设计器错误: 组件我愿意为以下内容定义属性列表: using System.Collections.Generic;using System.ComponentModel;using System.Windows.Forms;namespace TestProjectForProperty.Test{ public class MyTreeView : TreeView { private ListT
我在代码上遇到设计器错误:

组件我愿意为以下内容定义属性列表:

using System.Collections.Generic;
using System.ComponentModel;
using System.Windows.Forms;

namespace TestProjectForProperty.Test
{
    public class MyTreeView : TreeView
    {
        private List<TypeDescriptorBase> _descriptorsAvailable = new List<TypeDescriptorBase>();

        [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
        public List<TypeDescriptorBase> DescriptorsAvailable
        {
            get { return _descriptorsAvailable; }
            set { _descriptorsAvailable = value; }
        }
    }
}

描述符本身:

using System;

namespace TestProjectForProperty.Test
{
    [Serializable]
    public class TypeDescriptorBase
    {
        public string Name { get; set; }

        public override string ToString()
        {
            return Name;
        }
    }
}

如果我尝试在表单上使用组件并将属性表或组件的构造函数中的任何项添加到DescriptorsAvailable属性,我会收到以下错误

Error 1 Invalid Resx file. Could not load type
System.Collections.Generic.List`1[[TestProjectForProperty.Test.TypeDescriptorBase,
TestProjectForProperty,Version=1.0.0.0,Culture=neutral,
PublicKeyToken=null]],mscorlib,Version=4.0.0.0,
PublicKeyToken=b77a5c561934e089 which is used in the .RESX file.
Ensure that the necessary references have been added to your project.
Line 134,position 5. …visual studio
2010ProjectsTestProjectForPropertyTestProjectForPropertyForm1.resx 134 5 TestProjectForProperty

在Resx文件中,当出现此错误时,内部存在带有base64编码内容的数据字段.

我一直在寻找答案,但我得到的最好的是重新启动一切,它没有帮助我,你们有什么建议吗?我正在使用.net 4客户端和visual studio 2010

解决方法

将MyTreeView和TypeDescriptorBase类放入另一个项目中,并从GUI项目中引用它将解决问题.

我不确定为什么会出现问题 – 我猜这与序列化过程为DescriptorsAvailable属性生成base64字符串的方式有关.也许其他人可以给我们一些见解.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读