Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. DLL and Web Service Problem

DLL and Web Service Problem

Scheduled Pinned Locked Moved C#
helpquestiontutorial
5 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    Phoen25
    wrote on last edited by
    #1

    Hello, I have a problem and may be you can help me. I've a DLL in a WS and the same DLL in a winform. I need to invoke a WS method that return for example a Person object, from the winform. The problem is that it can't convert the WS.Person to the DLL.Person. How can I convert that type? I try to cast but I still the errors. Thanks a lot !!

    V 1 Reply Last reply
    0
    • P Phoen25

      Hello, I have a problem and may be you can help me. I've a DLL in a WS and the same DLL in a winform. I need to invoke a WS method that return for example a Person object, from the winform. The problem is that it can't convert the WS.Person to the DLL.Person. How can I convert that type? I try to cast but I still the errors. Thanks a lot !!

      V Offline
      V Offline
      Vitaliy Tsvayer
      wrote on last edited by
      #2

      What error do you get?

      Vitaliy Tsvayer Tikle

      P 1 Reply Last reply
      0
      • V Vitaliy Tsvayer

        What error do you get?

        Vitaliy Tsvayer Tikle

        P Offline
        P Offline
        Phoen25
        wrote on last edited by
        #3

        The error is Cannot convert the type WS.Person to Dll.Person

        P V 2 Replies Last reply
        0
        • P Phoen25

          The error is Cannot convert the type WS.Person to Dll.Person

          P Offline
          P Offline
          Phoen25
          wrote on last edited by
          #4

          Any idea?

          1 Reply Last reply
          0
          • P Phoen25

            The error is Cannot convert the type WS.Person to Dll.Person

            V Offline
            V Offline
            Vitaliy Tsvayer
            wrote on last edited by
            #5

            Well, first let me explain the reason of this problem. When you add WebReference to the WebService, proxy class is created with all the types that come from WSDL(generated by ASP.NET for your WebService). BUT, although generated classes have the same fields as your original class from DLL, they are abolutely different entities, that is why you cannot cast from WS.Person to DLL.person for instance. One of the solutions would be to modify the generated proxy class so that return type of the WebService method is the class from your shared DLL and not generated one. You need to modify Reference.css under Web References. Another solutions is to write code that takes WS.Person class and creates new DLL.person class by copying all the fields, etc. You could use reflection to shorten the code as all field names are the same in both types. Maybe there are more elegant solutions, but hope this helps.

            Vitaliy Tsvayer Tikle

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups