views:

148

answers:

2

Hi

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. 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. 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. 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

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) 
A: 

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?

ChrisBD
Thanks for the answer, I have checked the references and found no circularity, indeed I believe it wouldnt build if this was the case.
A: 

I would bet you are exposing IDocumentDto[] as a property in some control?

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.)

To fix it I create actual methods (not a property) to get and set the variable.

ElGringoGrande
Thanks for the answer. You are right, sorry I should have said, that this property is exposed from a control, and that visual studio is trying to create a value in the designer, even though I have put the browsable false attribute to indicate it shouldnt show up in the property window. I guess I can use methods to access these things, but it does look a bit like a Visual Studio bug