By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,877 Members | 1,064 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,877 IT Pros & Developers. It's quick & easy.

Remoting questions

P: n/a
Nak
Hi there,

I have been messing around with remoting in an attempt to create a
"shared application" as mentioned in another thread by that name.

I have created a singleton object just like the example in the 101
VB.NET examples. It works great, only 1 instance ever gets created and is
shared by each client. I have a few questions though,

* Can the singleton contain events? In such a way that when the
event is raised each application consuming the singleton recieves the event?
I had troubles trying to implement this.

* Can the host consume the singleton? I didn't seem to be able to
make the host instantiate an instance of the singleton so that it contained
the first and only instance for monitoring purposes etc.

Thanks for your help :-) I'm sure I'm doing something wrong maybe :-\

Nick.

--
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
"No matter. Whatever the outcome, you are changed."

Fergus - September 5th 2003
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
Nov 20 '05 #1
Share this Question
Share on Google+
9 Replies


P: n/a
In article <Oq**************@TK2MSFTNGP12.phx.gbl>, Nak wrote:

First, I want to qualify and say that I'm not a great expert on this
subject.
Hi there,

I have been messing around with remoting in an attempt to create a
"shared application" as mentioned in another thread by that name.

I have created a singleton object just like the example in the 101
VB.NET examples. It works great, only 1 instance ever gets created and is
shared by each client. I have a few questions though,

* Can the singleton contain events? In such a way that when the
event is raised each application consuming the singleton recieves the event?
I had troubles trying to implement this.

Yes - but you need to be aware of thread blocking issues... There is a
very good book on the subject by Ingo Rammer "Advanced .NET Remoting",
there is both a C# and a VB.NET version of the book. Anyway, you may
want to check out this link for the threading issue:

http://www.ingorammer.com/RemotingFA...PLICATION.html

* Can the host consume the singleton? I didn't seem to be able to
make the host instantiate an instance of the singleton so that it contained
the first and only instance for monitoring purposes etc.


I'm not sure... But, I don't see why not.

HTH
--
Tom Shelton
MVP [Visual Basic]
Nov 20 '05 #2

P: n/a
Nak
Hi there,
First, I want to qualify and say that I'm not a great expert on this
Fine by me, any advice is greatly appreciated!
Yes - but you need to be aware of thread blocking issues... There is a
very good book on the subject by Ingo Rammer "Advanced .NET Remoting",
there is both a C# and a VB.NET version of the book. Anyway, you may
want to check out this link for the threading issue:

http://www.ingorammer.com/RemotingFA...PLICATION.html

I shall check the link out, thanks loads.
I'm not sure... But, I don't see why not.


Yeah, I thought it might be, I just don't know the correct method for doing
so. Hopefully the above link will shed some light on the subject.

Thanks for your help again :-)

Nick.

--
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
"No matter. Whatever the outcome, you are changed."

Fergus - September 5th 2003
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
Nov 20 '05 #3

P: n/a
Hi Nak,

I am researching the issue, I will update you with new information ASAP.

Regards,
Peter Huang
Microsoft Online Partner Support
Get Secure! www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
--------------------
From: "Nak" <a@a.com>
References: <Oq**************@TK2MSFTNGP12.phx.gbl> <OU**************@tk2msftngp13.phx.gbl>Subject: Re: Remoting questions
Date: Fri, 17 Oct 2003 19:07:15 +0100
Lines: 33
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
Message-ID: <Oa**************@TK2MSFTNGP09.phx.gbl>
Newsgroups: microsoft.public.dotnet.languages.vb
NNTP-Posting-Host: dsl213-218-228-203.as15444.net 213.218.228.203
Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTN GP09.phx.gbl
Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.vb:147778
X-Tomcat-NG: microsoft.public.dotnet.languages.vb

Hi there,
First, I want to qualify and say that I'm not a great expert on this
Fine by me, any advice is greatly appreciated!
Yes - but you need to be aware of thread blocking issues... There is a
very good book on the subject by Ingo Rammer "Advanced .NET Remoting",
there is both a C# and a VB.NET version of the book. Anyway, you may
want to check out this link for the threading issue:

http://www.ingorammer.com/RemotingFA...PPLICATION.htm

