CodeSmith Community
Your Code. Your Way. Faster!

WinForm configuration...

Latest post 02-07-2008 11:42 AM by DudeMan. 2 replies.
  • 02-06-2008 4:57 PM

    • DudeMan
    • Top 500 Contributor
    • Joined on 10-22-2007
    • Posts 10
    • Points 260

    WinForm configuration...

    Freak'n New Guy!

    I've been generating [VS2005 (no unit tests)] on my own tables [SQL Server 2005] and incorporated a test winform project into the generated solution. To give you an idea of the exception I'm getting, I'll use the configuration text from the generation report to give other newbies a reference point. a) In SecurityContext.cs::IsAuthorized(string), the property ConnectionScope.Current.DataProvider.EnableMethodAuthorization (configuration failed to initialize). Stepping into that, in SecurityContext.cs::DataProvider, ConnectionStringKey is null. Stepping further into DataRepository.cs::NetTiersSection, the following exception is generated: "Unrecognized configuration section netTiersService". Sorry for being verbose, just trying to provide information for other newbies. It is obvious this is a configuration issue: 

    1) What is the purpose of the configuration text in the generated report. Its perhaps informative but doesn't work.

    2) Would the App.config.2005.cst template be useful in generating an App.config? If so, please explain the Data Section (FactoryType and ProviderInvariantName) and how to incorporate it when generating from the NetTiers.cst.

    3) I included the unit test (Team Suite) just to get at the entlib.config. I copied and pasted into the App.config but to no avail.

    Ideally, a copy of a basic WinForm App.config file would be nice but I would prefer using the App.config.2005 template as part of the NetTiers template execution. Your thoughts would be appreciated.

    Filed under:
    • Post Points: 35
  • 02-06-2008 5:43 PM In reply to

    • bgjohnso
    • Top 10 Contributor
    • Joined on 09-15-2005
    • Spokane, WA
    • Posts 767
    • Points 22,605

    Re: WinForm configuration...

    The sample configuration provided in the report should work just fine.  Here's a sample config file that I pulled from a WinForms app:

    <?xml version="1.0" encoding="utf-8" ?>

    <configuration>

    <configSections>

    <section name="netTiersService" type="YourNameSpace.DataAccessLayer.Bases.NetTiersServiceSection, YourNameSpace.DataAccessLayer"/>

    </configSections>

    <connectionStrings>

    <add

    name="connMain"

    providerName="System.Data.SqlClient"

    connectionString="YourConnectionString" />

    </connectionStrings>

    <netTiersService defaultProvider="SqlNetTiersProvider">

    <providers>

    <add name="SqlNetTiersProvider" type="YourNameSpace.DataAccessLayer.SqlClient.SqlNetTiersProvider, YourNameSpace.DataAccessLayer.SqlClient"

    useStoredProcedure="true" connectionStringName="connMain" applicationName="YourApplication" providerInvariantName="System.Data.SqlClient"/>

    </providers>

    </netTiersService>

    </configuration>

    Ben Johnson
    ------------------------------
     Member of the .NetTiers team
     Visit http://www.nettiers.com
    ------------------------------

    • Post Points: 35
  • 02-07-2008 11:42 AM In reply to

    • DudeMan
    • Top 500 Contributor
    • Joined on 10-22-2007
    • Posts 10
    • Points 260

    Re: WinForm configuration...

    Just a followup on this, first off, thanks for the prompt reply (bgjohnson)

    1) I had the section declaration for the netTiersService outside of the configSections section (duh) and...

    2) While you can compile without error utilizing the folowing references made in your client project: the nettiers component project, the nettiers data project, and the nettiers entities project, you also need to include as a reference the nettiers data.sqlclient (or whatever your provider is) project for the reflection the configurationmanager uses in accessing the configuration file. For people just getting started, if you don't have this reference included, you will get a null reference exception when the provider is attempting to be instantiated.

     Again, sorry for being verbose.

    • Post Points: 5
Page 1 of 1 (3 items) | RSS
Copyright © 2008 CodeSmith Tools, LLC
Powered by Community Server (Commercial Edition), by Telligent Systems