471,309 Members | 1,077 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,309 software developers and data experts.

Choosing implementing class for interface in config


I want to be able to make my application configurable for which
implementation of XmlReader should be used.

<?xml version="1.0" encoding="utf-8" ?>
<add key="XmlReader" value="System.Xml.XmlValidatingReader" />

String xmlReaderString = ConfigurationSettings.AppSettings["XmlReader"];

Type xmlReaderType = Type.GetType(xmlReaderString);

Object[] pathArray = {path};

XmlReader reader = (XmlReader) Activator.CreateInstance(xmlReaderType,

I get a System.ArgumentNullException line.
When I debug it, I note that xmlReaderType is still undifined after the
first line is executed?
What is the proper way to do this?
The examples for instatiating objects thru reflection all use classes from
the System namespace, this works fine. But what about classes from other


Feb 4 '06 #1
0 904

This discussion thread is closed

Replies have been disabled for this discussion.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.