无效的Resx文件。为什么无法加载类型错误? [英] Invalid Resx file. Could not load type error why?
问题描述
我在代码上遇到设计器错误:
I'm getting designer error on code:
我愿意为以下项定义属性列表的组件:
The Component i'm willing to define a List of properties for:
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属性中,则将其添加到
I am getting the following error if i try to use the component for example on a form and add any items on the property sheet or in the component's constructor to the DescriptorsAvailable property
错误1无效的Resx文件。无法加载类型
System.Collections.Generic.List`1 [[TestProjectForProperty.Test.TypeDescriptorBase,
TestProjectForProperty,版本= 1.0.0.0,文化=中性,
PublicKeyToken = null]] ,mscorlib,Version = 4.0.0.0,Culture = neutral,
PublicKeyToken = b77a5c561934e089(在.RESX文件中使用)。
确保已将必要的引用添加到您的项目中。
线134,位置5。... \Visual Studio
2010\Projects\TestProjectForProperty\TestProjectForProperty\Form1.resx 134 5 TestProjectForProperty
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, Culture=neutral, 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 2010\Projects\TestProjectForProperty\TestProjectForProperty\Form1.resx 134 5 TestProjectForProperty
在出现此错误时,在Resx文件中有一个包含base64编码内容的数据字段。
In the Resx file there is data field with base64 encoded stuff inside when this error is present.
我一直在搜索寻求答案,但是我最好的办法是重新启动所有程序,这对我没有帮助,你们有什么建议吗?我正在使用.net 4客户端和Visual Studio 2010
I have been searching for an answer, but the best i got is to restart everything, it didn't help me, do you guys have any suggestions? I'm using .net 4 client and visual studio 2010
推荐答案
放入 MyTreeView
和 TypeDescriptorBase
类放入另一个项目并从GUI项目中引用它可以解决问题。
Put the MyTreeView
and TypeDescriptorBase
classes into another project and reference it from your GUI project will resolve the issues.
I我不确定为什么会发生此问题-我想这与序列化过程为DescriptorsAvailable属性生成base64字符串的方式有关。也许其他人可以给我们一些见识。
I'm not sure why exactly the problem occurs - I guess it has something to do with the way the serializing process is generating the base64 string for the DescriptorsAvailable Property. Maybe somebody else can give us some insight.
这篇关于无效的Resx文件。为什么无法加载类型错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!