views:

555

answers:

3

As it should be the file app.config in an application Windows Form so that the given access classes her they generate automatically in the build?

+1  A: 

Yes. What you do is add a section in configSections called "SubsonicService", like this:

<configSections>
    <section name="SubSonicService" type="SubSonic.SubSonicSection, SubSonic" requirePermission="false"/>
</configSections>

Next, you add a connectionStrings branch with the connection strings that you will use in your project, like this:

<connectionStrings>
    <clear/>
    <add name="WheelMUDSQLite" connectionString="Data Source=C:\Dev\WheelMud.net\src\SQL\SQLite\WheelMud.net.db;Version=3;"/>
</connectionStrings>

Last, you add the SubsonicService node that you added in the configSections like this:

<SubSonicService defaultProvider="WheelMUDSQLite">
    <providers>
        <clear/>
        <add name="WheelMUDSQLite" type="SubSonic.SQLiteDataProvider, SubSonic" connectionStringName="WheelMUDSQLite" generatedNamespace="WheelMUD.DataLayer"/>
    </providers>
</SubSonicService>

This is where you put all of your providers. I use the SubStage utility to generate the DAL. This way you can completely disassociate your stuff from the Web bits that come with Subsonic.

hectorsosajr
+1  A: 

Your build process needs to include a command like this:

sonic.exe generate /config "c:\myproject\App.config"

sonic.exe is the SubCommander utility, and is included in the current release. There's no way to have the app.config handle this for you directly.

One way to run the command is with MSBuild. The Exec MS Build task task might look something like this:

<Target Name="GenerateSubSonicClasses" DependsOn="BeforeBuild">
  <Exec Command="sonic.exe generate /config &quot;c:\myproject\App.config&quot;" WorkingDirectory="c:\path-to-subcommander"/>
</Target>

I just made this up, so it probably needs tweaking before it'll work for you. This command would go in your visual studio project file (ie someproject.vbproj).

ranomore
A: 

I didn't understand.
This tag above should be inserted inside of the file app.config?
Should I install some other program in my personal computer?

Leandro
No. MSBuild is included with .NET 2.0 and newer. Edit your project file. Read this: http://msdn.microsoft.com/en-us/magazine/cc163589.aspx.
ranomore