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

Remote Method Service 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 Method Service Call
    Posted: 10-Apr-2013 at 12:02pm
I have a number of RMSC that work in DevForce 2010, but I can't seem to get them to work in 2012. I can do a normal query and get entities back, so I don't think it is a EM configuration issue.

I have tried this from a test project, and the error is always the same:

System.IO.FileNotFoundException: Could not load file or assembly 'SilverlightApplication62' or one of its dependencies.

ServerMethods.cs is linked to the SL project for the Delegate.

This is the test Server Method:

public static class ServerMethods
    {
        [AllowRpc]
        public static object GetNumberOfOrders(IPrincipal principal,
          EntityManager entityManager, params Object[] args)
        {
            return 5;
        }
    }

This is the SL call:

public async void GetNumberOfOrderFromServer(int id) {
            var _entityManager = new JetAnalyticsEntities();
            var serverMethod = new ServerMethodDelegate(ServerMethods.GetNumberOfOrders);
            var returnValue = (int)await _entityManager.InvokeServerMethodAsync(serverMethod, id);
        }

I also tried it using strings:

public async void GetNumberOfOrders2(int id)
        {
            try
            {
               string typeName = "SilverlightApplication62.ServerMethods, SilverlightApplication62";
               string methodName = "GetNumberOfOrders";
               var result = (int) await _entityManager.InvokeServerMethodAsync(typeName, methodName, id);
            }
            catch (Exception ex)
            {
              
            }
        }

The error message is always the same about the file could not be found. I am assuming that it can't find ServerMethods.cs, as a breakpoint in the file is never hit. This is the full error message from the log:

Caught exception: System.IO.FileNotFoundException: Could not load file or assembly 'SilverlightApplication62' or one of its dependencies. The system cannot find the file specified. File name: 'SilverlightApplication62' at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) at System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) at System.Reflection.Assembly.Load(AssemblyName assemblyRef) at IdeaBlade.Core.Reflection.ReflectionExtensions.LoadAssembly(String assemblyName) at IdeaBlade.Core.Reflection.ReflectionFns.GetLatestType(String pTypeName, Boolean pThrowOnError, Boolean pIgnoreCase) at IdeaBlade.EntityModel.Edm.RsmMethod.Create(String typeName, String methodName) at IdeaBlade.EntityModel.Edm.UdtMethodMap.GetRsmMethod(String typeName, String methodName) at IdeaBlade.EntityModel.Server.EntityServer.InvokeServerMethod(SessionBundle sessionBundle, InvokeServerMethodWorkState workState) at SyncInvokeInvokeServerMethod(Object , Object[] , Object[] ) at System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object instance, Object[] inputs, Object[]& outputs) at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage41(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage4(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage31(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage3(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage2(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage11(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage1(MessageRpc& rpc) at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet) === Pre-bind state information === LOG: User = DisplayName = SilverlightApplication62 (Partial) WRN: Partial binding information was supplied for an assembly: WRN: Assembly Name: SilverlightApplication62 | Domain ID: 2 WRN: A partial bind occurs when only part of the assembly display name is provided. WRN: This might result in the binder loading an incorrect assembly. WRN: It is recommended to provide a fully specified textual identity for the assembly, WRN: that consists of the simple name, version, culture, and public key token. WRN: See whitepaper http://go.microsoft.com/fwlink/?LinkId=109270 for more information and common solutions to this issue. LOG: Appbase = file:///D:/Clients/Test/SilverlightApplication62Web/ LOG: Initial PrivatePath = D:\Clients\Test\SilverlightApplication62Web\bin Calling assembly : IdeaBlade.Core, Version=7.1.1.0, Culture=neutral, PublicKeyToken=287b5094865421c0. === LOG: This bind starts in default load context. LOG: Using application configuration file: D:\Clients\Test\SilverlightApplication62Web\web.config LOG: Using host configuration file: C:\Users\Administrator\Documents\IISExpress\config\aspnet.config LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config. LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind). LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/root/1ae1acb2/bf9e6e56/SilverlightApplication62.DLL. LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/root/1ae1acb2/bf9e6e56/SilverlightApplication62/SilverlightApplication62.DLL. LOG: Attempting download of new URL file:///D:/Clients/Test/SilverlightApplication62Web/bin/SilverlightApplication62.DLL. LOG: Attempting download of new URL file:///D:/Clients/Test/SilverlightApplication62Web/bin/SilverlightApplication62/SilverlightApplication62.DLL. LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/root/1ae1acb2/bf9e6e56/SilverlightApplication62.EXE. LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/root/1ae1acb2/bf9e6e56/SilverlightApplication62/SilverlightApplication62.EXE. LOG: Attempting download of new URL file:///D:/Clients/Test/SilverlightApplication62Web/bin/SilverlightApplication62.EXE. LOG: Attempting download of new URL file:///D:/Clients/Test/SilverlightApplication62Web/bin/SilverlightApplication62/SilverlightApplication62.EXE.

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: 10-Apr-2013 at 3:56pm
Hi Greg,

The only thing I could think of is to check and make sure ServerMethods.cs has Build Action set to Compile in its properties.

Besides that, I'd take a look at the sample at http://drc.ideablade.com/devforce-2012/bin/view/Documentation/code-sample-remote-server-method and check for any subtle difference.
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: 11-Apr-2013 at 8:08am
Thanks. This line from the sample should be added to the documentation:

"Using the ServerMethodDelegate means that you must define a class/method stub on the client and use the same assembly name on the server as well as the client."

In other words, the issue was that the Server Project dll name was different than the client assembly dll. (The default project template of course adds "Web" to the end of the Server project dll name.)

Greg
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down