Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.net Silverlight开发-本地开发时的服务URL_.net_Silverlight - Fatal编程技术网

.net Silverlight开发-本地开发时的服务URL

.net Silverlight开发-本地开发时的服务URL,.net,silverlight,.net,Silverlight,在单个解决方案中开发Silverlight应用程序(Silverlight项目和Web应用程序)的正确模式或方法是什么?我的意思是,如果本地主机端口号将不断变化,您如何添加服务引用 谢谢。如果在解决方案资源管理器中选择web项目,则可以在“属性工具”窗口中更改属性,以阻止端口更改。属性被调用,您希望将其设置为false,以便端口保持静态 您还可以在这些设置中指定端口号 请注意,这不是在项目的属性页中,而是在属性工具窗口中,这可能就是为什么很难找到它的原因-我花了相当长的时间自己解决了这个问题 使

在单个解决方案中开发Silverlight应用程序(Silverlight项目和Web应用程序)的正确模式或方法是什么?我的意思是,如果本地主机端口号将不断变化,您如何添加服务引用


谢谢。

如果在解决方案资源管理器中选择web项目,则可以在“属性工具”窗口中更改属性,以阻止端口更改。属性被调用,您希望将其设置为false,以便端口保持静态

您还可以在这些设置中指定端口号

请注意,这不是在项目的属性页中,而是在属性工具窗口中,这可能就是为什么很难找到它的原因-我花了相当长的时间自己解决了这个问题

使现代化 为了在部署和开发之间切换,我倾向于指定两个SOAP绑定,然后使用ifdef DEBUG根据构建类型切换SOAP客户端的绑定。调试构建指向开发服务,发布构建指向部署的服务

因此,我的ClientConfig类似于:

<configuration>
  <system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding name="Soap_Debug" maxBufferSize="2147483647"
          maxReceivedMessageSize="2147483647">
          <security mode="None" />
        </binding>
        <binding name="Soap_Release" maxBufferSize="2147483647"
          maxReceivedMessageSize="2147483647">
          <security mode="None" />
        </binding>
      </basicHttpBinding>
    </bindings>
    <client>
      <endpoint address="http://www.mymadeupurl.com/myservices.asmx"
        binding="basicHttpBinding" bindingConfiguration="Soap_Release"
        contract="MyServices.MyServicesSoap" name="Soap_Release" />
      <endpoint address="http://localhost:1929/mydservices.asmx"
        binding="basicHttpBinding" bindingConfiguration="Soap_Debug"
        contract="MyServices.MyServicesSoap" name="Soap_Debug" />
    </client>
  </system.serviceModel>
</configuration>

如果在解决方案资源管理器中选择web项目,则可以在“属性”工具窗口中更改属性,以阻止端口更改。属性被调用,您希望将其设置为false,以便端口保持静态

您还可以在这些设置中指定端口号

请注意,这不是在项目的属性页中,而是在属性工具窗口中,这可能就是为什么很难找到它的原因-我花了相当长的时间自己解决了这个问题

使现代化 为了在部署和开发之间切换,我倾向于指定两个SOAP绑定,然后使用ifdef DEBUG根据构建类型切换SOAP客户端的绑定。调试构建指向开发服务,发布构建指向部署的服务

因此,我的ClientConfig类似于:

<configuration>
  <system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding name="Soap_Debug" maxBufferSize="2147483647"
          maxReceivedMessageSize="2147483647">
          <security mode="None" />
        </binding>
        <binding name="Soap_Release" maxBufferSize="2147483647"
          maxReceivedMessageSize="2147483647">
          <security mode="None" />
        </binding>
      </basicHttpBinding>
    </bindings>
    <client>
      <endpoint address="http://www.mymadeupurl.com/myservices.asmx"
        binding="basicHttpBinding" bindingConfiguration="Soap_Release"
        contract="MyServices.MyServicesSoap" name="Soap_Release" />
      <endpoint address="http://localhost:1929/mydservices.asmx"
        binding="basicHttpBinding" bindingConfiguration="Soap_Debug"
        contract="MyServices.MyServicesSoap" name="Soap_Debug" />
    </client>
  </system.serviceModel>
</configuration>
像这个:

不要依赖ServiceReference.ClientConfig中设置的URL。在代码中设置URL。将WebService调用代码更改为以下代码:

      var webService = new YourWebService.YourWebServiceClient() // This is the default constructor, url will be read from the clientconfig file.

      Uri address = new Uri(Application.Current.Host.Source, "../YourService.svc"); // this url will work both in dev and after deploy.

      var webService = new YourWebService.YourWebServiceClient("YourServiceEndPointName", address.AbsolutePath);
像这个:

不要依赖ServiceReference.ClientConfig中设置的URL。在代码中设置URL。将WebService调用代码更改为以下代码:

      var webService = new YourWebService.YourWebServiceClient() // This is the default constructor, url will be read from the clientconfig file.

      Uri address = new Uri(Application.Current.Host.Source, "../YourService.svc"); // this url will work both in dev and after deploy.

      var webService = new YourWebService.YourWebServiceClient("YourServiceEndPointName", address.AbsolutePath);

+谢谢。那么从长远来看,您如何解决在生产服务器和本地开发之间移动的问题呢?您是否使用了类似这样的代码:在silverlight应用程序开始时选择不断变化的域?没问题。我与动态端口问题斗争了很长一段时间,所以我知道这是多么令人沮丧。+1谢谢。那么从长远来看,您如何解决在生产服务器和本地开发之间移动的问题呢?您是否使用了类似这样的代码:在silverlight应用程序开始时选择不断变化的域?没问题。我与动态端口问题斗争了很长一段时间,所以我知道这是多么令人沮丧。