Hi all,
I guess one of you could help me out here with .NET Remoting. The situation
is below.
I have the following classes defined.
Public interface ISession
{
void Run();
void Stop();
//.. other methods
};
Public abstract class SessionBase : MarshalByRefObject, ISession
{
public SessionBase(parameters) {} // no default constructors for this
class
};
in an assembly Session.dll
public class MySession : SessionBase
{
public MySession() {} // default constructor available for
this class. Hence it is comvisible
}
Now i've a session host console application to host remote instances of
MySession as follows
Class SessionHost
{
main()
{
HttpChannel chnl = new HttpChannel(1234);
ChannelServices.RegisterChannel(chnl);
RemotingConfiguration.RegisterWellKnownServiceType(typeof(MySession),
"MySession.soap", WellKnownObjectMode.Singleton);
}
}
UnManaged Client Side Code
Remember an unmanaged client can't create instance of this class going
through Activator.GetObject, as the Activator is not COM creatable.
Hence I created a managed class named SessionADapter as follows.
Public interface ISessionAdapter
{
void Init();
ISession GetMySession();
}
[ComVisible(true)]
Public class SessionAdapter : ISessionAdpater
{
public void Init()
{
HttpChannel chnl = new HttpChannel();
ChannelServices.RegisterChannel(chnl);
}
public ISession GetSession(ISessionListener sessionListener)
{
ISession iSession = (ISession)Activator.GetObject(typeof(ISession),
"http://localhost:1234/MySession.soap");
Return iSession;
}
}
Hence my unmanaged client creates an local instance of the adapter (i.e CCW)
and gets the ISessionAdapter pointer. It is also successful in calling
GetSession() and getting a non null interface pointer to ISession. The
traces on the sessionhost console app verifies that a remote instance is
being created for a request from this unmanaged client app.
The problem is when I try to call methods on the ISession interface from the
unmanaged client. I get the following error that reads
"Run-Time Check Failure #0 - The value of ESP was not properly saved across
a function call. This is usually a result of calling a function declared
with one calling convention with a function pointer declared with a
different calling convention.".
Am I doing something wrong here? Please help.
Thanks,
Sundar Krishnamoorthy
KLA-Tencor Corp
(408) 875 7278
===================================
This list is hosted by DevelopMentor� http://www.develop.com
You may be interested in Guerrilla .NET, 24 March 2003, in London
http://www.develop.com/courses/gdotnet
View archives and manage your subscription(s) at http://discuss.develop.com