The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

import-bot (20211) [Avatar] Offline
#1
[Originally posted by bogatiy2]

When I run with HTTP with this example, I get the following error on the
client console:

Unhandled Exception: System.Runtime.Remoting.RemotingException: Invalid SOAPActi
on specified:
"http://schemas.microsoft.com/clr/nsassem/HelloObj/helloclient#Greet"

Server stack trace:
at System.Runtime.Remoting.Channels.SoapServerFormatterSink.ProcessMessage(IS
erverChannelSinkStack sinkStack, IMessage requestMsg, ITransportHeaders requestH
eaders, Stream requestStream, IMessage& responseMsg, ITransportHeaders& response
Headers, Stream& responseStream)

Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage req
Msg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgDa
ta, Int32 type)
at HelloObj.Greet(String name)
at HelloClient.Main(String[] args) in c:helloclientclienthello.cs:line 22
Press any key to continue

The file contents of helloclient.cs (I renamed it to clienthello.cs) is:

using System;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Http;

class HelloClient
{
public static void Main(string[] args)
{
ChannelServices.RegisterChannel(new HttpChannel());
HelloObj helloObjRef = (HelloObj)Activator.GetObject(
typeof(HelloObj),
"http://localhost:6789/HelloObj"
);
Console.WriteLine(helloObjRef.Greet("Joe Bloggs"));
Console.WriteLine(helloObjRef.Greet("Mary Bloggs"));
}
}
public interface HelloObj
{
string Greet(string name);
}

I added the interface so get the client to compile on VS. It works great with
tcp.

On the server window, the object activates and then hangs, the output is:


Csmilieocuments and Settingsuser1DesktopgrimesDotNetExamplescha_5>helloservice
configuring remoting...
configFile=helloservice.exe.http.singleton.config
waiting for remote calls...
hit ENTER to exit...
HelloObj activated...

The contents of the helloservice.cs file is:

using System;
using System.Runtime.Remoting;

public class HelloObj : MarshalByRefObject {

public HelloObj() {
Console.WriteLine("HelloObj activated...");
}

public string Greet(string name) {
lock(this) { numGreet++; }
string greeting = "Hello, " + name + "!";
Console.WriteLine("greeting #{0}: " + greeting, numGreet);
return greeting;
}

private int numGreet = 0;
}

public class HelloService {
public static void Main(string[] args) {

Console.WriteLine("configuring remoting...");
string configFile = "helloservice.exe.http.singleton.config";
if (args.Length > 0) configFile = args[0];
Console.WriteLine("configFile=" + configFile);
RemotingConfiguration.Configure(configFile);

Console.WriteLine("waiting for remote calls...");
Console.WriteLine("hit ENTER to exit...");
Console.ReadLine();
}
}

The contents of the config file is:

<configuration>
<system.runtime.remoting>
<application>
<service>
<wellknown>
type="HelloObj, HelloService"
objectUri="HelloObj"
mode="Singleton"
/>
</service>
<channels>
<!--channel<br /> type="System.Runtime.Remoting.Channels.Http.HttpChannel,<br /> System.Runtime.Remoting"<br /> port="6789"<br /> /-->
<channel>
ref="http"
port="6789"
/>
</channels>
</application>
</system.runtime.remoting>
</configuration>

Why is this exception being thrown?
import-bot (20211) [Avatar] Offline
#2
Re: Remoting 5.3.3 example
[Originally posted by fgrimes]

Hi,

I hope I don't offend if I offer my own personal approach to
finding errors like this...

You say you changed the original working example, by renaming (and ?).
Since the original worked ok, I would start from scratch with the
example verbatim from the book and trace my changes one-by-one from
there. It's often quicker, and always more informative, than looking
for typos.

Regards,
Fergal