Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

close connection to server .net remoting

Posted on 2009-02-19
14
Medium Priority
?
1,721 Views
Last Modified: 2012-05-06
Hi

How do I close a client connection to a server so that others can use it?

Using .net remoting.

Thanks
0
Comment
Question by:gustierng
  • 8
  • 6
14 Comments
 
LVL 6

Expert Comment

by:Jammer59
ID: 23684814
What type of .net remoting object are you calling?  The answer varies depending on if it is using JustInTimeActivation or not.  
If you are not using JustInTimeActivation, I would use try, catch, finally within my code.
Within the try block, declare and instantiate your serviced component.  Within the finally block, dispose of it.  
If you had a remote service called NorthwindSC, you would instantiate it within the try block with:  
NorthwindSC nsc = new NorthwindSC();
To dispose of it in the finally block,
nsc.Dispose();
If the .net remoting object uses JustInTimeActivation, the Dispose will actually dispose of the object and then reopen it, resulting in more work for the server.
I would suggest also looking at ObjectPooling to allow more users to simultaneously access the remote object.
Hope this helps.
 
0
 

Author Comment

by:gustierng
ID: 23690487
I am not using JustInTimeActivation.

ok, so i just use Dispose.  

Thank you
0
 
LVL 6

Expert Comment

by:Jammer59
ID: 23691697
Glad I could help.
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

Author Comment

by:gustierng
ID: 23720159
I can't seem to find where to use dispose.  The client object doe not seem to have this method.  Please explain or point me to a link that explains in more details.

Thank you
0
 
LVL 6

Expert Comment

by:Jammer59
ID: 23720942
Am I correct in assuming you have code that at a minimum includes a TRY and a FINALLY block?  
Prior to the TRY block, you would instantiate your object. Within the TRY block, you should perform some action with your object.  If an error occurs the CATCH block should perform some action.  The FINALLY block will happen whether or not an error occurs and is where the dispose should occur.
Private Sub btnExecute_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExecute.Click
NorthwindSC nsc = New NorthwindSC
  Try
    ' Call the ExecuteQuery() method of the
    ' NorthwindSC serviced component to execute
    ' query and bind the results to the data grid
    dgResults.DataSource = nsc.ExecuteQuery(txtQuery.Text)
    dgResults.DataMember = "Results"
    dgResults.DataBind()
  Catch ex As Exception
    Response.Write(ex.Message & ": Invalid Query")
  Finally
    nsc.Dispose()
  End Try
End Sub  
This article written in VB.Net should help you.
http://www.dotnetjohn.com/articles.aspx?articleid=163
0
 
LVL 6

Expert Comment

by:Jammer59
ID: 23720960
I was a little hasty with my last response.  You said the object does not support the Dispose method.  Is the object written in house or a purchased component?  Can you post additional information or sample code?
0
 

Author Comment

by:gustierng
ID: 23721233
can you send an example that uses .net remoting please
0
 
LVL 6

Expert Comment

by:Jammer59
ID: 23723667
.Net remoting is a very broad category.  
Can you provide more details about what the .net remote object actually does?  Does it access a database, perform some complex function?
Can you tell me about the .net remoting object you are calling or post the client code you are calling it with (and web or app config files that may define Channels)?
Who wrote the .net remoting object?  Is it from a 3rd party or written internally?
Is it a Server Activate Object (SAO) or a Client Activated Object (CAO)?  It is most likely a CAO and we may need to look at client leases.  
What Channels do you use to communicate with the server?  HTTP or TCP?  
What development language are you using to build your client?
Most of my experience is related to a few third party .net remoting applications and training manuals.  I would recommend reading the Developing XML Web Services and Server Components with Visual C#.Net and .Net Framework - EXAM 70-320.  The author is Amit Kalani.  He has written an equivalent book for VB.Net.  
That will be a good start for now.  I may have more questions to follow before I can give you a complete example.
0
 

Author Comment

by:gustierng
ID: 23724545
To answer your questions:

This is using .net remoting, so the ChannelServices.RegisterChannel to setup the channel and Activator.GetObject used to create a connection to the shared port. Singleton, TCP, C#.

Fairly complex as high speed reading and writing
0
 
LVL 6

Expert Comment

by:Jammer59
ID: 23737040

Thank you for your response.  I am starting to think I may not be able to help you.  
Thinking out loud....
Singleton method initiated and running on server.  By default multiple clients should have access to the remote service.  
Why would your client lock the service and not allow others to access it?  Do other client applications exist which call the remote service that do not hang the service?  My thought is of course there are other client apps that work.  
What is different about your machine or your app from the others on the network?  Are all clients using the same .Net framework?  What .Net framework do you use?  Do you have multiple .Net  frameworks installed on the client?
Again, let me apologize for not being able to resolve this for you.  If you would like to close this question, not award any points and open a new question, I will understand.  
I would be interested in understanding the solution to your problem.
0
 

Author Comment

by:gustierng
ID: 23743279
the versions of .net are the same but versions of VS2005 are different
0
 
LVL 6

Expert Comment

by:Jammer59
ID: 23744259
Time for some basic troubleshooting.
You need to isolate whether the client app is the issue or your computer is the issue.
If you copy your client app to another computer and execute it, does it also not close the client connection.
Can you run other client apps which talk to the remote service from your machine without a problem?
Other alternatives.
Could the remote service be rewritten in COM+ to allow for object pooling?
0
 

Author Comment

by:gustierng
ID: 23745033
yes i would like to be able to close the client connection
0
 
LVL 6

Accepted Solution

by:
Jammer59 earned 1500 total points
ID: 23746639
Can you post your client code?
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
Hello there! As a developer I have modified and refactored the unit tests which was written by fellow developers in the past. On the course, I have gone through various misconceptions and technical challenges when it comes to implementation. I would…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
The Relationships Diagram is a good way to get an overall view of what a database is keeping track of. It is also where relationships are defined. A relationship specifies how two tables connect to each other. As you build tables in Microsoft Ac…

564 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question