I've got an Outlook Add-In that references a Web Service that implements a custom UserNameTokenManager WSE 3 authentication class. However, I'm getting an error when I attempt to call myWebService.SetPolicy("ClientPolicy"):

System.ArgumentOutOfRangeException was caught

Message="Specified argument was out of the range of valid values. Parameter name: Policy 'ClientPolicy' is not configured in the system"

ParamName="Policy 'ClientPolicy' is not configured in the system"

Source="Microsoft.Web.Services3"

StackTrace:

at Microsoft.Web.Services3.WebServicesClientProtocol.SetPolicy(String policyName) at MyAdd_In.Security.Login() in C:\MyAdd_In\Security.vb:line 184


The relevant portion of my app.config is:

<microsoft.web.services3>
<diagnostics>
<traceenabled="true"input="InputTrace.webinfo"output="OutputTrace.webinfo"/>
</diagnostics>
<policyfileName="wse3policyCache.config"/>
</microsoft.web.services3>

The wse3policyCache.config file contains:

<policiesxmlns="http://schemas.microsoft.com/wse/2005/06/policy">
<extensions>
<extensionname="usernameOverTransportSecurity"type="Microsoft.Web.Services3.Design.UsernameOverTransportAssertion,Microsoft.Web.Services3,Version=3.0.0.0,Culture=neutral,PublicKeyToken=31bf3856ad364e35"/>
<extensionname="requireActionHeader"type="Microsoft.Web.Services3.Design.RequireActionHeaderAssertion,Microsoft.Web.Services3,Version=3.0.0.0,Culture=neutral,PublicKeyToken=31bf3856ad364e35"/>
</extensions>
<policyname="ClientPolicy">
<usernameOverTransportSecurity/>
<requireActionHeader/>
</policy>
</policies>

I've tested the same WSE config settingsand web service call in a Windows Form application and the policy loads fine.

Both config files are output to the directory where the Add-In's dll is stored.

So what's different about calling this file with an Add-In? Do these files have to be a different name or be in a different location??

Eric Legault [MVP - Outlook] MCDBA, MCTS (Messaging & Collaboration, SharePoint Infrastructure, MOSS 2007 & WSS 3.0 Application Development) President Collaborative Innovations http://www.collaborativeinnovations.ca http://blogs.officezealot.com/legault