Sobreira

Hello,

I have a ExcelWorkbook solution where I call a WCF Web Service. Then I have this error:

¡°{"An error occurred creating the configuration section handler for system.serviceModel/client: That assembly does not allow partially trusted callers. (C:\\xpto\\bin\\Debug\\ExcelWorkbook1.dll.config line 30)"}¡±

Well... I already put the ExcelWorkbook1.dll assembly as a full trusted on the ¡°.NET Framework 2.0¡± on the ¡°Administration Tools¡±.

What more can I do

Tanks,
Patricia Sobreira.



Re: Visual Studio Tools for Office Is Excel a partial trust caller?

Mike Walker

The VSTO security requires FullTrust due to COM interop and other reasons too deep to express here. What you can do with this scenario where you are late loading an Assembly is load using an Evidence based on the Active Assembly for example.

System.Security.Policy.Evidence ev = Assembly.GetExecutingAssembly().Evidence;
Assembly *** = null;
Type t = null;

*** = Assembly.LoadFrom(@"C:\MYASSEMBLY.DLL", ev);

The above will get the Evidence from the ExecutingAssembly and allow you to reuse this, otherwise the Loaded Assembly will raise accordingly.

I have not done WCF specifically but think this is related.

Regards






Re: Visual Studio Tools for Office Is Excel a partial trust caller?

Sobreira

Hello,

I just have an assembly that is the code behind. With the SCVUTIL.EXE create a output.config an Campaingservice.cs. I created a simple ExcelWorkbook solution with this code behind:

using System;
using System.Data;
using System.Drawing;
using System.Windows.Forms;
using Microsoft.VisualStudio.Tools.Applications.Runtime;
using Excel = Microsoft.Office.Interop.Excel;
using Office = Microsoft.Office.Core;
using System.ServiceModel;
using System.ServiceModel.Description;

namespace ExcelWorkbook1
{
public partial class Sheet1
{

...
private void Button1_Click(object sender, System.EventArgs e)
{
CampaignServiceClient clt = new CampaignServiceClient();
string aux = clt.GetList(new SituationFilter()).Campaigns[0].Name;
this.Range["A1", "A1"].Value2 = aux;
}

#region VSTO Designer generated code

private void InternalStartup(){

....

this.button1.Click += new System.EventHandler(Button1_Click);
}
#endregion
}
}

app.config:

< xml version="1.0" encoding="utf-8" >
<configuration>
<
configSections>
<
sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="ExcelWorkbook1.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"requirePermission="false" />

</sectionGroup>
</
configSections>
<
system.serviceModel>
<
bindings>
<
wsHttpBinding>
<
binding name="WSHttpBinding_ICampaignService" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:20:00" sendTimeout="00:01:00"
bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"
allowCookies="false">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<reliableSession ordered="true" inactivityTimeout="00:10:00"
enabled="false" />
<security mode="Message">
<transport clientCredentialType="Windows" proxyCredentialType="None"
realm="" />
<message clientCredentialType="Windows" negotiateServiceCredential="true"
algorithmSuite="Default" establishSecurityContext="false" />
</security>
</
binding>
</
wsHttpBinding>
</
bindings>
<
client>
<
endpoint address="http://xpto/CampaignService.svc"
binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_ICampaignService"
contract="ICampaignService" name="WSHttpBinding_ICampaignService">
<identity>
<
servicePrincipalName value="host/xpto" />
</identity>
</
endpoint>
</
client>
</
system.serviceModel>
</
configuration>


Tanks,
Patricia Sobreira.





Re: Visual Studio Tools for Office Is Excel a partial trust caller?

Misha Shneerson - MSFT

Hi Patricia,

I believe you need to FullTrust your config file as well. The reason is that the call of the WCF walks up the stack and checks whether everything on the stack has full trust. Since, the invocation of the WCF is controlled through the config file - the permission set for this config file is also on the stack.

You can use caspol it e.g. something like this:

caspol -u -ag 1 -url <path_to_config_file> FullTrust






Re: Visual Studio Tools for Office Is Excel a partial trust caller?

Sobreira

Hi Mischa,

Didn't work :(. The same error continues.

Tanks,
Patricia Sobreira.






Re: Visual Studio Tools for Office Is Excel a partial trust caller?

Misha Shneerson - MSFT

What do you see when you perform:

caspol -rsg C:\\xpto\\bin\\Debug\\ExcelWorkbook1.dll.config