【问题标题】:SubSonic and app.config in Windows FormWindows 窗体中的 SubSonic 和 app.config
【发布时间】:2010-10-26 00:30:55
【问题描述】:

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

【问题讨论】:

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

标签: winforms configuration subsonic app-config


【解决方案1】:

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

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

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

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

最后,添加您在 configSections 中添加的 SubsonicService 节点,如下所示:

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

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

【讨论】:

    【解决方案2】:

    您的构建过程需要包含这样的命令:

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

    sonic.exe 是SubCommander 实用程序,包含在current release 中。无法让 app.config 直接为您处理。

    运行命令的一种方法是使用MSBuildExec MS Build task 任务可能看起来像这样:

    <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)。

    【讨论】:

      猜你喜欢
      • 2016-11-15
      • 2012-05-17
      • 1970-01-01
      • 2010-10-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多