Actually I need a gateway functionality - to provide access via Internet to
..NET remoting services which use TcpChannel. So there is WebGateway - ASP.NET
application which accesses repository of services, exposes services'
interfaces on itself and when called, forwards the call to the actual service.
Example:
public interface IMySvc
{
void DoSomething();
}
There is remoting service hosted in standalone exe and exposing interface
IMySvc: tcp://host1:12345/MySvc.
WebGateway is remoting application hosted in IIS and exposing the same
interface:
https://webgateway/gw/MySvc.rem
WebGateway forwards calls from the client to the actual service.
Problems with this current approach are:
1. When there are more than one services implementing the same interface,
..NET is confused by the same types instantiated from different assemblies
loaded from the service repository. So before loading new assembly I check if
such assembly is already loaded. It works fine unless interface is modified
and at the same time there are old and new interfaces.
2. When service is restarted with newer interface, Gateway also needs to be
restarted to use new type.
So I wanted to freely mix different versions of same interaface and reload
interface of only restarted service. For that it seemed logical to use
appdomain per service.
Details of the problem I faced is in the first message. It does not matter
whether I call Marshal or RegisterWellKnownServiceType in a new domain -
these URI are not get exposed.
protected void Application_Start(Object sender, EventArgs e)
{
AppDomain d = AppDomain.CurrentDomain;
AppDomain domain = AppDomain.CreateDomain(
"TestDomain",
d.Evidence, d.SetupInformation);
Type t = typeof(C);
C c = (C) domain.CreateInstanceAndUnwrap(t.Assembly.FullName, t.FullName);
//C c = new C();
c.Marshal();
}
public class C : MarshalByRefObject
{
public void Marshal()
{
IDictionary props = new Hashtable();
props["name"] = "MyChannel";
props["priority"] = "100";
HttpChannel channel = new HttpChannel(props, null, null);
ChannelServices.RegisterChannel(channel);
WellKnownServiceTypeEntry WKSTE = new WellKnownServiceTypeEntry(
typeof(C),
"Test",
WellKnownObjectMode.SingleCall);
RemotingConfiguration.RegisterWellKnownServiceType(WKSTE);
}
public string SayIt()
{
return "Works!";
}
}
When instance of class C is created by new (current domain) - everyrthing is
fine and in Internet explorer I get proper XML for
http://websvr/MyApp/Test.soap?wsdl.
When I use domain.CreateInstanceAndUnwrap (new domain) for the same URL I
get error message like there nothing there.
[quoted text, click to view] "Sergey Radkevich" wrote:
> > I want to marshal object in an IIS hosted application.
> > It works fine when RemotingServices.Marshal is called in the original
> AppDomain.
> > But when I create new AppDomain and marshal there,
> > the object cannot be accessed remotely.
> >
> > Could anyone please suggest hot accomplish that?
>
> - Does it works in non IIS-hosted application?
> - What are reasons for calling RemotingServices.Marshal instead of using
> standart ways
> (Registering well-known types + Activator.GetObject and using client-side
> activation)?
> - Can you provide sample code or more detailed description of overal
> architecture of your solution
> (only parts which are related to remoting)?
>
>