Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/wcf/4.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
Silverlight&x2B;WCF通信异常_Silverlight_Wcf_Localhost - Fatal编程技术网

Silverlight&x2B;WCF通信异常

Silverlight&x2B;WCF通信异常,silverlight,wcf,localhost,Silverlight,Wcf,Localhost,我有一个silverlight应用程序,其中有一个WCF。调用wcf时,它会失败,出现以下异常: An error occurred while trying to make a request to URI 'http://localhost:4693/MapService.svc'. This could be due to attempting to access a service in a cross-domain way without a proper cross-domain p

我有一个silverlight应用程序,其中有一个WCF。调用wcf时,它会失败,出现以下异常:

An error occurred while trying to make a request to URI 'http://localhost:4693/MapService.svc'. This could be due to attempting to access a service in a cross-domain way without a proper cross-domain policy in place, or a policy that is unsuitable for SOAP services. You may need to contact the owner of the service to publish a cross-domain policy file and to ensure it allows SOAP-related HTTP headers to be sent. This error may also be caused by using internal types in the web service proxy without using the InternalsVisibleToAttribute attribute. Please see the inner exception for more details.
silverlight和WCF都是从本地运行的

我的silverlight正在从以下位置运行:

...\SilverlightApplication1\SilverlightApplication1\Bin\Release\SilverlightApplication1TestPage.html
这是WCF web.config服务标记:

<services>
        <service behaviorConfiguration="FileUpAndDownload.Web.MapServiceBehavior" name="FileUpAndDownload.Web.MapService">
            <endpoint address="" binding="basicHttpBinding" bindingConfiguration="MapBinding" contract="FileUpAndDownload.Web.IMapService">
                <identity>
                    <dns value="localhost"/>
                </identity>
            </endpoint>
            <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
        </service>
    </services>

这是ServiceReference.ClientConfig:

<configuration>
<system.serviceModel>
    <bindings>
        <basicHttpBinding>
            <binding name="BasicHttpBinding_IMapService" maxBufferSize="2147483647"
                maxReceivedMessageSize="2147483647">
                <security mode="None" />
            </binding>
        </basicHttpBinding>
    </bindings>
    <client>
        <endpoint address="http://localhost:4693/MapService.svc" binding="basicHttpBinding"
            bindingConfiguration="BasicHttpBinding_IMapService" contract="MapService.IMapService"
            name="BasicHttpBinding_IMapService" />
    </client>
</system.serviceModel>

我已将clientaccesspolicy.xml放在bin\release中,但没有帮助


救命啊

您需要一些额外的配置来执行跨域调用请参见:http://www.dotnetcurry.com/ShowArticle.aspx?ID=208&AspxAutoDetectCookieSupport=1


您可能将clientaccesspolicy.xml放在了错误的位置,请检查您的IIS日志以查找未找到的文件错误。

客户端访问策略文件必须位于wwwroot文件夹中。

与从web服务器运行Silverlight相比,在本地运行Silverlight存在问题。 访问权限不同,Silverlight将无法访问任何Web服务。 我很久以前在SL2上遇到过这个问题,我想它可能已经改变了

您应该在VisualStudio中创建一个新的WebApplication项目,并在其中托管Silverlight。
那么您的SL客户端连接到该服务就不会有问题。

如果我没有IIS,wwwroot文件夹是什么?您需要确保可以使用相同的uri前缀访问ClientConfig文件。例:。例如,如果使用开发服务器,则右键单击其属性并找到物理路径。另外,请确保在使用ClientAccessPolicy文件时正确定义了端口号。出于测试目的,我总是使用跨域文件。