l
I shall check the link out, thanks loads.
I'm not sure... But, I don't see why not.
Yeah, I thought it might be, I just don't know the correct method for doing
so. Hopefully the above link will shed some light on the subject.

Thanks for your help again :-)

Nick.

--
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/

\"No matter. Whatever the outcome, you are changed."

Fergus - September 5th 2003
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/ \


Nov 20 '05 #4

P: n/a
Nak
Hi there,
I am researching the issue, I will update you with new information ASAP.


Excellent I shall eagerly await your reply. I'm also out to buy the
advanced .net remoting book to give that a whirl :-) Thanks for your help.

Nick.

--
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
"No matter. Whatever the outcome, you are changed."

Fergus - September 5th 2003
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
Nov 20 '05 #5

P: n/a
Hi Nick,
* Can the singleton contain events? In such a way that when the
event is raised each application consuming the singleton recieves the event? I had troubles trying to implement this.
Here is a sample about the sink event in remoting object.
Remoting Events
http://staff.develop.com/woodring/dotnet/

* Can the host consume the singleton? I didn't seem to be able to
make the host instantiate an instance of the singleton so that it contained the first and only instance for monitoring purposes etc.

Yes, here I write a simple sample for you.
[Server Host]
Imports System
Imports System.Runtime.Remoting
Imports System.Runtime.Remoting.Channels
Imports System.Runtime.Remoting.Channels.Tcp
Imports ClassLibrary5
Module Module1
Sub Main()
Dim tcpchannel As New TcpChannel(8082)
ChannelServices.RegisterChannel(tcpchannel)

RemotingConfiguration.RegisterWellKnownServiceType (GetType(HelloServiceClass
), "RemoteTest", WellKnownObjectMode.Singleton)
Dim service As HelloServiceClass =
CType(Activator.GetObject(GetType(HelloServiceClas s),
"tcp://localhost:8082/RemoteTest"), HelloServiceClass)
Console.WriteLine(service.HelloMethod("Server"))
Console.ReadLine()
End Sub
End Module

[Remoting Object]
Imports System
Public Class HelloServiceClass
Inherits MarshalByRefObject
Private str As String
Public Sub New()
Console.WriteLine("Constructor")
End Sub
Public Property ObjFlag()
Get
ObjFlag = str
End Get
Set(ByVal Value)
str = ObjFlag
End Set
End Property
Public Function HelloMethod(ByVal name As String) As String
Return "Hi there " + name + "."
End Function
End Class

[Client]
Imports System
Imports System.Runtime.Remoting
Imports System.Runtime.Remoting.Activation
Imports System.Runtime.Remoting.Channels
Imports System.Runtime.Remoting.Channels.Tcp
Imports ClassLibrary5
Module Module1
Sub Main()
ChannelServices.RegisterChannel(New TcpChannel)
Dim sc As ClassLibrary5.HelloServiceClass
sc = CType(Activator.GetObject(GetType(HelloServiceClas s),
"tcp://localhost:8082/RemoteTest"), HelloServiceClass)
Console.WriteLine(sc.HelloMethod("Client"))
End Sub
End Module

From the sample , you will find that he constructor of the remoting object
is called once.
Did I misunderstand your meaning?
If you have any related question, please feel free to let me know.

Regards,
Peter Huang
Microsoft Online Partner Support
Get Secure! www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
--------------------From: "Nak" <a@a.com>
References: <Oq**************@TK2MSFTNGP12.phx.gbl> <OU**************@tk2msftngp13.phx.gbl>
<Oa**************@TK2MSFTNGP09.phx.gbl>
<om**************@cpmsftngxa06.phx.gbl>Subject: Re: Remoting questions
Date: Mon, 20 Oct 2003 22:36:49 +0100
Lines: 17
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
Message-ID: <Od**************@TK2MSFTNGP12.phx.gbl>
Newsgroups: microsoft.public.dotnet.languages.vb
NNTP-Posting-Host: dsl213-218-228-203.as15444.net 213.218.228.203
Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTN GP12.phx.gbl
Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.vb:148492
X-Tomcat-NG: microsoft.public.dotnet.languages.vb

