Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Remoting / December 2004

Tip: Looking for answers? Try searching our database.

Creating an interface on a server application

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Adrian - 15 Dec 2004 13:13 GMT
Hi!
How can I create an instance of an interface on a server machine which is
exactly like another one on a client machine. I tried different methods and
no results.
Thanks!
todd.mancini@gmail.com - 15 Dec 2004 14:28 GMT
You need to compile the interface into its own class library, and then
deploy that same DLL to both machines.

A prototypical remoting sample will often involve 3 projects -- the
server exe, the client exe, and a shared class library of interfaces.
(You'd then add a reference to the shared library to both of the client
and server projects.)
Sam Santiago - 15 Dec 2004 18:57 GMT
Check out the examples on GotDotNet:
http://samples.gotdotnet.com/QuickStart/howto/default.aspx?url=/quickstart/howto
/doc/Remoting/byvalue.aspx


Thanks,

Sam

Signature

_______________________________
Sam Santiago
ssantiago@n0spam-SoftiTechture.com
http://www.SoftiTechture.com
_______________________________

> You need to compile the interface into its own class library, and then
> deploy that same DLL to both machines.
[quoted text clipped - 3 lines]
> (You'd then add a reference to the shared library to both of the client
> and server projects.)
Adrian - 16 Dec 2004 08:35 GMT
I did exactly what you explained,  the methods are invoked even on different
machine, but when I created some events, they aren't fired if the client is
on another machine. So, I think that the problem is that I did not create
the instance correctly.
On server application, I wrote:

ListDictionary prop = new ListDictionary();
prop.Add("port", 1235);
SoapClientFormatterSinkProvider clientProvider = new
SoapClientFormatterSinkProvider();
SoapServerFormatterSinkProvider serverProvider = new
SoapServerFormatterSinkProvider();
serverProvider.TypeFilterLevel =
System.Runtime.Serialization.Formatters.TypeFilterLevel.Full;
HttpChannel channel = new HttpChannel(prop, clientProvider, serverProvider);
ChannelServices.RegisterChannel(channel);
System.Runtime.Remoting.RemotingConfiguration.RegisterWellKnownServiceType(t
ypeof(UserServer), "User.soap",
System.Runtime.Remoting.WellKnownObjectMode.Singleton);
intUser =
(UsersLibrary.IUser)Activator.GetObject(typeof(UsersLibrary.IUser),
http://192.168.13.10:1235/User.soap);

intUser is an instance of my interface and I think there is another way to
create it.
Thanks!
Ken Kolda - 16 Dec 2004 16:04 GMT
Although it's not what your original question seemed to be asking, it looks
like what you're trying to do is to get a reference to your singleton on the
server so you can raise events which will then be handled by the clients.
The code as you have it below is an awkward and inefficient way of doing
this as essential you're making the server a client of itself. Any method
calls to the UserServer object will have to go through all the remoting
mechanisms even though the object is actually in the same process/AppDomain.

To get a reference to the actual singleton without using GetObject() on the
server, do this:

1) Declare and instantiate a static instance of your UserServer class.
2) Replace the code that calls RegisterWellKnownServiceType() with code that
instead calls RemotingServices.Marshal(), passing in your static instance
and your URI (User.soap).

Now, in your server code, you can simply reference the static variable to
get the same instance of the UserServer class as is being accessed by the
clients.

Hope that helps -
Ken

> I did exactly what you explained,  the methods are invoked even on different
> machine, but when I created some events, they aren't fired if the client is
[quoted text clipped - 12 lines]
> HttpChannel channel = new HttpChannel(prop, clientProvider, serverProvider);
> ChannelServices.RegisterChannel(channel);

System.Runtime.Remoting.RemotingConfiguration.RegisterWellKnownServiceType(t
> ypeof(UserServer), "User.soap",
> System.Runtime.Remoting.WellKnownObjectMode.Singleton);
[quoted text clipped - 5 lines]
> create it.
> Thanks!
cnfr - 17 Dec 2004 07:59 GMT
Thanks Ken!
I told you that I was pretty sure that the way wasn't right.
Unfortunately, it did not work that way you explained me.

Anyway, I appreciate your promptitude
Adrian - 17 Dec 2004 08:30 GMT
I have to apologize.
I made a stupid mistake. Now it works!
Thanks a lot!

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.