Subsonic Access To App.Config Connection Strings From Referenced DLL in Powershell Script

后端 未结 1 1140
生来不讨喜
生来不讨喜 2021-01-20 11:35

I\'ve got a DLL that contains Subsonic-generated and augmented code to access a data model. Actually, it is a merged DLL of that original assembly, Subsonic itself and a few

相关标签:
1条回答
  • 2021-01-20 12:10

    Did you add the System.Configuration assembly to your PowerShell session? The following works for me:

    PS> gc .\app.config
    
    <?xml version='1.0' encoding='utf-8'?>
    <configuration>
        <connectionStrings>
          <clear />
          <add name="Name"
               providerName="System.Data.ProviderName"
               connectionString="Valid Connection String;" />
        </connectionStrings>
    </configuration>
    
    PS> [appdomain]::CurrentDomain.SetData("APP_CONFIG_FILE", "$home\app.config")
    PS> Add-Type -AssemblyName System.Configuration
    PS> [Configuration.ConfigurationManager]::ConnectionStrings['Name']
    
    Name                    : Name
    ConnectionString        : Valid Connection String;
    ...
    
    0 讨论(0)
提交回复
热议问题