I have problem to call Azure WCF Service from sandbox Visual Web Part Sharepoint 2010. All installed al local computer Windows 7 64 Ultimate - Sharepoint Foundation 2010 to develop web parts and Visual Studio 2010 with Azure SDK. Web Service starting in local Azure Emulator, web part in local computer. When i use standart master "Add Service Reference" to web part, that generate app.config, then throw error:

 ServiceReference1.Service1Client serv = new ServiceReference1.Service1Client();
 Label1.Text = serv.GetData(9);

Could not find default endpoint element that references contract 'ServiceReference1.IService1' in the ServiceModel client configuration section. This might be because no configuration file was found for your application, or because no endpoint element matching this contract could be found in the client element.

When i create connection programmatically -

 EndpointAddress adr = new EndpointAddress(new Uri(""));
 BasicHttpBinding basic = new BasicHttpBinding();
 ChannelFactory<ServiceReference1.IService1Channel> fact = new ChannelFactory<ServiceReference1.IService1Channel>(basic, adr);
 Label1.Text = fact.CreateChannel().GetData(8);

throw error:

Request for the permission of type "System.Net.WebPermission, System, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089".

app.config webpart:

<?xml version="1.0" encoding="utf-8" ?>
                <binding name="BasicHttpBinding_IService1" />
            <endpoint address="" binding="basicHttpBinding"
                bindingConfiguration="BasicHttpBinding_IService1" contract="ServiceReference1.IService1"
                name="BasicHttpBinding_IService1" />

web.config Azure WCF Service:

<?xml version="1.0"?>
  <!--  To collect diagnostic traces, uncomment the section below or merge with existing system.diagnostics section.
        To persist the traces to storage, update the DiagnosticsConnectionString setting with your storage credentials.
        To avoid performance degradation, remember to disable tracing on production deployments.
      <add name="AzureLocalStorage" type="WCFServiceWebRole1.AzureLocalStorageTraceListener, WCFServiceWebRole1"/>
      <source name="System.ServiceModel" switchValue="Verbose, ActivityTracing">
          <add name="AzureLocalStorage"/>
      <source name="System.ServiceModel.MessageLogging" switchValue="Verbose">
          <add name="AzureLocalStorage"/>
   </system.diagnostics> -->
        <add type="Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener, Microsoft.WindowsAzure.Diagnostics, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
          <filter type="" />
    <compilation debug="true" targetFramework="4.0" />
          <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
          <serviceMetadata httpGetEnabled="true"/>
          <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
          <serviceDebug includeExceptionDetailInFaults="false"/>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
    <modules runAllManagedModulesForAllRequests="true"/>

P.S. When all moved to work deployment - Azure и Sharepoint Online - errors again. I create connection programmatically, because read, that in sandbox solutions app.config not deployed with web part, we must duplicate his code in web.config Sharepoint 2010 - but in Sharepoint Online this file is closed from developers!

1 Answer 1


I don't think you can do this from a sandbox application, the sandbox restrictions won't allow it from the server. You will have to call the WCF from client side using Javascript.

  • Ian, but with Silverlight sandbox I can do it! Any ideas about solution?(
    – user7862
    Apr 16, 2012 at 13:45
  • I only know about Sharepoint Sandbox solutions. You can get around the limitation by using a proxy, but you won't be able to that with Office365 or Sharepoint Online. Was your Silverlight sandbox running with partial trust or did you adjust the security levels somehow ?
    – Ian
    Apr 16, 2012 at 14:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.