How to force a generic type eventhandler to a ingeneric one? [modified]
-
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
-
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
The important piece of information missing is the actual type of the
GetAgencyListCompleted
event but your error message suggests that it is not anEventHandler <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.
-
The important piece of information missing is the actual type of the
GetAgencyListCompleted
event but your error message suggests that it is not anEventHandler <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.
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.