Hi there,
I am researching the issue, I will update you with new information ASAP.
Excellent I shall eagerly await your reply. I'm also out to buy the
advanced .net remoting book to give that a whirl :-) Thanks for your help.

Nick.

--
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/

\"No matter. Whatever the outcome, you are changed."

Fergus - September 5th 2003
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/ \


Nov 20 '05 #6

P: n/a
Nak
Hi Peter,
http://staff.develop.com/woodring/dotnet/


Excuse me, but this is very difficult to explain...

I have been looking at the example thoroughly, unfortunately it is in C#, so
I am a little unsure on a few minor details.

Firstly, the events are raised via the eventShim class, unfortunately I
can't for the life of me see 1 solid reference to the eventshim class in the
code!! So I am slightly confused as to how the server could possibly use
the class to forward events when it doesn't even have a reference to or know
about the class.

I would have thought that the server would create a singleton of the
eventshim class and use that to forward to all registered clients, but the
server doesn't even use it! The eventshim class is instantiated on the
client rather than the server.

For example, the server creates a new class, this class is exposed as a
remoting object. The class implements the interface desired for the
remoting object, which in-turn exposes the event. In my code I know that
the server is attempting to raise the event, as I have placed a messagebox
just before the line, but unfortunately the event never gets to the client!!

I suppose my main question should be, where should the eventshim class be
created? Is it simply used on the client side to recieve events? If that
is the case then how does the event even get there if it is not even linked
to the remoteable object? Very confusing example, and seeing as I am using
VB.NET Standard I cannot even see if it works as I would expect. Thanks for
your help again, I think I might scrap that one and read the advanced .net
remoting book.

Nick.

--
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
"No matter. Whatever the outcome, you are changed."

Fergus - September 5th 2003
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
Nov 20 '05 #7

P: n/a
Hi Nak,

There is a simple VB remoting event sample in .NET SDK.
e.g.
D:\Program Files\Microsoft Visual Studio .NET
2003\SDK\v1.1\Samples\Technologies\Remoting\VB
I also has comments in line.

If you have any related question please feel free to let me know.

Regards,
Peter Huang
Microsoft Online Partner Support
Get Secure! www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
--------------------
From: "Nak" <a@a.com>
References: <Oq**************@TK2MSFTNGP12.phx.gbl> <OU**************@tk2msftngp13.phx.gbl>
<Oa**************@TK2MSFTNGP09.phx.gbl>
<om**************@cpmsftngxa06.phx.gbl>
<Od**************@TK2MSFTNGP12.phx.gbl>
<Lg**************@cpmsftngxa06.phx.gbl>Subject: Re: Remoting questions
Date: Tue, 21 Oct 2003 14:05:09 +0100
Lines: 44
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
Message-ID: <#X**************@TK2MSFTNGP12.phx.gbl>
Newsgroups: microsoft.public.dotnet.languages.vb
NNTP-Posting-Host: dsl213-218-228-203.as15444.net 213.218.228.203
Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTN GP12.phx.gbl
Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.vb:148643
X-Tomcat-NG: microsoft.public.dotnet.languages.vb

Hi Peter,
http://staff.develop.com/woodring/dotnet/
Excuse me, but this is very difficult to explain...

I have been looking at the example thoroughly, unfortunately it is in C#,

soI am a little unsure on a few minor details.

Firstly, the events are raised via the eventShim class, unfortunately I
can't for the life of me see 1 solid reference to the eventshim class in thecode!! So I am slightly confused as to how the server could possibly use
the class to forward events when it doesn't even have a reference to or knowabout the class.

EventShim is in the calcif.cs i.e. calcif.dll
You can see the calcif.dll will be referenced in both the server and client.

I would have thought that the server would create a singleton of the
eventshim class and use that to forward to all registered clients, but the
server doesn't even use it! The eventshim class is instantiated on the
client rather than the server.

You may try to see the app.config file of the server.
What the configure file do can also be done in the code.

Remoting Settings Schema
http://msdn.microsoft.com/library/de...us/cpgenref/ht
ml/gnconremotingsettingsschema.asp

