Object values disappearing
-
I hope I can make sense of this question. I have three projects in the solution: a WCF service, a project with my datacontract classes in it, and a windows forms program consuming the service. If the form doesn't also reference the datacontract classes, all is normal and data is sent and received properly. But now I add a reference to the project with the datacontract classes to my form. The data appears to be sent properly - but my form gets only null references from the WCF service. The only thing I changed was adding the reference. What do I need to do to be able to get the data from my WCF service if my form knows about the datacontract classes? Thanks
Brent
-
I hope I can make sense of this question. I have three projects in the solution: a WCF service, a project with my datacontract classes in it, and a windows forms program consuming the service. If the form doesn't also reference the datacontract classes, all is normal and data is sent and received properly. But now I add a reference to the project with the datacontract classes to my form. The data appears to be sent properly - but my form gets only null references from the WCF service. The only thing I changed was adding the reference. What do I need to do to be able to get the data from my WCF service if my form knows about the datacontract classes? Thanks
Brent
dbrenth wrote:
But now I add a reference to the project with the datacontract classes to my form.
If I understand you correctly, this is your problem: The datacontract classes are generated ultimately from the ones in your service when you create the proxy classes. The are not the same classes as the one you have referenced in your dll, for one thing they will most likely have a different namespace. If you take a look at the process might be clearer Service data contract --> WSDL --> [Generated] Contract. The resultant generated contract can't be the same as the one included from the service side.You can use the service classes if you are prepared to do all the work that the generated proxy does for you (and out line of creating the Channel can be found inUsing WCF without a generated proxy, by using ChannelFactory[^]) But:
- It can be a PITA: I used this methodolgy once and the proxy was simply easier
- Unless you have a good reason for wanting to distibute the service side class it goes against the grain of the service architecture IMO
Sort of a cross between Lawrence of Arabia and Dilbert.[^]
-Or-
A Dead ringer for Kate Winslett[^] -
I hope I can make sense of this question. I have three projects in the solution: a WCF service, a project with my datacontract classes in it, and a windows forms program consuming the service. If the form doesn't also reference the datacontract classes, all is normal and data is sent and received properly. But now I add a reference to the project with the datacontract classes to my form. The data appears to be sent properly - but my form gets only null references from the WCF service. The only thing I changed was adding the reference. What do I need to do to be able to get the data from my WCF service if my form knows about the datacontract classes? Thanks
Brent
For your main project you should be adding a Service Reference to the WCF service. Once that is successfully implemented, you will have a local class library to represents the data returned to you by the server. Sometimes you have to look inside the server reference to locate that library but once you find it you can easily access the data.
Software Zen: delete this;