游子的博客
慈母手中线,游子身上衣, 临行密密缝,意恐迟迟归, 谁言寸草心,报得三春晖。 数据读取中,请稍候......
posts - 337,  comments - 546,  trackbacks - 0
错误 6 Invalid Resx file. Could not load type Vidicon.MainApp.VidiconPropertity, Vidicon.MainApp, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null which is used in the .RESX file.  Ensure that the necessary references have been added to your project. 行 133,位置 5。 F:\setup\av\视频监控\VidiconApplication\Vidicon.MainApp\VidiconPanel.resx 133 5 Vidicon.MainApp

这到底是个什么错误呢?关掉VS,重开,就好了。
今天关掉重开也不行了。
连微软也没有解决方案啊:http://connect.microsoft.com/VisualStudio/feedback/details/113060/invalid-resx-file-could-not-load-type


这里有一篇介绍ResX文件的。

ResX File References

Both versions of the .NET Framework allow files such as bitmaps to be included in resources. These files are included through two methods: file embedding and file referencing. Both versions of the framework support both methods. The difference between the two methods lies solely in the packaging of the original resource source. When a file is embedded in a resource, the file's complete data stream is copied from the original file into the resx file, and the original file is no longer needed. When a file is referenced in a resource, the resource simply contains a link to the original file and both files are needed. The Visual Studio 2005 Resource Editor uses file references to add files to a resource. The Visual Studio 2003 Resource Editor has no direct support for adding files to a resource, so the method chosen depends on the approach that you take (see the "Adding Images and Files in Visual Studio 2003" section of Chapter 3, "An Introduction to Internationalization"). The following resource entry represents a bitmap that has been embedded in a .NET Framework 1.1 resx file:

<data name="NationalFlag" type="System.Drawing.Bitmap,
System.Drawing, Version=1.0.5000.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a" mimetype="application/x-
microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4
c6QAAAARnQU1BAACxjwv8YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAH
UwAADqYAAAOpgAABdwnLpRPAAAAMtJREFUOE+lks0NwjAMhR8zeSdPwaFrd
AFG4YDcK10CifbMwTwnVVvET1Jq6ZOjKHmxn3MQbR1dB0BIxLJu0zr4ESIU
gDqErDPXBimCENDWXDWzFvKKoIB6EJcjs5W5EhNWUCAJAE2+FHlqJfb9MRR
JLZwug9vNU9YwdRI1pQ8FcgVrUiVsi0J+bIosFZi7kVmQIjUxm7iMMPshFS
OMMaPv+9eHwrgNgTSmytc+nYO1NIsf6V9wv56Ls/72H8Zx9P0tvJm4wcA4u
ruCJ1wJmJQKMPjaAAAAAElFTkSuQmCC
</value>
</data>

The following resource entry represents a bitmap that has been referenced in a .NET Framework 2.0 resx file:

<data name="NationalFlag"
type="System.Resources.ResXfileref, System.Windows.Forms">
<value>ResourcesNationalFlag.gif;System.Drawing.Bitmap,
System.Drawing, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a
</value>
</data>

Notice that the type is no longer a System.Drawing.Bitmap, but a System.Resources.ResXfileref. In the value element, you can see the file reference (ResourcesNationalFlag.gif) and also the type of the contents of the file (System.Drawing.Bitmap). From the point of view of the resource assembly that gets compiled from these resources, there is no difference between resources that are referenced and those that are embedded because the file references are resolved before the assembly is generated, and the resulting assembly contains the complete "embedded" definition of the resource (so the referenced files do not need to be deployed and are not required at runtime). From the point of view of version control, the benefit of using file references is that you get better granularity of resource versioning. From the point of view of code that processes resx files, the distinction between referenced and embedded is important. Recall our first code snippet, which read a resx file and added the contents of each DictionaryEntry into a ListBox. This code will most likely fail if it processes a resx file with file references. The ArgumentException that occurs reports the problem:

ResX file Could not find a part of the path
'C:BooksI18NTestsVS2005WindowsApplication1inDebug
ResourcesNationalFlag.gif'. Line 329, position 5. cannot be parsed.

Recall that the file reference is to "ResourcesNationalFlag.gif"i.e., a relative reference, not an absolute reference. The path is relative to the executing assembly, so it looks in the WindowsApplication1inDebugResources folder and not the WindowsApplication1Resources folder, where the files are. If you are using the .NET Framework 1.1, the simplest solution is to use absolute file references. If you are using the .NET Framework 2.0, you can tell the ResXResourceReader where to find the resource files using the ResXResourceReader.BasePath property:

ResXResourceReader reader =
new ResXResourceReader("Form1Resources.resx");
reader.BasePath = @"....";

Alternatively, a more generic solution to the same problem is to simply set the BasePath to the same folder as the resx file that the ResXResourceReader is processing:

string fileName = @"C:AppsWindowsApplication1Form1Resources.resx";
ResXResourceReader reader = new ResXResourceReader(fileName);
reader.BasePath = Path.GetDirectoryName(fileName);

The new support for file references that was added in the Visual Studio 2005 Resource Editor has an implication for code that processes resx files. As we have already seen, the code that reads entries using a ResXResourceReader works well in both the .NET Framework 1.1 and 2.0, as long as resources are embedded or absolute file paths are used. The Visual Studio 2005 Resource Editor, however, defaults to file references (using relative paths), so code that processes resx files that worked under the .NET Framework 1.1 will mostly likely fail when processing the .NET Framework 2.0 resx files (because the file references are relative) and must be updated to set the ResXResourceReader's BasePath property

posted on 2010-03-17 23:01 游子 阅读(938) 评论(2)  编辑 收藏 引用 所属分类: 软件

FeedBack:
# re: 该死的Resx
2010-03-18 00:39 | me
终于整好了。原来不是resx文件有问题,是同名的xx.Designer.cs文件出了问题。创建控件的代码不知道怎么被删了?----肯定不是我删除的,也许IDE工具有问题。
我是通过比较以前的工程发现的,所以备份好代码是非常重要的。
可以睡觉了。  回复  更多评论
  
# re: 该死的Resx
2010-03-19 12:26 | 罗莱家纺
案件说的话胜多负少的  回复  更多评论
  
只有注册用户登录后才能发表评论。

欢迎大家扔鸡蛋!送鲜花!

博客可以收入过千吗?

<2006年5月>
日一二三四五六3012345678910111213
14151617181920212223242526272829303112345678910

常用链接

留言簿(8)

随笔分类(314)

随笔档案(337)

文章分类(7)

文章档案(10)

相册

收藏夹(1)

其它

友情链接

数字电视

生活、旅游

自己的链接

计算机

搜索

  •  

积分与排名

  • 积分 - 403683
  • 排名 - 9

最新评论

阅读排行榜

评论排行榜