Winforms设计师无法找到项目组件?

时间:2010-09-20 13:14:14

标签: c# winforms serialization build-error

我有一个win形式的Usercontrol突然无法构建,出现此错误:

编辑 - 忘了提,项目的名称是Datatesting,它不是外部参考!

Error   1   Invalid Resx file. Could not load type DataTesting.TableColumn, DataTesting, 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. Line 129, position 5.    C:\Team Explorer\DataTesting\TableColumnListEditor.resx 129 5   DataTesting

导航到错误将打开TableColumnListEditor.resx的此部分:

  <data name="tableColumnEditor1.EditingTableColumn" mimetype="application/x-microsoft.net.object.binary.base64">
    <value>
      AAEAAAD/////AQAAAAAAAAAMAgAAAEJEYXRhVGVzdGluZywgVmVyc2lvbj0xLjAuMC4wLCBDdWx0dXJl
      PW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPW51bGwFAQAAABdEYXRhVGVzdGluZy5UYWJsZUNvbHVtbgYA
      AAAVPE5hbWU+a19fQmFja2luZ0ZpZWxkGDxTcWxUeXBlPmtfX0JhY2tpbmdGaWVsZBs8RmlsbE1ldGhv
      ZD5rX19CYWNraW5nRmllbGQaPFByZWNpc2lvbj5rX19CYWNraW5nRmllbGQbPElzSWRlbnRpdHk+a19f
      QmFja2luZ0ZpZWxkGzxJc051bGxhYmxlPmtfX0JhY2tpbmdGaWVsZAEBAQAAAAUBAQIAAAAGAwAAAAAG
      BAAAAAAGBQAAAAABMAAACw==
    </value>
  </data>

最后,当我尝试打开控件的设计器时,我收到此错误:

    To prevent possible data loss before loading the designer, the following errors must be resolved:   



    1 Error   

  Ignore and Continue   
    Why am I seeing this page?   

   Unable to find assembly 'DataTesting, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.       

Instances of this error (1)  

1.   Show Call Stack  

at System.Runtime.Serialization.Formatters.Binary.BinaryAssemblyInfo.GetAssembly()
at System.Runtime.Serialization.Formatters.Binary.ObjectReader.GetType(BinaryAssemblyInfo assemblyInfo, String name)
at System.Runtime.Serialization.Formatters.Binary.ObjectMap..ctor(String objectName, String[] memberNames, BinaryTypeEnum[] binaryTypeEnumA, Object[] typeInformationA, Int32[] memberAssemIds, ObjectReader objectReader, Int32 objectId, BinaryAssemblyInfo assemblyInfo, SizedArray assemIdToAssemblyTable)
at System.Runtime.Serialization.Formatters.Binary.ObjectMap.Create(String name, String[] memberNames, BinaryTypeEnum[] binaryTypeEnumA, Object[] typeInformationA, Int32[] memberAssemIds, ObjectReader objectReader, Int32 objectId, BinaryAssemblyInfo assemblyInfo, SizedArray assemIdToAssemblyTable)
at System.Runtime.Serialization.Formatters.Binary.__BinaryParser.ReadObjectWithMapTyped(BinaryObjectWithMapTyped record)
at System.Runtime.Serialization.Formatters.Binary.__BinaryParser.ReadObjectWithMapTyped(BinaryHeaderEnum binaryHeaderEnum)
at System.Runtime.Serialization.Formatters.Binary.__BinaryParser.Run()
at System.Runtime.Serialization.Formatters.Binary.ObjectReader.Deserialize(HeaderHandler handler, __BinaryParser serParser, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage)
at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream serializationStream, HeaderHandler handler, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage)
at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream serializationStream)
at System.Resources.ResXDataNode.GenerateObjectFromDataNodeInfo(DataNodeInfo dataNodeInfo, ITypeResolutionService typeResolver)
at System.Resources.ResXDataNode.GetValue(ITypeResolutionService typeResolver)
at System.Resources.ResXResourceReader.ParseDataNode(XmlTextReader reader, Boolean isMetaData)
at System.Resources.ResXResourceReader.ParseXml(XmlTextReader reader)  

