App.config没有生成 [英] App.config is not generating

查看:368
本文介绍了App.config没有生成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在.NET visual studio代码中添加了一个服务引用,即WSDL。但它没有生成app.config文件。我也尝试在visual studio命令提示符下使用svcutil.exe。我还尝试在添加服务引用时单击高级按钮取消选中引用程序集中的重用类型。但是仍然没有生成App.config文件。



所以我在我的课程中添加了以下代码。但仍然是它给错误'找不到引用契约的默认端点元素'。



I have added a service reference i.e. a WSDL in my .NET visual studio code. But its not generating app.config file. I have also tried using the svcutil.exe in visual studio command prompt. I have also tried unchecking the 'Resuse types in referenced assemblies' by clicking the Advanced button while adding the service reference. But still App.config file is not generating.

So I have added the following code in my class. But still it is giving the error'could not find default endpoint element that references contract'.

client = new SalesLeadServiceClient();
_client.ClientCredentials.UserName.UserName = "***";
_client.ClientCredentials.UserName.Password = "***";

EndpointAddress endPointAddr = new EndpointAddress(address);
BasicHttpBinding binding = new BasicHttpBinding(BasicHttpSecurityMode.TransportWithMessageCredential);
binding.Security.Message.ClientCredentialType = BasicHttpMessageCredentialType.UserName;
_client = new SalesLeadServiceClient(binding, endPointAddr);
BindingElementCollection elements = _client.Endpoint.Binding.CreateBindingElements();
elements.Find<SecurityBindingElement>().IncludeTimestamp = false;
_client.Endpoint.Binding = new CustomBinding(elements);
igcomp.PrepareConnectSession(_client.ChannelFactory);





如果有人能就此提出任何解决方案,将不胜感激?



It will be grateful if anyone can suggest any solution on this?

推荐答案

根据我的理解,你必须手动添加它。请参阅:如何:将应用程序配置文件添加到C#项目 [ ^ ]



有关详细信息,请参阅:

如何:在配置中指定客户端绑定 [ ^ ]

如何:在配置中创建服务端点 [ ^ ]





我不像我希望的那样熟悉Web服务,但我找到了可能有用的链接:

找不到在ServiceModel clien中引用合同''的默认端点元素...... [ ^ ]

无法找到默认端点元素 [ ^ ]

无法找到引用合同的默认端点元素 [ ^ ]
As per my understanding, you have to add it manually. Please, see: How to: Add an Application Configuration File to a C# Project[^]

For further information, see:
How to: Specify a Client Binding in Configuration[^]
How to: Create a Service Endpoint in Configuration[^]


I'm not familiar with web services as much as i wish to be, but i have found links, which might be helpful:
Could not find default endpoint element that references contract '' in the ServiceModel clien...[^]
Could not find default endpoint element[^]
Could not find default endpoint element that references contract[^]


这篇关于App.config没有生成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