J
Jeff
ASP.NET 2.0
This code crashes. It generate this error:
Value cannot be null.
Parameter name: type
I've created some custom web.config settings and this crash is related to
accessing theme custom settings. This code is where the crash occur:
_instance =
(DAL)Activator.CreateInstance(Type.GetType(min.test.Config.Settings.msgElement.ProviderType));
This code is trying to do is to create an instance of the DAL provider,
************* custom web.config settings: **********************
<configSections>
<section name="msg" type="min.test.ConfigSection, __code"/>
</configSections>
<msg>
<messages providerType="min.test.DAL.SqlServer2005"/>
</msg>
********* In this code the crash occur *********
/* This code is from the DAL class, this code is trying to create an
instance of the DAL set in web.config - min.test.DAL.SqlServer2005
static public DAL Instance
{
get
{
if (_instance == null)
_instance =
(DAL)Activator.CreateInstance(Type.GetType(min.test.Config.Settings.msgElement.ProviderType));
<--- code crashes here
return _instance;
}
}
******** definition of the custom settings in web.config
**********************
using System;
using System.Collections.Generic;
using System.Configuration;
namespace min.test
{
public class ConfigSection : ConfigurationSection
{
[ConfigurationProperty("messages", IsRequired = true)]
public MsgElement msgElement
{
get { return (MsgElement)base["messages"]; }
}
}
public class MsgElement : ConfigurationElement
{
[ConfigurationProperty("providerType", DefaultValue =
"min.test.DAL.SqlServer2005")]
public string ProviderType
{
get { return (string)base["providerType"]; }
set { base["providerType"] = value; }
}
}
}
Any suggestions??
Jeff
This code crashes. It generate this error:
Value cannot be null.
Parameter name: type
I've created some custom web.config settings and this crash is related to
accessing theme custom settings. This code is where the crash occur:
_instance =
(DAL)Activator.CreateInstance(Type.GetType(min.test.Config.Settings.msgElement.ProviderType));
This code is trying to do is to create an instance of the DAL provider,
************* custom web.config settings: **********************
<configSections>
<section name="msg" type="min.test.ConfigSection, __code"/>
</configSections>
<msg>
<messages providerType="min.test.DAL.SqlServer2005"/>
</msg>
********* In this code the crash occur *********
/* This code is from the DAL class, this code is trying to create an
instance of the DAL set in web.config - min.test.DAL.SqlServer2005
static public DAL Instance
{
get
{
if (_instance == null)
_instance =
(DAL)Activator.CreateInstance(Type.GetType(min.test.Config.Settings.msgElement.ProviderType));
<--- code crashes here
return _instance;
}
}
******** definition of the custom settings in web.config
**********************
using System;
using System.Collections.Generic;
using System.Configuration;
namespace min.test
{
public class ConfigSection : ConfigurationSection
{
[ConfigurationProperty("messages", IsRequired = true)]
public MsgElement msgElement
{
get { return (MsgElement)base["messages"]; }
}
}
public class MsgElement : ConfigurationElement
{
[ConfigurationProperty("providerType", DefaultValue =
"min.test.DAL.SqlServer2005")]
public string ProviderType
{
get { return (string)base["providerType"]; }
set { base["providerType"] = value; }
}
}
}
Any suggestions??
Jeff