相关疑难解决方法(0)

如何以编程方式修改WCF app.config端点地址设置?

我想以编程方式修改我的app.config文件以设置应该使用哪个服务文件端点.在运行时执行此操作的最佳方法是什么?以供参考:

<endpoint address="http://mydomain/MyService.svc"
    binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IASRService"
    contract="ASRService.IASRService" name="WSHttpBinding_IASRService">
    <identity>
        <dns value="localhost" />
    </identity>
</endpoint>
Run Code Online (Sandbox Code Playgroud)

c# wcf app-config configuration-files

49
推荐指数
5
解决办法
10万
查看次数

以编程方式添加端点

我有一个WCF服务,我在客户端应用程序中连接.我在配置文件中使用以下.

<system.serviceModel>  
    <bindings>  
      <basicHttpBinding>  
        <binding name="MyNameSpace.TestService" closeTimeout="00:01:00" openTimeout="00:01:00"  
            receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false"  
            bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"  
            maxBufferSize="2147483647" maxBufferPoolSize="524288" maxReceivedMessageSize="2147483647"  
            messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"  
            useDefaultWebProxy="true">  
          <readerQuotas maxDepth="32" maxStringContentLength="2147483647" maxArrayLength="16384"  
              maxBytesPerRead="4096" maxNameTableCharCount="16384" />  
          <security mode="None">  
            <transport clientCredentialType="None" proxyCredentialType="None"  
                realm="" />  
            <message clientCredentialType="UserName" algorithmSuite="Default" />  
          </security>  
        </binding>  
      </basicHttpBinding>  
    </bindings>  
    <client>  
      <endpoint address="http://localhost:9100/TestService" binding="basicHttpBinding"  
          bindingConfiguration="MyNameSpace.TestService" contract="TestService.IService" name="MyNameSpace.TestService" />  
    </client>  
</system.serviceModel>  
Run Code Online (Sandbox Code Playgroud)

在代码中,我在此服务上调用API,如下所示,

TestServiceClient client = new TestServiceClient()
client.BlahBlah()
Run Code Online (Sandbox Code Playgroud)

现在我想用porgramatically定义端点.怎么办?我在配置文件中注释掉了部分,因为我认为我必须在TestServiceClient实例上放置一些代码来动态添加端点,然后在实例化TestServiceClient时抛出异常.

无法在ServiceModel客户端配置部分中找到引用合同"TestService.IService"的默认端点元素.这可能是因为没有为您的应用程序找到配置文件,或者因为在客户端元素中找不到与此合同匹配的端点元素.

我怎么能做到这一点?此外,以编程方式添加端点的代码示例的任何一点都将受到赞赏.

wcf wcf-endpoint

3
推荐指数
1
解决办法
6367
查看次数

SQL Server错误 - 已从调用COM组件返回HRESULT E_FAIL

我有一个巨大的200MB .SQL文件.当我尝试在SQL Server Management Studio 2008中打开它时,我收到错误-Error HRESULT E_FAIL已从调用COM组件返回.

原因是什么以及如何解决?这是由于大文件引起的吗?当我打开2-3 KB文件时不会发生这种情况.

sql-server ssms sql-server-2008

2
推荐指数
1
解决办法
2万
查看次数