Winforms Windows窗体中的亚音速和app.config

Winforms Windows窗体中的亚音速和app.config,winforms,configuration,subsonic,app-config,Winforms,Configuration,Subsonic,App Config,因为它应该是应用程序Windows窗体中的app.config文件,以便在生成时自动生成给定的访问类?是。您要做的是在configSections中添加一个名为“SubsonicService”的节,如下所示: <configSections> <section name="SubSonicService" type="SubSonic.SubSonicSection, SubSonic" requirePermission="false"/> </conf

因为它应该是应用程序Windows窗体中的app.config文件,以便在生成时自动生成给定的访问类?

是。您要做的是在configSections中添加一个名为“SubsonicService”的节,如下所示:

<configSections>
    <section name="SubSonicService" type="SubSonic.SubSonicSection, SubSonic" requirePermission="false"/>
</configSections>
<connectionStrings>
    <clear/>
    <add name="WheelMUDSQLite" connectionString="Data Source=C:\Dev\WheelMud.net\src\SQL\SQLite\WheelMud.net.db;Version=3;"/>
</connectionStrings>
<SubSonicService defaultProvider="WheelMUDSQLite">
    <providers>
        <clear/>
        <add name="WheelMUDSQLite" type="SubSonic.SQLiteDataProvider, SubSonic" connectionStringName="WheelMUDSQLite" generatedNamespace="WheelMUD.DataLayer"/>
    </providers>
</SubSonicService>
sonic.exe generate /config "c:\myproject\App.config"
<Target Name="GenerateSubSonicClasses" DependsOn="BeforeBuild">
  <Exec Command="sonic.exe generate /config &quot;c:\myproject\App.config&quot;" WorkingDirectory="c:\path-to-subcommander"/>
</Target>

接下来,添加一个ConnectionString分支,其中包含将在项目中使用的连接字符串,如下所示:

<configSections>
    <section name="SubSonicService" type="SubSonic.SubSonicSection, SubSonic" requirePermission="false"/>
</configSections>
<connectionStrings>
    <clear/>
    <add name="WheelMUDSQLite" connectionString="Data Source=C:\Dev\WheelMud.net\src\SQL\SQLite\WheelMud.net.db;Version=3;"/>
</connectionStrings>
<SubSonicService defaultProvider="WheelMUDSQLite">
    <providers>
        <clear/>
        <add name="WheelMUDSQLite" type="SubSonic.SQLiteDataProvider, SubSonic" connectionStringName="WheelMUDSQLite" generatedNamespace="WheelMUD.DataLayer"/>
    </providers>
</SubSonicService>
sonic.exe generate /config "c:\myproject\App.config"
<Target Name="GenerateSubSonicClasses" DependsOn="BeforeBuild">
  <Exec Command="sonic.exe generate /config &quot;c:\myproject\App.config&quot;" WorkingDirectory="c:\path-to-subcommander"/>
</Target>

最后,添加在ConfigSection中添加的服务节点,如下所示:

<configSections>
    <section name="SubSonicService" type="SubSonic.SubSonicSection, SubSonic" requirePermission="false"/>
</configSections>
<connectionStrings>
    <clear/>
    <add name="WheelMUDSQLite" connectionString="Data Source=C:\Dev\WheelMud.net\src\SQL\SQLite\WheelMud.net.db;Version=3;"/>
</connectionStrings>
<SubSonicService defaultProvider="WheelMUDSQLite">
    <providers>
        <clear/>
        <add name="WheelMUDSQLite" type="SubSonic.SQLiteDataProvider, SubSonic" connectionStringName="WheelMUDSQLite" generatedNamespace="WheelMUD.DataLayer"/>
    </providers>
</SubSonicService>
sonic.exe generate /config "c:\myproject\App.config"
<Target Name="GenerateSubSonicClasses" DependsOn="BeforeBuild">
  <Exec Command="sonic.exe generate /config &quot;c:\myproject\App.config&quot;" WorkingDirectory="c:\path-to-subcommander"/>
</Target>


这是您放置所有提供者的地方。我使用SubStage实用程序生成DAL。通过这种方式,您可以将您的内容与亚音速附带的Web位完全分离。

您的构建过程需要包含如下命令:

<configSections>
    <section name="SubSonicService" type="SubSonic.SubSonicSection, SubSonic" requirePermission="false"/>
</configSections>
<connectionStrings>
    <clear/>
    <add name="WheelMUDSQLite" connectionString="Data Source=C:\Dev\WheelMud.net\src\SQL\SQLite\WheelMud.net.db;Version=3;"/>
</connectionStrings>
<SubSonicService defaultProvider="WheelMUDSQLite">
    <providers>
        <clear/>
        <add name="WheelMUDSQLite" type="SubSonic.SQLiteDataProvider, SubSonic" connectionStringName="WheelMUDSQLite" generatedNamespace="WheelMUD.DataLayer"/>
    </providers>
</SubSonicService>
sonic.exe generate /config "c:\myproject\App.config"
<Target Name="GenerateSubSonicClasses" DependsOn="BeforeBuild">
  <Exec Command="sonic.exe generate /config &quot;c:\myproject\App.config&quot;" WorkingDirectory="c:\path-to-subcommander"/>
</Target>
sonic.exe是实用程序,包含在中。无法让app.config直接为您处理此问题

运行该命令的一种方法是使用。任务可能如下所示:

<configSections>
    <section name="SubSonicService" type="SubSonic.SubSonicSection, SubSonic" requirePermission="false"/>
</configSections>
<connectionStrings>
    <clear/>
    <add name="WheelMUDSQLite" connectionString="Data Source=C:\Dev\WheelMud.net\src\SQL\SQLite\WheelMud.net.db;Version=3;"/>
</connectionStrings>
<SubSonicService defaultProvider="WheelMUDSQLite">
    <providers>
        <clear/>
        <add name="WheelMUDSQLite" type="SubSonic.SQLiteDataProvider, SubSonic" connectionStringName="WheelMUDSQLite" generatedNamespace="WheelMUD.DataLayer"/>
    </providers>
</SubSonicService>
sonic.exe generate /config "c:\myproject\App.config"
<Target Name="GenerateSubSonicClasses" DependsOn="BeforeBuild">
  <Exec Command="sonic.exe generate /config &quot;c:\myproject\App.config&quot;" WorkingDirectory="c:\path-to-subcommander"/>
</Target>


这是我编造的,所以在它对你有用之前可能需要调整一下。此命令将放在您的visual studio项目文件(即someproject.vbproj)中。

我认为[重申]的问题是“如何配置我的app.config,以便亚音速类作为构建的一部分自动生成?”