加密的配置部分加上 BCL。建

Encrypted config section plus BCL.Build

提问人:Emyr 提问时间:6/16/2017 更新时间:6/16/2017 访问量:269

问:

我正在尝试在 ASP.Net 4.0 Web 应用程序中更新 LinqKit,该应用程序使用加密的配置部分来混淆 connectionstrings 部分。我们还使用配置转换。

<?xml version="1.0" encoding="utf-8"?>
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
  <configProtectedData>
    <providers>
      <add keyContainerName="FooBarKeys" useMachineContainer="true" description="Uses RsaCryptoServiceProvider to encrypt and decrypt" name="FooBarProvider" type="System.Configuration.RsaProtectedConfigurationProvider,System.Configuration, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
    </providers>
  </configProtectedData>
  <connectionStrings configProtectionProvider="FooBarProvider">
    <EncryptedData Type="http://www.w3.org/2001/04/xmlenc#Element" xmlns="http://www.w3.org/2001/04/xmlenc#">
...

对于面向 .Net 4.0 的项目,LinqKit 1.1.7+ 依赖于 Microsoft.Bcl.Async,并且在引用使用 Microsoft.Bcl.Async 的类库的任何项目中都需要 Microsoft.Bcl.Build。

当我构建时,我收到以下错误:

The "EnsureBindingRedirects" task failed unexpectedly.
System.Xml.XmlException: App.config must have root configuration element. Line 2, position 2.
   at Roxel.BuildTasks.EnsureBindingRedirects.ThrowXmlException(String message, Exception inner, IXmlLineInfo info)
   at Roxel.BuildTasks.EnsureBindingRedirects.LoadAppConfig(String appConfigPath)
   at Roxel.BuildTasks.EnsureBindingRedirects.Execute()
   at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
   at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext() 
File: packages\Microsoft.Bcl.Build.1.0.21\build\Microsoft.Bcl.Build.targets line 97

如果我更改为 ,我会收到 web.config 的 XML 验证警告:<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0"><configuration>

The 'keyContainerName' attribute is not allowed.
The 'useMachineContainer' attribute is not allowed.
The 'description' attribute is not allowed.
The 'configProtectionProvider' attribute is not allowed.
The element 'connectionStrings' has invalid child element 'EncryptedData' in namespace 'http://www.w3.org/2001/04/xmlenc#'. List of possible elements expected: 'add, remove, clear'.

我尝试使用,与和。这将验证,但在运行时失败:<configuration xmlns:c="http://schemas.microsoft.com/.NetConfiguration/v2.0"><c:configProtectedData><c:connectionStrings>

HTTP Error 500.19 - Internal Server Error
The requested page cannot be accessed because the related configuration data for the page is invalid.
Error Code     0x80070032
Config Error       The configuration section 'c:configProtectedData' cannot be read because it is missing a section declaration 
Config Source:
5:   </configSections>
**6:   <c:configProtectedData>**
7:     <providers>

如何在 .Net 4.0 Web 应用中使用这些库,以便它生成、具有有效的 web.config 并运行?

asp.net web-config async-await base-class-library web-config-encryption

评论


答: 暂无答案