General description
I am calling a Silverlight enabled WCF service from a Silverlight application. My service queries a database (SQL Server) and returns values from there. The problem is that the service uses other libraries that do the dirty database work and I get this exception when trying to use the service:
我从Silverlight应用程序调用启用Silverlight的WCF服务。我的服务查询数据库(SQL Server)并从那里返回值。问题是该服务使用其他库来执行脏数据库工作,并且在尝试使用该服务时出现此异常:
Exception
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:
More info
If I remove the "using mylibs
" from the using
statements and just return some simple List<int> with a few numbers instead, the service works just fine.
如果我从using语句中删除“使用mylibs”,只返回一些带有几个数字的简单List
Any insights anyone?
有谁有见解?
2 个解决方案
#1
The using mylibs doesn't call any code. Only the code inside of mylibs does that. It would appear to be failing. You should test it.
使用mylibs不会调用任何代码。只有mylibs里面的代码可以做到这一点。这似乎是失败的。你应该测试一下。
Note that since this service is running on the server (not on the browser with SilverLight), the problem cannot be SilverLight permissions.
请注意,由于此服务在服务器上运行(而不是在使用SilverLight的浏览器上),因此问题不能是SilverLight权限。
#2
Have you implemented ClientAccessPolicy.xml and CrossDomain.xml on the WCF service? A CommunicationException like the one you are receiving could be caused by a missing ClientAccessPolicy.xml file or one that is not allowing your Silverlight client access to the service.
您是否在WCF服务上实现了ClientAccessPolicy.xml和CrossDomain.xml?您收到的CommunicationException可能是由于缺少ClientAccessPolicy.xml文件或不允许Silverlight客户端访问该服务的文件引起的。
#1
The using mylibs doesn't call any code. Only the code inside of mylibs does that. It would appear to be failing. You should test it.
使用mylibs不会调用任何代码。只有mylibs里面的代码可以做到这一点。这似乎是失败的。你应该测试一下。
Note that since this service is running on the server (not on the browser with SilverLight), the problem cannot be SilverLight permissions.
请注意,由于此服务在服务器上运行(而不是在使用SilverLight的浏览器上),因此问题不能是SilverLight权限。
#2
Have you implemented ClientAccessPolicy.xml and CrossDomain.xml on the WCF service? A CommunicationException like the one you are receiving could be caused by a missing ClientAccessPolicy.xml file or one that is not allowing your Silverlight client access to the service.
您是否在WCF服务上实现了ClientAccessPolicy.xml和CrossDomain.xml?您收到的CommunicationException可能是由于缺少ClientAccessPolicy.xml文件或不允许Silverlight客户端访问该服务的文件引起的。