hhravn
hhravn

Reputation: 1741

Cannot convert to same type in WCF

I am building a test-stub for a webservice, implementing the interface retrieved from the production webservice using svcutil. When calling a method on the stub i get the exception;

Object of type 
'Sbsys.Services.HostService.DokumentBoks.DKALWSAfsendService.MaterialeType[]' 
cannot be converted to type
'Sbsys.Services.HostService.DokumentBoks.DKALWSAfsendService.MaterialeType[]'.

where 'Sbsys.Services.HostService.DokumentBoks' is the namespace of the consuming client, and 'DKALWSAfsendService' is the namespace containing the generated proxy classes for the service.

Any ideas on whats going on?

Bonus info: When using the production service everything works as intended

Upvotes: 3

Views: 2499

Answers (3)

Shital Shah
Shital Shah

Reputation: 68708

Sometime this error occurs because of Generate Serializable Assembly option in Project properties (especially if you are using per-generated serialization assembly using sgen). Try setting this option in Project properties to Off and see if it works. After you turn this option off you will need to per-generate your assembly using sgen. There is some good discussion and background thread in this Q&A for this.

Upvotes: 0

hhravn
hhravn

Reputation: 1741

Solved: I had a suspicion that it might be a versioning problem, and moved my servicereference to an isolated project, containing nothing else. Referenced this from both the consuming client and the webservice stub, hoping that this would solve any problems with building multiple times or whatever. Presto. Problem gone.

Upvotes: 3

VdesmedT
VdesmedT

Reputation: 9113

Any chance that the wsdl/contract in prod is different from the one you call against ? If the proxy has been generated against the prod and use on another instance of the service with a different contract, you might have that kind of weird message.

Upvotes: 2

Related Questions