Connecting Tech Pros Worldwide Help | Site Map

Conversion error in web service

Newbie
 
Join Date: Jun 2009
Posts: 2
#1: Sep 11 '09
Hello,

I am working on a single sign on sollution for two different websites.
I am trying to make the methods in my customized(overriden) provider post to a web service and get the results from it so that the same login.

It works for most methods but there are ones that return System.We.Security sp3ecific objects that fail. For example

Expand|Select|Wrap|Line Numbers
  1. public override MembershipUser GetUser(object providerUserKey, bool userIsOnline)
  2.         {
  3.             System.Web.Security.MembershipUser mu = null;
  4.             iConnect.Core.iConnectWS.iConnect connect = new iConnect.Core.iConnectWS.iConnect();
  5.             mu = ((MembershipUser)connect.GetUser(providerUserKey, userIsOnline));
  6.             return mu;
  7.         }
  8.  
is in the provider
and it calls
Expand|Select|Wrap|Line Numbers
  1. [WebMethod(EnableSession = true)]
  2.     public object GetUser(object providerUserKey, bool userIsOnline)
  3.     {
  4.         return (object) System.Web.Security.Membership.GetUser(providerUserKey, userIsOnline);
  5.     }
  6.  
in the webservice
(the webservice uses the default asp.net provider System.Web.Security.SqlMembershipProvider)

My problem is that when I try to run this I get an error
Expand|Select|Wrap|Line Numbers
  1. Unable to cast object of type 'iConnect.Core.iConnectWS.MembershipUser' to type 'System.Web.Security.MembershipUser'
  2.  
If I don't make the web service return a object then I get this error at compilation.

The class is the web service and the one in the one in the provider is one and the same System.Web.Security.MembershipUser.

Can anyone help me?
thank you in advance
Reply

Tags
asp.net, c sharp, exception, web service