views:

17

answers:

1

Hi all,

I create a c# console project to read the excel document on the sharepoint server, everything works fine. The problem is when I try to read the excel file data in a silverlight application, a exception popped up as below:

{System.ServiceModel.CommunicationException: An error occurred while trying to make a request to URI 'http://phc/_vti_bin/excelservice.asmx'. 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. ---> System.Security.SecurityException ---> System.Security.SecurityException: Security error.
  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)
  --- End of inner exception stack trace ---
  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)
  --- End of inner exception stack trace ---
  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 CERViewer.ESW.ExcelServiceSoapClient.ExcelServiceSoapClientChannel.EndOpenWorkbook(IAsyncResult result)
  at CERViewer.ESW.ExcelServiceSoapClient.CERViewer.ESW.ExcelServiceSoap.EndOpenWorkbook(IAsyncResult result)
  at CERViewer.ESW.ExcelServiceSoapClient.EndOpenWorkbook(IAsyncResult result, ObservableCollection`1& status)
  at CERViewer.ESW.ExcelServiceSoapClient.OnEndOpenWorkbook(IAsyncResult result)
  at System.ServiceModel.ClientBase`1.OnAsyncCallCompleted(IAsyncResult result)}

The source code:

private void GetFeatures()
    {
      ExcelServiceSoapClient = new ExcelServiceSoapClient();
      string targetWorkbookPath = "http://phc/Shared%20Documents/sample.xlsx";

      xlservice.OpenWorkbookCompleted += new EventHandler<OpenWorkbookCompletedEventArgs>(xlservice_OpenWorkbookCompleted);
      xlservice.OpenWorkbookAsync(targetWorkbookPath, "en-US", "en-US");
    }

    void xlservice_OpenWorkbookCompleted(object sender, OpenWorkbookCompletedEventArgs e)
    {
      sessionId = (string)e.Result; //exception here!!!
    }

I tried the ways below, but they all failed.

1: create the file and put it on the "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\isapi\", but it failed again.

2: open the cross-domain workbook and data connection access in the sharepoint server, here

I am totally new to sharepoint and silverlight development, I search around on the net but can't find the answer. anyone could help me???

A: 

fix the problem, put the clientaccesspolicy.xml file in the server root. thanks all.

adshuangjoh