App.Config: using doctype and entity blocks

H

Harold Howe

When .NET loads an app.config at runtime (myapp.exe.config), will it
honor an entity declaration? Based on what I am seeing, the answer is
no, but I think, or hope, that I am doing something wrong.

I tried this:

// myapp.exe.config
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE configuration [
<!ENTITY mydll SYSTEM "mydll.xml">
]>

<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
&mydll;
</assemblyBinding>
</runtime>
</configuration>

//mydll.xml
<dependentAssembly>
<assemblyIdentity name="mydll"
publicKeyToken="cbbe122047afc212"
culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-999.9999.9999.9999"
newVersion="1.0.4.0"/>
</dependentAssembly>

I verified that I have everything formatted correctly by loading the
config file into internet explorer (after changing the file extention to
..xml). IE processes the entity include just fine, but when I run my app,
fuslogvw reports that the XML config file is not formatted correctly.

LOG: This bind starts in default load context.
ERR: There was an error parsing XML (hr = 0xc00ce565).
WRN: Error parsing XML file N:\MyApp\bin\Debug\MyApp.exe.config. Ignoring.

I am trying to use an xml entity to include a separate config file with
a collection of binding redirects and codebase statements. Why am I
doing that? It is a long a sordid tale... But if there is another way to
import, merge, or share a config file, I would be open to it.

H^2
 
G

Guest

You might want to look at the Application Block Framework for .NET, which
gives examples on how to read or write, manipulate, the XML App.config from
within code. There are plenty of examples that come with the Application
Block Framework, which is free for download. The examples show you how to
set up sections in the App.Config for your usage and shows the code that will
do the manipulation of the App.Config. The Net 2003 version is standalone
and all you really do is reference the the DLL to use. The Application Block
Framework for the manipulation of the App.Config is included as part of the
2.0 Framework. You still can download the 2.0 Framework examples.

Duane :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top