gpt4 book ai didi

dll - 找不到类型或命名空间名称 `HolidayService2'。您是否缺少程序集引用?

转载 作者:行者123 更新时间:2023-12-04 17:02:01 25 4
gpt4 key购买 nike

在 Linux 上,我如何编译和执行 holidayclient.cs ? A using进口是 required , 当然。还有一个 namespace ?

thufir@dur:~/wsdl$ 
thufir@dur:~/wsdl$ ls
thufir@dur:~/wsdl$
thufir@dur:~/wsdl$ wsdl http://api.google.com/GoogleSearch.wsdl
Web Services Description Language Utility
Mono Framework v4.0.30319.42000
Error: ThereWasAnErrorDownloading0
Stack:
at System.Web.Services.Discovery.DiscoveryClientProtocol.Download (System.String& url, System.String& contentType) [0x000b1] in <df933ee897464fb99338a340b9d5761d>:0
at System.Web.Services.Discovery.DiscoveryClientProtocol.DiscoverAny (System.String url) [0x0000f] in <df933ee897464fb99338a340b9d5761d>:0
at (wrapper remoting-invoke-with-check) System.Web.Services.Discovery.DiscoveryClientProtocol:DiscoverAny (string)
at Mono.WebServices.Driver.Run (System.String[] args) [0x000f5] in <24b8cb9db67d4a19a4db9642439f119f>:0
thufir@dur:~/wsdl$
thufir@dur:~/wsdl$ wsdl http://holidaywebservice.com/HolidayService_v2/HolidayService2.asmx
Web Services Description Language Utility
Mono Framework v4.0.30319.42000
Writing file 'HolidayService2.cs'
thufir@dur:~/wsdl$
thufir@dur:~/wsdl$ mcs /target:library HolidayService2.cs -r:System.Web.Services
thufir@dur:~/wsdl$
thufir@dur:~/wsdl$ ls
HolidayService2.cs HolidayService2.dll
thufir@dur:~/wsdl$
thufir@dur:~/wsdl$ nano holidayclient.cs
thufir@dur:~/wsdl$
thufir@dur:~/wsdl$ cat holidayclient.cs
using System;

class HolidayClient
{
public static void Main (string [] args)
{
HolidayService2 holiday = new HolidayService2 ();

String response = holiday.foo ("hmm");

Console.WriteLine(response);
}
}
thufir@dur:~/wsdl$
thufir@dur:~/wsdl$ mcs holidayclient.cs
holidayclient.cs(7,9): error CS0246: The type or namespace name `HolidayService2' could not be found. Are you missing an assembly reference?
holidayclient.cs(9,27): error CS0841: A local variable `holiday' cannot be used before it is declared
Compilation failed: 2 error(s), 0 warnings
thufir@dur:~/wsdl$

不确定要单击哪些按钮 MonoDevelop使用 CLI 也是如此。

引用:

http://www.mono-project.com/archived/consuming_a_webservice/

http://holidaywebservice.com/HolidayService_v2/HolidayService2.asmx?op=GetHolidayDate

https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/compiler-messages/cs0246

最佳答案

在 MonoDevelop (MD) 中,您需要创建一个您想要的类型(表单、控制台、Web 等)的新项目,并将您的 HolidayClient.cs 代码添加到其中。您需要确保代码中的命名空间与项目中的命名空间一致,以保持简单。使用 MD 添加对 HolidayService.dll 程序集的引用(右键单击“项目/引用”并选择“编辑引用...”,然后找到 .NET 程序集选项卡并跟随您的 Nose 浏览并加载引用)。完成此操作后,您应该能够在代码中调用服务客户端。

关于dll - 找不到类型或命名空间名称 `HolidayService2'。您是否缺少程序集引用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48854482/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com