При отладке приложения Silverlight в Visual Studio, я получаю это исключение:System.ServiceModel.CommunicationException был необработанное с помощью пользовательского кода сообщения = Произошла ошибка при попытке сделать запрос к URI
System.ServiceModel.CommunicationException was unhandled by user code
Message=An error occurred while trying to make a request to URI 'http://localhost:8733/Design_Time_Addresses/WcfForecastService/Service1/'. 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.EndCall(String action, Object[] outs, IAsyncResult result)
at System.ServiceModel.ClientBase`1.ChannelBase`1.EndInvoke(String methodName, Object[] args, IAsyncResult result)
at RollingActivityForecast.Services.ForecastServiceClient.ForecastServiceClientChannel.EndGetForecasts(IAsyncResult result)
at RollingActivityForecast.Services.ForecastServiceClient.RollingActivityForecast.Services.IForecastService.EndGetForecasts(IAsyncResult result)
at RollingActivityForecast.Services.ForecastServiceClient.OnEndGetForecasts(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__DisplayClassa.<EndGetResponse>b__9(Object sendState)
at System.Net.Browser.AsyncHelper.<>c__DisplayClass4.<BeginOnUI>b__0(Object sendState)
InnerException:
Когда я раскрываю приложение для inetpub и перейдите к нему изнутри диспетчера IIS, он отлично работает без каких-либо исключений, так как я добавил файлы clientaccesspolicy.xml и crossdomain.xml в службу.
Так что я задаю вопрос, где разместить файлы clientaccesspolicy.xml/crossdomain.xml в моем решении Visual Studio, чтобы я прекратил получать это исключение при отладке?
Я думал, что он должен идти в проекте MySilverlightApp.Web рядом с файлом web.config, но я все еще получаю исключение, когда я это делаю. Нужно ли добавить что-то лишнее в файл web.config для ссылки на файл clientaccesspolicy.xml?
FYI У меня есть служба WCF в отдельном проекте из проекта MySilverlightApp.Web.
TIA.
UPDATE:
Вот файлы:
clientaccesspolicy.xml:
<?xml version="1.0" encoding="utf-8"?>
<access-policy>
<cross-domain-access>
<policy>
<allow-from http-request-headers="*">
<domain url="*"/>
</allow-from>
<grant-to>
<resource path="/" include-subpaths="true"/>
</grant-to>
</policy>
</cross-domain-access>
</access-policy>
crossdomain.xml:
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE cross-domain-policy SYSTEM
"http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd">
<cross-domain-policy>
<allow-http-request-headers-from domain="*" headers="*"/>
</cross-domain-policy>
Благодарим за сообщение. Да, я забыл упомянуть, что я уже установил «Копировать всегда», но я все еще получаю ошибку. Предполагается ли, что эти файлы находятся в том же каталоге, что и служба WCF? – Roger