C# 无效URI:使用web服务时URI为空
在以下链接的帮助下,我在项目中添加了一个Web服务: 我已经按照这个链接的步骤动态地创建了ByURL 但问题是我的reference.cs中没有URI。我也没有web.config文件 当我运行客户端时,会出现以下错误:C# 无效URI:使用web服务时URI为空,c#,web-services,C#,Web Services,在以下链接的帮助下,我在项目中添加了一个Web服务: 我已经按照这个链接的步骤动态地创建了ByURL 但问题是我的reference.cs中没有URI。我也没有web.config文件 当我运行客户端时,会出现以下错误: Unhandled Exception: System.UriFormatException: Invalid URI: The URI is empty. at System.Uri.CreateThis(String uri, Boolean dontEscape, Uri
Unhandled Exception: System.UriFormatException: Invalid URI: The URI is empty.
at System.Uri.CreateThis(String uri, Boolean dontEscape, UriKind uriKind)
at System.Uri..ctor(String uriString)
at OCC_Client.pivClassTestClient.pivClassWebService.set_Url(String value) in
at OCC_Client.pivClassTestClient.pivClassWebService..ctor() in C:\Workspace\O
at OCC_Client.Program.Main(String[] args) in C:\Workspace\OCC_Client\OCC_Client
它指向reference.cs文件中的这段代码
public new string Url {
get {
return base.Url;
}
set {
if ((((this.IsLocalFileSystemWebService(base.Url) == true)
&& (this.useDefaultCredentialsSetExplicitly == false))
&& (this.IsLocalFileSystemWebService(value) == false))) {
base.UseDefaultCredentials = false;
}
base.Url = value;
}
}
请帮忙。我对web服务非常陌生 堆栈跟踪表明异常正在主方法中发生,请发布该代码。我怀疑您试图在未首先定义URL的情况下访问web服务。我必须在哪里定义URL?我让它充满活力。通过使其动态化,请提供帮助这意味着您可以在运行时以任何需要的方式提供它,但您必须在调用web服务之前提供它,否则它如何知道要连接到哪个web服务。为了提供更多帮助,我们需要查看调用web服务的代码。考虑到这一点,您是说您不知道将URL放在哪里,因为在文章中,它说将其添加到您的web配置中,但控制台应用程序没有web.config?如果是,您希望将其添加到app.config。