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. How to force a generic type eventhandler to a ingeneric one? [modified]

How to force a generic type eventhandler to a ingeneric one? [modified]

Scheduled Pinned Locked Moved C#
helptutorialquestion
3 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.
  • J Offline
    J Offline
    JUNEYT
    wrote on last edited by
    #1

    Hello, I get

    GetAgencyListCompleted

    EventHandler and

    GetAgencyListCompletedEventArg

    EventArguments delegations from a WebService to check the EventHandler result. The result property (object) of the eventhandler will bring the list of items that what I am looking for. However, I get implicitly conversion error message in the code below. How can solve the problem?. If you know the solution, would you please show me how to do it? Thanks.

    //PRONTOWS IS A WEB SERVICE & PSSaleWS is a WEB REFERANCE

    // The following statement causes implicit conversion error

    ProntoWS.GetAgencyListCompleted += new EventHandler <PSSaleWS.GetAgencyListCompletedEventArgs>(Proxy_AgencyInfoCompleted);

    // Here is the proxy class

    void Proxy_AgencyInfoCompleted(object sender, PSSaleWS.GetAgencyListCompletedEventArgs Completed)
    {
    Response.Write("Here");

        }
    

    What a curious mind needs to discover knowledge is noting else than a pin-hole.

    modified on Sunday, May 22, 2011 6:26 PM

    A 1 Reply Last reply
    0
    • J JUNEYT

      Hello, I get

      GetAgencyListCompleted

      EventHandler and

      GetAgencyListCompletedEventArg

      EventArguments delegations from a WebService to check the EventHandler result. The result property (object) of the eventhandler will bring the list of items that what I am looking for. However, I get implicitly conversion error message in the code below. How can solve the problem?. If you know the solution, would you please show me how to do it? Thanks.

      //PRONTOWS IS A WEB SERVICE & PSSaleWS is a WEB REFERANCE

      // The following statement causes implicit conversion error

      ProntoWS.GetAgencyListCompleted += new EventHandler <PSSaleWS.GetAgencyListCompletedEventArgs>(Proxy_AgencyInfoCompleted);

      // Here is the proxy class

      void Proxy_AgencyInfoCompleted(object sender, PSSaleWS.GetAgencyListCompletedEventArgs Completed)
      {
      Response.Write("Here");

          }
      

      What a curious mind needs to discover knowledge is noting else than a pin-hole.

      modified on Sunday, May 22, 2011 6:26 PM

      A Offline
      A Offline
      Alan N
      wrote on last edited by
      #2

      The important piece of information missing is the actual type of the GetAgencyListCompleted event but your error message suggests that it is not an

      EventHandler <PSSaleWS.GetAgencyListCompletedEventArgs>

      If it is typed non generically as

      public delegate void GetAgencyListCompletedEventHandler(object sender, PSSaleWS.GetAgencyListCompletedEventArgs Completed);

      then the solution is to explicitly create a delegate of the correct type or let the compiler do it for you automatically. either

      ProntoWS.GetAgencyListCompleted += new GetAgencyListCompletedEventHandler(Proxy_AgencyInfoCompleted);

      or

      ProntoWS.GetAgencyListCompleted += Proxy_AgencyInfoCompleted;

      If this doesn't solve your issue then please supply more information about the actual types involved. Alan.

      J 1 Reply Last reply
      0
      • A Alan N

        The important piece of information missing is the actual type of the GetAgencyListCompleted event but your error message suggests that it is not an

        EventHandler <PSSaleWS.GetAgencyListCompletedEventArgs>

        If it is typed non generically as

        public delegate void GetAgencyListCompletedEventHandler(object sender, PSSaleWS.GetAgencyListCompletedEventArgs Completed);

        then the solution is to explicitly create a delegate of the correct type or let the compiler do it for you automatically. either

        ProntoWS.GetAgencyListCompleted += new GetAgencyListCompletedEventHandler(Proxy_AgencyInfoCompleted);

        or

        ProntoWS.GetAgencyListCompleted += Proxy_AgencyInfoCompleted;

        If this doesn't solve your issue then please supply more information about the actual types involved. Alan.

        J Offline
        J Offline
        JUNEYT
        wrote on last edited by
        #3

        Hi Alan! Thank you for your answer, I got rid of the implicit conversion problem with your approach but Proxy_AgencyInfoCompleted never fires up even I invoke the procedure after ProntoWS.GetAgencyListCompleted += new GetAgencyListCompletedEventHandler(Proxy_AgencyInfoCompleted); statement. Web service doesn't have specific asyncronous methods. Therefore I tried to call the method as follows bur Proxy_AgencyInfoCompleted didn't fire up. Do you have any idea where is the problem? Thank you very much.

         ProntoWS.GetAgencyListCompleted += new GetAgencyListCompletedEventHandler(Proxy\_AgencyInfoCompleted);
        
         // after the following statement I should able to fire up Proxy\_AgencyInfoCompleted
        
         GetAgencyList = GetAgencyList = ProntoWS.GetAgencyList(Agent, User, Password, GetCityName, "TR");
        

        What a curious mind needs to discover knowledge is noting else than a pin-hole.

        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