我正在尝试使用更简单的消费客户端(控制台应用程序)创建一个简单的ASP.NET Web服务,以测试我之前制作的.dll中公共类的传递。
由于某种原因,它不会编译并返回此错误:
参数1:无法从'BDMTSShipLibrary.ShipBaseClass'转换为 'BdmtsServiceTester.localhost.ShipBaseClass'
BdmtsPing方法工作得很好,但是一旦我尝试传递自定义类参数就会死掉。
服务代码:
public class BdmtsService : System.Web.Services.WebService
{
[WebMethod]
public string HelloWorld()
{
return "Hello World";
}
[WebMethod]
public string BdmtsPing(int i)
{
string output = "";
for (int p = 0; p <= i; p++)
output += "Server is alive!\n";
return string.Format(output + "Done!");
}
[WebMethod]
public string PassTheShip(ShipBaseClass ship)
{
return ship.BaseShipToString();
}
}
我的客户:
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Client is live...");
localhost.BdmtsService myService = new localhost.BdmtsService();
Console.WriteLine(myService.BdmtsPing(5));
Console.WriteLine("\n");
ShipBaseClass myShip = new ShipBaseClass();
Console.WriteLine(myService.PassTheShip(myShip););
Console.ReadKey();
}
}
ShipBaseClass在.dll中定义,在服务的.asmx和客户端的.cs中由“using”引用。
在我看来,编译器并不认为所有的ShipBaseClasses都相同,但我的问题是什么?