I have tried to define and use DTD entities inside my App.config
. For example:
<?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>
Using System.Configuration.ConfigurationManager
to read appSettings
or connectionStrings
won't throw an error, but it also does not resolve the DTD entities.
(And sometimes the program will not execute at all. I have no idea why .NET complains only sometimes of a configuration error.)
Is my use of DTD incorrect, or does .NET not support custom DTD entities in App.config
?