我试图在我的App.config
中定义和使用DTD实体。例如:我可以在App.config中声明和使用DTD实体吗?
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE configuration [
<!ENTITY dataSource ".\SQLEXPRESS">
]>
<configuration>
<appSettings>
<add key="FooDataSource" value="&dataSource;" />
</appSettings>
<connectionStrings>
<add name="Foo" connectionString="Data Source=&dataSource;;Integrated Security=SSPI;" />
</connectionStrings>
</configuration>
使用System.Configuration.ConfigurationManager
阅读appSettings
或connectionStrings
不会引发错误,但它也不能解决DTD实体。
(有时程序将不会执行的。我不知道为什么.NET抱怨只是偶尔出现配置错误。)
是我使用DTD的不正确或不.NET不支持自定义DTD App.config
的实体吗?
优秀的答案!对于这个毫无意义的评论感到抱歉,但我不得不赞扬你:) – MetaFight 2014-07-29 11:15:17