New Posts New Posts RSS Feed: Remote Service Method Call
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Remote Service Method Call

 Post Reply Post Reply
Author
gregweb View Drop Down
DevForce MVP
DevForce MVP
Avatar

Joined: 10-Sep-2009
Location: Clearwater, Fl
Posts: 253
Post Options Post Options   Quote gregweb Quote  Post ReplyReply Direct Link To This Post Topic: Remote Service Method Call
    Posted: 27-Dec-2010 at 5:53am
I am trying to get a RSMC to work as per http://drc.ideablade.com/xwiki/bin/view/Documentation/QueryRSMC
 
On the server I have a class called MailService like this:
 
namespace Jet.Services
{
    public static class MailService
    {
        [AllowRpc]
        public static object GetNewMail(IPrincipal pPrincipal, EntityManager pPm, params Object[] pArgs )
        {
            Debug.WriteLine("Getting New Mail");
            return "Got Mail";
        }

    }
}
I link this class in the SL project so I have a reference to it.  I then call it like this on the client:
internal void GetMail()
{
            object[] parms = new object[] { "Test" };
            //string methodName = "GetNewMail";
            ServerMethodDelegate del = Jet.Services.MailService.GetNewMail;
var op  = _mgr.InvokeServerMethodAsync( del, parms);
}
 
This compiles.  But when I run it, I get the following exception:
 
Unable to load type: Jet.Services.MailService, Jet, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
 
I looked for a sample in DRC_SampleCode, but didn't find one.
 
Greg
 
 
 
 
 
 
Back to Top
sbelini View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 13-Aug-2010
Location: Oakland
Posts: 786
Post Options Post Options   Quote sbelini Quote  Post ReplyReply Direct Link To This Post Posted: 28-Dec-2010 at 4:27pm
Hi Greg,
 
You are getting this error because when you create a delegate in the client, its full type name is
 
Jet.Services.MailService, Jet, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
 
but in the server, the Assembly name is most likely JetWeb. (I'm guessing the server assembly name is JetWeb based on the assumption that you created your project using the Silverlight template)
 
To get rid of the error, you could:
1) change the Assembly name of the server to match the SL project's. This is possible, but NOT advisable as it could cause other adverse effects.
 
2) use the
  public InvokeServerMethodOperation InvokeServerMethodAsync( 
    string fullTypeName,
    string methodName,
    Action<InvokeServerMethodOperation> userCallback,
    object userState,
    params object[] userArguments
  )
overload.
 
Silvio.
Back to Top
gregweb View Drop Down
DevForce MVP
DevForce MVP
Avatar

Joined: 10-Sep-2009
Location: Clearwater, Fl
Posts: 253
Post Options Post Options   Quote gregweb Quote  Post ReplyReply Direct Link To This Post Posted: 29-Dec-2010 at 5:43am

Hi Silvio,

Thanks very much, I am going to try number 2 above.  I found a good sample of this in the AuthenticationManager:
 
// Call a server-side method.  Note type name must be fully-qualifed:  MyNamespace.MyClass, MyAssemblyName
            string typeName = "Jet.RegistrationServices, Jet.Web";
            string methodName = "CreateUser";
            var op1 = Manager.InvokeServerMethodAsync(typeName, methodName, nullnull, user, password);
            yield return op1;
            CreateUserResult result = op1.Result as CreateUserResult;
            if (result.Status != CreateUserStatus.Success)
            {
                // Throw an exception here - the caller can decide what to do.  
                throw new RegistrationException(result);
            }
 
I also tried setting the assembly name in the Project Properties to Jet from Jet.Web, and this also worked! 
 
Greg


Edited by gregweb - 29-Dec-2010 at 6:34am
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down