[英]Using Web References in C# Code in Visual Studio 2008
In the beginning, I was trying to find any solution for my issue but I didn't find anything. 一开始,我试图为我的问题找到任何解决方案,但没有发现任何问题。
I am Dynamics NAV Developer so C# is not my "native" language ;) 我是Dynamics NAV Developer,所以C#不是我的“母语”;)
I have to connect my Win Form Application with Microsoft Dynamics NAV so I want to use Web Reference (SOAP). 我必须将Win Form应用程序与Microsoft Dynamics导航连接,因此我想使用Web参考(SOAP)。
This application is created for Smart devices (Windows Mobile 5.0) in Visual Studio 2008. 此应用程序是在Visual Studio 2008中为智能设备(Windows Mobile 5.0)创建的。
I added the Web Reference by right-clicking on my solution and selecting "Add Web Reference". 我通过右键单击解决方案并选择“添加Web参考”来添加Web参考。 My reference is named as "WS", so In my code (button click function) I try to use this reference ie entering WS.Collectors webservice = WS.Collectors();
我的参考名为“ WS”,因此在我的代码(按钮单击功能)中,我尝试使用此参考,即输入WS.Collectors webservice = WS.Collectors();
When I try to compile my project, I have the following error: 当我尝试编译我的项目时,出现以下错误:
Error 1 The type or namespace name 'WS' could not be found (are you missing a using directive or an assembly reference?) (...) 错误1找不到类型或名称空间名称'WS'(您是否缺少using指令或程序集引用?)(...)
I also tried to enter using WS.Collectors
but it's not working. 我也尝试using WS.Collectors
进入,但是它不起作用。
How can I use my Web Reference in my C# Code and add some data to it? 如何在C#代码中使用Web参考并向其中添加一些数据?
Thanks in advance! 提前致谢!
You need to add appconfig file where you specify your app setting 您需要在指定应用程序设置的地方添加appconfig文件
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<appSettings>
<add key="ServiceBaseUrl" value="http://yourserver" />
<add key="ServicePort" value="yourportvalue"/>
<add key="InstanceName" value="DynamicsNAV"/>
<add key="ServiceType" value="Codeunit"/>
<add key="ServiceName" value="Your Service Name" />
<add key="CompanyName" value="your company name"/>
<add key="ServiceBaseOther" value="WS"/>
<add key="UserName" value="YourUsername"/>
<add key="Password" value="YourPassword"/>
<add key="Domain" value="Your Domain"/>
<add key="TimeInterval" value="60000"/>
</appSettings>
</configuration>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.