简体   繁体   English

Visual Studio 2008,WinForms设计器类型转换

[英]Visual Studio 2008, WinForms designer type conversion

Got a problem thats driving me a bit nuts here. 有一个问题使我有点生气。 I have a winforms project containing usercontrols, that use types from another project which is reference by add project. 我有一个包含用户控件的winforms项目,该项目使用来自添加项目引用的另一个项目的类型。 I have checked the references, and they are all fine, there is only one reference from the UI project to the services, and that is by adding a project reference. 我已经检查了引用,它们都很好,从UI项目到服务只有一个引用,那就是添加一个项目引用。 I can get around this problem by either deleting the resx file, or by in the designer, setting the erroring line that uses resx to null. 我可以通过删除resx文件或在设计器中将使用resx的错误行设置为null来解决此问题。 However I ship so much time doing this everytime. 但是,我每次都花很多时间这样做。 Ive googled to death and checked through here with no joy. 我已经死了,没有高兴地检查了一下。 Anyone got any pointers. 任何人都有任何指示。 Error is below with stack trace 错误低于堆栈跟踪

TIA TIA

Error: 错误:

Object of type 'NewSchool.Services.Document.IDocumentDto[]' cannot be converted to type 'NewSchool.Services.Document.IDocumentDto[]'.

Stack Trace: 堆栈跟踪:

at System.RuntimeType.CheckValue(Object value, Binder binder, CultureInfo culture, BindingFlags invokeAttr)
at System.Reflection.RtFieldInfo.InternalSetValue(Object obj, Object value, BindingFlags invokeAttr, Binder binder, CultureInfo culture, Boolean doVisibilityCheck, Boolean doCheckConsistency)
at System.Reflection.RtFieldInfo.InternalSetValue(Object obj, Object value, BindingFlags invokeAttr, Binder binder, CultureInfo culture, Boolean doVisibilityCheck)
at System.Runtime.Serialization.FormatterServices.SerializationSetValue(MemberInfo fi, Object target, Object value)
at System.Runtime.Serialization.ObjectManager.CompleteObject(ObjectHolder holder, Boolean bObjectFullyComplete)
at System.Runtime.Serialization.ObjectManager.DoNewlyRegisteredObjectFixups(ObjectHolder holder)
at System.Runtime.Serialization.ObjectManager.RegisterObject(Object obj, Int64 objectID, SerializationInfo info, Int64 idOfContainingObj, MemberInfo member, Int32[] arrayIndex)
at System.Runtime.Serialization.Formatters.Binary.ObjectReader.RegisterObject(Object obj, ParseRecord pr, ParseRecord objectPr, Boolean bIsString)
at System.Runtime.Serialization.Formatters.Binary.ObjectReader.ParseObjectEnd(ParseRecord pr)
at System.Runtime.Serialization.Formatters.Binary.ObjectReader.Parse(ParseRecord pr)
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)

The only thing that readily springs to mind is that you have some sort of circular reference. 唯一想到的就是您有某种循环参考。 Perhaps in this case that is due to the reference to the Service and the other project with classes reference. 也许在这种情况下,这是由于对服务的引用以及具有类引用的其他项目所致。

Does you project need to interact with the service project? 您的项目需要与服务项目进行交互吗?

I would bet you are exposing IDocumentDto[] as a property in some control? 我敢打赌您在某些控件中将IDocumentDto []公开为属性?

Why it happens I cannot tell you. 为什么会发生,我无法告诉你。 (I think it has something to do with the Visual Studio trying to create an instance of the interface during design time to expose it in the property grid but I am probably wrong. I am not a GUI guy and 99% of my work is in the middle tier.) (我认为这与Visual Studio试图在设计时创建接口实例以在属性网格中公开该接口有关,但我可能是错的。我不是GUI专家,我99%的工作都在中间层。)

To fix it I create actual methods (not a property) to get and set the variable. 为了解决这个问题,我创建了实际的方法(不是属性)来获取和设置变量。

It just happened to me and non of those solutions worked for me. 它只是发生在我身上,没有一种解决方案对我有用。 I finally found out the reason. 我终于找到了原因。 Designer added resx file for placing BindingSource on screen. 设计器添加了resx文件,用于在屏幕上放置BindingSource。 There was also weird resource of one control placed on the control with no value. 一个控件上放置的资源也很奇怪,没有任何价值。 After deleting those resources, it works again. 删除这些资源后,它将再次起作用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM