Search code examples
vb.netwcfweb-serviceswcf-data-services

Value of type 'DOOD.ServiceReference1.Search' cannot be converted to 'DOOD.Search'


After adding service reference in web application it created reference.vb class with namespace
service reference1 and when i tried to assign

i created a class same as what web service is returning and assigning the object

Dim obj1 As Search

Dim obj1 = client.Search(date, name)

here i am getting Value of type 'DOOD.ServiceReference1.Search' cannot be converted to 'DOOD.Search'

how to resolve this ...


Solution

  • Once worked at a place where we had an app where you had to go into the Reference.vb file and remove the declaration of the classes (in your case, specifically class Search) entirely from the file -- every time you regenerated the service reference. (generally when you changed the interface to any of the functions).

    The service would then return just your DOOD.Search and no typecasting issues.

    The alternative is that you have to write an adapter to convert between the two.