Help with this error  

MSDN Help   


Forum posts about this error  

Search the MSDN Forums for posts related to this error   

这个表格已经工作了很长时间了,我不知道它为什么会突然断开,或者如何纠正这个问题。

之前是否有其他人看过这个并且可能知道如何解决这个问题?

1 个答案:

答案 0 :(得分:3)

您设法以某种方式创建了一个循环项目引用。当从base64转换为字节时,资源值看起来大致如此:

00000000:  00 01 00 00 00 FF FF FF │ FF 01 00 00 00 00 00 00           
00000010:  00 0C 02 00 00 00 42 44 │ 61 74 61 54 65 73 74 69       BDataTesti
00000020:  6E 67 2C 20 56 65 72 73 │ 69 6F 6E 3D 31 2E 30 2E   ng, Version=1.0.
00000030:  30 2E 30 2C 20 43 75 6C │ 74 75 72 65 3D 6E 65 75   0.0, Culture=neu
00000040:  74 72 61 6C 2C 20 50 75 │ 62 6C 69 63 4B 65 79 54   tral, PublicKeyT
00000050:  6F 6B 65 6E 3D 6E 75 6C │ 6C 05 01 00 00 00 17 44   oken=null   D
00000060:  61 74 61 54 65 73 74 69 │ 6E 67 2E 54 61 62 6C 65   ataTesting.Table
00000070:  43 6F 6C 75 6D 6E 06 00 │ 00 00 15 3C 4E 61 6D 65   Column   <Name
00000080:  3E 6B 5F 5F 42 61 63 6B │ 69 6E 67 46 69 65 6C 64   >k__BackingField
00000090:  18 3C 53 71 6C 54 79 70 │ 65 3E 6B 5F 5F 42 61 63   <SqlType>k__Bac
000000A0:  6B 69 6E 67 46 69 65 6C │ 64 1B 3C 46 69 6C 6C 4D   kingField<FillM
000000B0:  65 74 68 6F 64 3E 6B 5F │ 5F 42 61 63 6B 69 6E 67   ethod>k__Backing
000000C0:  46 69 65 6C 64 1A 3C 50 │ 72 65 63 69 73 69 6F 6E   Field<Precision
000000D0:  3E 6B 5F 5F 42 61 63 6B │ 69 6E 67 46 69 65 6C 64   >k__BackingField
000000E0:  1B 3C 49 73 49 64 65 6E │ 74 69 74 79 3E 6B 5F 5F   <IsIdentity>k__
000000F0:  42 61 63 6B 69 6E 67 46 │ 69 65 6C 64 1B 3C 49 73   BackingField<Is
00000100:  4E 75 6C 6C 61 62 6C 65 │ 3E 6B 5F 5F 42 61 63 6B   Nullable>k__Back
00000110:  69 6E 67 46 69 65 6C 64 │ 01 01 01 00 00 00 05 01   ingField   
00000120:  01 02 00 00 00 06 03 00 │ 00 00 00 06 04 00 00 00          
00000130:  00 06 05 00 00 00 00 01 │ 30 00 00 0B                    0   

这是BinaryFormatter生成的数据,请注意它是引用DataTesting程序集,即您尝试编译的程序集。由于DataTesting.dll将在您编辑项目时存在,因此确实可以暂时检测不到。直到你做一个干净的构建,DLL不再可用。 KABOOM。

首先不知道资源实际意味着什么或者如何将其纳入资源。但是你需要将这里存储的任何类型旋转到另一个组件中,以便它可以单独构建。通过手动编辑.resx文件并删除资源,可以从此错误中恢复,而不是从SCCS恢复早期版本。