<!-- server.exe.config -->
<configuration>
<system.runtime.remoting>
<application name="calcsrv">
<service>
<wellknown mode="Singleton" type="Calc, server" objectUri="calc" />
</service>
<channels>
<channel ref="http" port="999">
<clientProviders>
<formatter ref="binary" />
</clientProviders>
<serverProviders>
<formatter ref="binary" typeFilterLevel="Full"/> <!-- On the
1.1 runtime, add typeFilterLevel='Full' to the formatter element -->
</serverProviders>
</channel>
</channels>
</application>
</system.runtime.remoting>
</configuration>
For example, the server creates a new class, this class is exposed as a
remoting object. The class implements the interface desired for the
remoting object, which in-turn exposes the event. In my code I know that
the server is attempting to raise the event, as I have placed a messagebox
just before the line, but unfortunately the event never gets to the client!! Event is a kind of call back mechanism.
static void Main()
{
RemotingConfiguration.Configure("client.exe.config ");

ICalc c = (ICalc)
RemotingServices.Connect(typeof(ICalc),
ConfigurationSettings.AppSettings["calcURL"]);

MagicNumberCallback cb = EventShim.Create(new
MagicNumberCallback(OnMagicNumber));
c.MagicNumber += cb;//add event handle

Console.WriteLine("c.AppDomainName (Calc) = {0}", c.AppDomainName);
Console.WriteLine("2 + 2 (Calc) = {0}", c.add(2, 2));
//Server fire the MagicNumber event
//Client get the event and fire the event handle function OnMagicNumber

Console.WriteLine("4 + 4 (Calc) = {0}", c.add(4, 4));

c.MagicNumber -= cb;
}
I suppose my main question should be, where should the eventshim class be
created? Server side.
Is it simply used on the client side to recieve events? If that It is an remoting object with event declared.
is the case then how does the event even get there if it is not even linked
to the remoteable object? Very confusing example, and seeing as I am using
VB.NET Standard I cannot even see if it works as I would expect. Thanks foryour help again, I think I might scrap that one and read the advanced .net
remoting book. That is a good book, I think that book will give your many information.

If you have any related question, please feel free to let me know.

Nick.

--
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/ \"No matter. Whatever the outcome, you are changed."

Fergus - September 5th 2003
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/ \


Nov 20 '05 #8

P: n/a
Nak
Hi Peter,
D:\Program Files\Microsoft Visual Studio .NET
2003\SDK\v1.1\Samples\Technologies\Remoting\VB
I also has comments in line.


Aaah, I see I have the same for v1.0, I shall check it out, excellent thank
you :-)

Nick.

--
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
"No matter. Whatever the outcome, you are changed."

Fergus - September 5th 2003
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
Nov 20 '05 #9

P: n/a
Hi Nick,

I hope my suggestion can help you.

If you have any related question, please post here.

Regards,
Peter Huang
Microsoft Online Partner Support
Get Secure! www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
--------------------
From: "Nak" <a@a.com>
References: <Oq**************@TK2MSFTNGP12.phx.gbl> <OU**************@tk2msftngp13.phx.gbl>
<Oa**************@TK2MSFTNGP09.phx.gbl>
<om**************@cpmsftngxa06.phx.gbl>
<Od**************@TK2MSFTNGP12.phx.gbl>
<Lg**************@cpmsftngxa06.phx.gbl>
<#X**************@TK2MSFTNGP12.phx.gbl>
<LY**************@cpmsftngxa06.phx.gbl>Subject: Re: Remoting questions
Date: Wed, 22 Oct 2003 11:42:22 +0100
Lines: 19
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
Message-ID: <ej**************@TK2MSFTNGP12.phx.gbl>
Newsgroups: microsoft.public.dotnet.languages.vb
NNTP-Posting-Host: dsl213-218-227-57.as15444.net 213.218.227.57
Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTN GP12.phx.gbl
Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.vb:148990
X-Tomcat-NG: microsoft.public.dotnet.languages.vb

Hi Peter,
D:\Program Files\Microsoft Visual Studio .NET
2003\SDK\v1.1\Samples\Technologies\Remoting\VB
I also has comments in line.
Aaah, I see I have the same for v1.0, I shall check it out, excellent thank
you :-)

Nick.

--
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/

\"No matter. Whatever the outcome, you are changed."

Fergus - September 5th 2003
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/ \


Nov 20 '05 #10

This discussion thread is closed

Replies have been disabled for this discussion.