gustierng
asked on
close connection to server .net remoting
Hi
How do I close a client connection to a server so that others can use it?
Using .net remoting.
Thanks
How do I close a client connection to a server so that others can use it?
Using .net remoting.
Thanks
ASKER
I am not using JustInTimeActivation.
ok, so i just use Dispose.
Thank you
ok, so i just use Dispose.
Thank you
Glad I could help.
ASKER
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
Thank you
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.a spx?articl eid=163
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.
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/
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?
ASKER
can you send an example that uses .net remoting please
.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.
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.
ASKER
To answer your questions:
This is using .net remoting, so the ChannelServices.RegisterCh annel 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
This is using .net remoting, so the ChannelServices.RegisterCh
Fairly complex as high speed reading and writing
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.
ASKER
the versions of .net are the same but versions of VS2005 are different
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?
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?
ASKER
yes i would like to be able to close the client connection
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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.