Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/sorting/2.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
C# ipaddress:port vs localhost:IIS 7上使用WCF托管silverlight Prism时的端口_C#_Wcf_Silverlight_Iis_Prism - Fatal编程技术网

C# ipaddress:port vs localhost:IIS 7上使用WCF托管silverlight Prism时的端口

C# ipaddress:port vs localhost:IIS 7上使用WCF托管silverlight Prism时的端口,c#,wcf,silverlight,iis,prism,C#,Wcf,Silverlight,Iis,Prism,这可能很简单,但请容忍我 当我使用WCF将我的Silverlight 5应用程序部署到IIS时,使用简单的复制和粘贴技术,我可以完美地浏览网站,但当我尝试通过ipaddress(如192.168.1.3:8099)访问它时,每次服务调用都会返回如下错误: An exception occurred during the operation, making the result invalid. Check InnerException for exception details. at .

这可能很简单,但请容忍我

当我使用WCF将我的Silverlight 5应用程序部署到IIS时,使用简单的复制和粘贴技术,我可以完美地浏览网站,但当我尝试通过ipaddress(如192.168.1.3:8099)访问它时,每次服务调用都会返回如下错误:

An exception occurred during the operation, making the result invalid.  Check InnerException for exception details.
  at .....
  at <MyNamespace>.OnGetSomethingFromDataBaseCompleted(Object state)
操作期间发生异常,导致结果无效。检查InnerException以了解异常详细信息。
在
at.OnGetSomethingFromDataBaseCompleted(对象状态)
我可以成功地将来自其他机器的WCF服务作为目标(192.168.1.3:8099/SomeService.svc)。 我编写了测试控制台应用程序来调用(并关闭)服务,它正确地从远程DBServer获取了一些数据。 但在浏览器中什么也没有

当导航到192.168.1.3:8099时,应该从浏览器中添加回Fiddler不注册此调用,但它从localhost:8099注册

你能帮忙吗?

我认为这对于比我更有部署经验的人来说是一个简单的问题,但如果您认为应该这样做,请继续阅读


因此,您正在阅读=>(Prism)

我有一个Silverlight应用程序,它连接到调用WCF服务的数据库(添加为Silverlight WCF服务-VSTemplate)

在这个应用程序中,我将介绍Prism-like建议

我还使用web代理从ViewModel访问WCF服务

我的项目结构:

  • 网络项目
  • 银光与地狱
  • 模B
  • 公共工程
部署目录结构:

C:\inetpub\wwwroot\MyAppFolder(IISUSER具有访问权限)
  • \bin\alldll
  • .\ClientBin\AllXapFiles(来自上述所有项目的XAP文件)
  • .\Services\n定义服务运营合同的所有*.cs文件
  • \Web.config
  • \TestPage.html
  • \TestPage.aspx
  • Silverlight.js
  • .\AllServices*.scv文件
最后但并非最不重要

  • .\clientaccesspolicy.xml
其中包含以下代码:

<?xml version="1.0" encoding="utf-8"?>
<access-policy>
  <cross-domain-access>
    <policy>
      <allow-from http-request-headers="*">
        <domain uri="*"/>"
      </allow-from>
      <grant-to>
        <resource path="/Services" include-subpaths="true"/><!--I tried with App_Code here when renaming Services dir to App_Code with the same wain result-->
      </grant-to>
    </policy>
  </cross-domain-access>
</access-policy>

"

感谢您阅读

这是我在卡洛斯·菲盖拉的帖子之后最后做的事情,并解决了我的问题。我不确定是否有更好的Silverlight 5解决方案,但它对我有效

public static void UpdateMyServiceAddress(WebServiceMyProxies.MyServiceClient client)
        {
            client.Endpoint.Address = UpdateServiceAddress(client.Endpoint.Address.Uri.ToString());
        }

private static System.ServiceModel.EndpointAddress UpdateServiceAddress(string originalAddress)
        {
            int svcIndex = originalAddress.IndexOf(".svc");
            int serviceNameIndex = originalAddress.LastIndexOf('/', svcIndex);
            string serviceName = originalAddress.Substring(serviceNameIndex + 1);

            string baseAddress = Application.Current.Host.Source.ToString();
            baseAddress = baseAddress.Substring(0, baseAddress.LastIndexOf('/')); // removing /App.xap
            baseAddress = baseAddress.Substring(0, baseAddress.LastIndexOf('/')); // removing /ClientBin

            return new System.ServiceModel.EndpointAddress(String.Format("{0}/{1}/{2}", baseAddress,"Services", serviceName));
        }
我目前正在退房,如果有帮助,我会让你知道。