JUAN
JUAN

Reputation: 523

stopwatch is not working

i have create a web service using visual studio 2010, the web service receives 2 integers and the stopwach, one of the parameter also includes and out statement just as show in the nex example:

 public double[][] Parameters(int N_ele, int N_carac, Stopwatch inic, out Stopwatch ini_final)

wen i create a web aplication in visual studio a have to create a web reference in order to call the web service. When i call the web service i used the next code:

webclient.Serv1 service = new webclient.Serv1();
int element, caracteristic;
System.Diagnostics.Stopwatch time_sent = new System.Diagnostics.Stopwatch();
System.Diagnostics.Stopwatch time_respond = new System.Diagnostics.Stopwatch();
servicie.Parameters(ele, caract,time_sent, out time_respond);

how ever visual studio marks and error it says: cannot convert System.Diagnostics.Stopwatch to Application1.webclient.Serv1.Stopwatch

and also the same error in the out statement, if some can help me to find the reason of the error and how to solve it. also i am using the C#, visual studio, .NET framework 4 and 3, using two different web application.

Upvotes: 0

Views: 1635

Answers (2)

devio
devio

Reputation: 37215

Short answer: You cannot do that.

Long answer:

Referencing a web service in a VS project creates proxy classes for any class declared by the web service.

This means that if you expose the class System.Diagnostics.Stopwatch in a WS parameter, the client reference will create a local proxy class for Stopwatch, in your case Application1.webclient.Serv1.Stopwatch.

Therefore, you cannot pass a System.Diagnostics.Stopwatch on the client side where the server side declares the Stopwatch class.

I would be surprised if this proxy class contains more than just the public data members.

Upvotes: 0

Servy
Servy

Reputation: 203827

You are dealing with two classes that are both named Stopwatch. One is in the System.Diagnostics namespace, and the other is in the Application1.webclient.Serv1 namespace. Make sure that all of your Stopwatch instances are the same type of Stopwatch.

Upvotes: 2

Related Questions