首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >C# -在Visual Studio外部执行应用程序时出现问题

问C# -在Visual Studio外部执行应用程序时出现问题
EN

Stack Overflow用户
提问于 2019-05-28 02:11:30
回答 1查看 75关注 0票数 3

我在应用程序中执行实现时遇到问题。我有一些可以在Visual Studio中正常工作、运行和访问其信息的its服务。

例如,可以通过IE访问与are服务地址的连接,并且服务是正常的。

我在应用程序中执行可执行文件,当它试图访问get服务时,我得到403 (禁止)错误。

凭据很好,因为触发错误的行是在身份验证完成后使用webservice的方法时触发的。

即使在应用程序中以管理员权限运行,它也会显示相同的错误。并且WCF服务由本地管理员用户运行。

我已经尝试在与正在使用的方法相同的作用域中请求,但没有成功。

代码语言:javascript
复制
private SI_Out_SyncClient WebserviceConnection ()
{

    BasicHttpBinding binding = new BasicHttpBinding(BasicHttpSecurityMode.TransportCredentialOnly);

    binding.MaxBufferSize = 2147483647;
    binding.MaxReceivedMessageSize = 2147483647;

    binding.CloseTimeout = new TimeSpan(1, 5, 0);
    binding.OpenTimeout = new TimeSpan(1, 5, 0);
    binding.SendTimeout = new TimeSpan(1, 5, 0);

    binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Basic;
    binding.Security.Transport.ProxyCredentialType = HttpProxyCredentialType.Basic;

    EndpointAddress address = new EndpointAddress(Library.Environment.GetGlobalString("ENDPOINT"));

    var client = new SI_Out_SyncClient(binding, address);

    client.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation;
    client.ClientCredentials.UserName.UserName = Library.Environment.GetGlobalString("USER");
    client.ClientCredentials.UserName.Password = Library.Environment.GetGlobalString("PASSWORD");

    return client;
}

我希望在应用程序中运行,因为我可以在debug中运行,但以正确的方式运行,而不是将debug编译模式设置为true。

提前感谢!

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-05-28 20:57:09

我知道是怎么回事了。

在我的例子中,运行WCF服务的管理员用户没有访问互联网。

这是一个愚蠢的错误,但值得注册,因为我在研究中没有发现这样的方向。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/56330700

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档