我正在尝试构建一个概念验证 Csla 3.7/Silverlight 3 应用程序,并且一直在学习Rocky 的教程。这是一个非常简单的单表单/单业务对象数据编辑应用程序,直到我尝试配置 Wcf 以使 Silverlight 应用程序可以与数据门户通信之前,一切都很顺利。
我得到的错误是:
CommunicationException was unhandled by user code
An error occurred while trying to make a request to URI 'http://localhost:1406/WcfPortal.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 有点不了解。对于 Csla Silverlight 应用程序,我的设置非常简单。我有4个项目:
- CslaSilverlight : Silverlight 项目
- CslaSilverlight.Client:Silverlight 类库
- CslaSilverlight.Server:.NET 类库
- CslaSilverlight.Web:托管 SL 应用程序的 ASPNET 项目
一切都在我的笔记本电脑上在 Cassini 下本地运行。我希望 DataPortal 在 Silverlight 之外运行,以便我可以访问 SQL Server。我认为问题可能与我在 Silverlight 应用程序中的 Wcf 配置有关,该应用程序在 ServiceReferences.ClientConfig 文件中指定:
<configuration>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IWcfPortal" maxBufferSize="65536"
maxReceivedMessageSize="65536" receiveTimeout="10" sendTimeout="10">
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:1406/WcfPortal.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IWcfPortal"
contract="Csla.WcfPortal.IWcfPortal" name="BasicHttpBinding_IWcfPortal" />
</client>
</system.serviceModel>
</configuration>
我想知道端口号是否重要,当我更改它时,我会得到一个不同的错误。我也想知道端点地址的格式是否正确。
不确定它是否重要,但我在 ASPNet web.config 中的 serviceModel 设置是:
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="WcfPortalBehavior">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service behaviorConfiguration="WcfPortalBehavior" name="Csla.Server.Hosts.Silverlight.WcfPortal">
<endpoint address="" binding="basicHttpBinding" contract="Csla.Server.Hosts.Silverlight.IWcfPortal">
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
</system.serviceModel>