WCF Connection
-
Hello everyone,
ActiveDB.DBContractsClient _Proxy = new ActiveDB.DBContractsClient();
\_Proxy.Open(); \_Proxy.ExecuteQuery("Select 1", new object\[\] { }); \_Proxy.Close(); \_Proxy.Open(); \_Proxy.Close();
I have the following code to demonstrate my problem. Till the point where is the second open it works fine, but when it tries to open to connection for the second time it says cannot open object because it is disposed. Am I doing something worng or any ideas on how i may fix it? Thank you for any help.
-
Hello everyone,
ActiveDB.DBContractsClient _Proxy = new ActiveDB.DBContractsClient();
\_Proxy.Open(); \_Proxy.ExecuteQuery("Select 1", new object\[\] { }); \_Proxy.Close(); \_Proxy.Open(); \_Proxy.Close();
I have the following code to demonstrate my problem. Till the point where is the second open it works fine, but when it tries to open to connection for the second time it says cannot open object because it is disposed. Am I doing something worng or any ideas on how i may fix it? Thank you for any help.
It looks like
_Proxy.Close
automatically disposes of the object. I'd take a look into that if I were you. One way round it is to create a new instance ofActiveDB.DBContractsClient
before calling the second_Proxy.Open
.I have CDO, it's OCD with the letters in the right order; just as they ruddy well should be
Forgive your enemies - it messes with their heads
-
It looks like
_Proxy.Close
automatically disposes of the object. I'd take a look into that if I were you. One way round it is to create a new instance ofActiveDB.DBContractsClient
before calling the second_Proxy.Open
.I have CDO, it's OCD with the letters in the right order; just as they ruddy well should be
Forgive your enemies - it messes with their heads
The Issue is that I want to use the same instance i am using this in a web application and what I am doing is that I am creating this instance when the session starts and use the same instance for every operation that the user does in the application. And for every operation I want to open and close the connection to make sure that no connections are ever left open.
-
The Issue is that I want to use the same instance i am using this in a web application and what I am doing is that I am creating this instance when the session starts and use the same instance for every operation that the user does in the application. And for every operation I want to open and close the connection to make sure that no connections are ever left open.
You can't have it both ways unfortunately. Either it's disposed and you create a new instance every time, or you have to leave it open. It would be easier if you had control of the class itself, and could remove the Dispose out of there, but it looks like you don't have that option.
I have CDO, it's OCD with the letters in the right order; just as they ruddy well should be
Forgive your enemies - it messes with their heads
-
Hello everyone,
ActiveDB.DBContractsClient _Proxy = new ActiveDB.DBContractsClient();
\_Proxy.Open(); \_Proxy.ExecuteQuery("Select 1", new object\[\] { }); \_Proxy.Close(); \_Proxy.Open(); \_Proxy.Close();
I have the following code to demonstrate my problem. Till the point where is the second open it works fine, but when it tries to open to connection for the second time it says cannot open object because it is disposed. Am I doing something worng or any ideas on how i may fix it? Thank you for any help.
I was playing with WCF last spring, not with a web whatsis, and only opened the connection once, so I didn't encounter that. I'll take a look at what I can find out later.
-
The Issue is that I want to use the same instance i am using this in a web application and what I am doing is that I am creating this instance when the session starts and use the same instance for every operation that the user does in the application. And for every operation I want to open and close the connection to make sure that no connections are ever left open.