一般说明
我从Silverlight应用程序调用启用Silverlight的WCF服务。我的服务查询数据库(SQL Server)并从那里返回值。问题是该服务使用其他库来执行脏数据库工作,并且在尝试使用该服务时出现此异常:
异常
System.ServiceModel.CommunicationException was unhandled by user code Message="An error occurred while trying to make a request to URI 'mysite/myservice.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." StackTrace:
at System.ServiceModel.AsyncResult.End[TAsyncResult](IAsyncResult result)
at System.ServiceModel.Channels.ServiceChannel.SendAsyncResult.End(SendAsyncResult result)
at System.ServiceModel.Channels.ServiceChannel.EndCall(String action, Object[] outs, IAsyncResult result)
at System.ServiceModel.ClientBase`1.ChannelBase`1.EndInvoke(String methodName, Object[] args, IAsyncResult result)
at ODP_Silverlight.ODP.WCFServices.PropertySetWcfServiceClient.PropertySetWcfServiceClientChannel.EndGetPropertySet(IAsyncResult result)
at ODP_Silverlight.ODP.WCFServices.PropertySetWcfServiceClient.ODP_Silverlight.ODP.WCFServices.PropertySetWcfService.EndGetPropertySet(IAsyncResult result)
at ODP_Silverlight.ODP.WCFServices.PropertySetWcfServiceClient.OnEndGetPropertySet(IAsyncResult result)
at System.ServiceModel.ClientBase`1.OnAsyncCallCompleted(IAsyncResult result) InnerException: System.Security.SecurityException
Message=""
StackTrace:
at System.Net.Browser.AsyncHelper.BeginOnUI(SendOrPostCallback beginMethod, Object state)
at System.Net.Browser.BrowserHttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelAsyncRequest.CompleteGetResponse(IAsyncResult result)
InnerException: System.Security.SecurityException
Message="Security error."
StackTrace:
at System.Net.Browser.BrowserHttpWebRequest.InternalEndGetResponse(IAsyncResult asyncResult)
at System.Net.Browser.BrowserHttpWebRequest.<>c__DisplayClass5.<EndGetResponse>b__4(Object sendState)
at System.Net.Browser.AsyncHelper.<>c__DisplayClass2.<BeginOnUI>b__0(Object sendState)
InnerException:
更多信息
如果我从using mylibs
语句中删除“using
”,只返回一些简单的List&lt; int&gt;只需几个数字,服务就可以了。
任何人的见解?
答案 0 :(得分:0)
使用mylibs不会调用任何代码。只有mylibs里面的代码可以做到这一点。这似乎是失败的。你应该测试它。
请注意,由于此服务正在服务器上运行(而不是在使用SilverLight的浏览器上),因此问题不能是SilverLight权限。
答案 1 :(得分:0)
您是否在WCF服务上实现了ClientAccessPolicy.xml和CrossDomain.xml?您收到的CommunicationException可能是由于缺少ClientAccessPolicy.xml文件或者不允许Silverlight客户端访问该服务的文件引起的。