Invalid token for impersonation reawakened

Invalid token for impersonation reawakened

Old forum URL: forums.lhotka.net/forums/t/2275.aspx


DanEssin posted on Sunday, February 04, 2007

Web Services are a new topic for me although I've got several WinForms apps deployed in production with CSLA going on about a year now.

I downloaded the latest package 2.1.3, unzipped, and compiled everything.
Then I Attached the sample databases to my SQL Server 2005 Developer Edition.
I set debug to true in both app.config and web.config.
Then I opened up PtTracker, edited the connection strings in the web.config and tried to run PtServiceClient.

This is the first call in the form_load event:
        this.ProjectDataBindingSource.DataSource =
          svc.GetProjectList();

Execution halts there and throws the exception:
"Invalid token for impersonation - it cannot be duplicated."

I'm a little confused by the app.config (below) for PtServiceClient. It doesn't have an AppSettings section nor does it have a CslaAuthentication key.

I've read all of the posts form 6/30/2006 and tried everything suggested there.

I am clueless about what might be causing this. Help would be appreciated.

Dan
----------------------------------------------------------------
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="PTServiceClient.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
        </sectionGroup>
    </configSections>
    <applicationSettings>
        <PTServiceClient.Properties.Settings>
            <setting name="PTServiceClient_PTService_PTService" serializeAs="String">
                <value>http://localhost:7411/PTWebService/PTService.asmx</value>
            </setting>
        </PTServiceClient.Properties.Settings>
    </applicationSettings>
</configuration>

web.config
-------------------------------------------------------------------------
<?xml version="1.0"?>
<!--
    Note: As an alternative to hand editing this file you can use the
    web admin tool to configure settings for your application. Use
    the Website->Asp.Net Configuration option in Visual Studio.
    A full list of settings and comments can be found in
    machine.config.comments usually located in
    \Windows\Microsoft.Net\Framework\v2.x\Config
-->
<configuration>
  <appSettings>
    <add key="CslaAuthentication" value="Csla" />
    <!--<add key="CslaDataPortalProxy"
      value="Csla.DataPortalClient.RemotingProxy, Csla"/>
    <add key="CslaDataPortalUrl"
      value="http://localhost:3187/RemotingHost/RemotingPortal.rem"/>-->
    <add key="CslaDataPortalProxy"
      value="Csla.DataPortalClient.WebServicesProxy, Csla"/>
    <add key="CslaDataPortalUrl"
      value="http://localhost:4334/WebServicesHost/WebServicePortal.asmx"/>
    <!--<add key="CslaDataPortalProxy"
             value="EnterpriseServicesHost.EnterpriseServicesProxy, EnterpriseServicesHostvb"/>-->
  </appSettings>
  <connectionStrings>
    <add name="PTracker"
             connectionString="Data Source=(Local);Initial Catalog=Ptracker;Integrated Security=True;"
             providerName="System.Data.SqlClient" />
    <add name="Security"
             connectionString="Data Source=(Local);Initial Catalog=Security;Integrated Security=True;"
             providerName="System.Data.SqlClient" />
  </connectionStrings>
  <system.web>
        <!--
            Set compilation debug="true" to insert debugging
            symbols into the compiled page. Because this
            affects performance, set this value to true only
            during development.
        -->
        <compilation debug="true">
            <assemblies>
                <add assembly="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
                <add assembly="System.Runtime.Remoting, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
                <add assembly="System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
                <add assembly="System.Transactions, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/></assemblies></compilation>
        <!--
            The <authentication> section enables configuration
            of the security authentication mode used by
            ASP.NET to identify an incoming user.
        -->
        <authentication mode="Windows"/>
        <!--
            The <customErrors> section enables configuration
            of what to do if/when an unhandled error occurs
            during the execution of a request. Specifically,
            it enables developers to configure html error pages
            to be displayed in place of a error stack trace.

        <customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
            <error statusCode="403" redirect="NoAccess.htm" />
            <error statusCode="404" redirect="FileNotFound.htm" />
        </customErrors>
        -->
    </system.web>
</configuration>

RockfordLhotka replied on Monday, February 05, 2007

The PTServiceClient application is designed as a "service client", not a CSLA .NET client. Due to this, it expects that only XML service messages will go to/from the server, and it knows nothing at all about the implementation of those services (including the fact that they use CSLA .NET).

In other words PTServiceClient is NOT a CSLA .NET application - it is a pure web service client.

Read through Chapter 11 for a full discussion.

DanEssin replied on Monday, February 05, 2007

OK, I'll keep reading...

Thank

RockfordLhotka wrote:

The PTServiceClient application is designed as a "service client", not a CSLA .NET client. Due to this, it expects that only XML service messages will go to/from the server, and it knows nothing at all about the implementation of those services (including the fact that they use CSLA .NET).

In other words PTServiceClient is NOT a CSLA .NET application - it is a pure web service client.

Read through Chapter 11 for a full discussion.




Copyright (c) Marimer LLC