My scenario is following..
I have created a WCF service in vs 2008.
added one reference to classlibrary1.dll
and added one Interface like
[OperationContract]
string Myclass2(Class1 c);
in Iservice1.cs.
and added this method
public string Myclass2(Class1 c)
{
c = new Class1();
return c.Name;
}
in my service1.svc.cs.
I have compiled the webservice and build succeeded.
Now I have created one client application in vs 2005.Its a web application.
Added web reference to this wcf service.
Also added reference to classlibrary1.dll.
used the namespace "using localhost".
and my code goes like this
Service1 ser = new Service1();
ClassLibrary1.Class1 c = ser.Myclass2(c);
then when i compile its giving error like
Error 1 The best overloaded method match for 'localhost.Service1.Myclass2(
Error 2 Argument '1': cannot convert from 'ClassLibrary1.Class1' to 'localhost.Class11'
I have tried all the possible way and the solution given in internet.but nothing is working.
Could nyone help me out in this regard?
Your help is highly appreciated
kishore vnPosted Jul 7, 2009, 10:37 AM
now servicehost obj =new servicehost(servicename)
obj.start()
at client side,
servicehost clinet=new servicehost()
client.mymethod(aaa)
soumen dePosted May 7, 2009, 5:12 AM
public string Myclass2(Class1 c)
{
c = new Class1();
return c.Name; // LOOK @ THIS LINE
}
It returns a string and expects to put in a object like
ClassLibrary1.Class1 c = ser.Myclass2(c);
Here ClassLibrary1.Class1 c need an object
and ser.Myclass2(c); returns string. See what u r doing.
you could probably do:
public Class1 Myclass2(Class1 c)
{
c = new Class1();
return c; // LOOK @ THIS LINE
}
NamithaPosted May 6, 2009, 12:05 AM
its nt like tht i have to esnt a class object only.
So m creating there object of class1 and passing it to service.
even if you do classlibrary1 class1 c;
and srtring name=ser.myclass2(c) error will be same.
soumen dePosted May 5, 2009, 8:32 AM
Look ser.Myclass2(c); returns a string whereas
ClassLibrary1.Class1 c expects a class, u could problay do
string name = ser.Myclass2(c);
Soumen, India