3

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

hhravn
  • 1,701
  • 1
  • 10
  • 22
  • any chance that there are multiple definitions of `Sbsys.Services.HostService.DokumentBoks.DKALWSAfsendService.MaterialeType` in the solution? maybe multiple web-service-references with similar types and namespaces? maybe one in a referenced dll, one locally? – Marc Gravell Sep 20 '11 at 07:03
  • @MarcGravell: sadly not. The project is quite isolated, with a single servicereference. Bonus info: When using the production service everything works as intended. – hhravn Sep 20 '11 at 07:11
  • when you say "the production service" - how is that configured? is that the same *service*, but with a different value in the config file (or alternative, changing the url at runtime on the channel) - or do you have a separate service reference for dev/prod? – Marc Gravell Sep 20 '11 at 07:22
  • @MarcGravell: We have a utility method that builds the service client, and simply takes an url as the only parameter. So, same service reference, different url. In the meanwhile i build a second project, using the same utility method to build a client. Works without a hitch.. – hhravn Sep 20 '11 at 07:30

3 Answers3

3

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.

hhravn
  • 1,701
  • 1
  • 10
  • 22
2

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.

VdesmedT
  • 9,037
  • 3
  • 34
  • 50
0

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.

Community
  • 1
  • 1
Shital Shah
  • 63,284
  • 17
  • 238
  • 185