using the June 2005 edition of the Ent Lib.
I can serialize a SqlParameterCollection using
ConfigurationManager.WriteConfiguration() but GetConfiguration() does not seem to be able to deserialize that same ParameterCollection. The TestConfiguration.config file looks perfect... I actually said "Cool!" when I first saw it!
A small sample app follows.
**Note**
If I uncomment the three line in Main, the GetConfiguration() works fine... but then my reading indicates that at that point GetConfiguration is actually reading cached data, which is pointless.
Am I not corrrect in understanding that the config block should behave like the old *.ini files: a plain text and human readable config file that can be read at runtime?
How can I accomplish this?
In the example below, mytest2 is created with the _myName variable as "Billy"
but the _pcol variable as undefined.
****code example************
using System;
using System.Data.SqlClient;
using System.Data;
using Microsoft.Practices.EnterpriseLibrary.Configuration;
namespace AccountUserMigration
{
public class Test{
private SqlParameterCollection _pcol;
private string _myName;
public string myName{
get{return this._myName;}
set{this._myName = value;}
}
public SqlParameterCollection pcol{
get{return this._pcol;}
set{this._pcol = value;}
}
public Test(){}
public void PrepForSerialization(){
SqlCommand cmd = new SqlCommand();
cmd.Parameters.Add("@one",SqlDbType.VarChar);
cmd.Parameters.Add("@two",SqlDbType.Int);
this.pcol = cmd.Parameters;
this.myName = "Billy";
}
static void Main(){
//Test mytest = new Test(), mytest2 = new Test();
//mytest.PrepForSerialization();
//ConfigurationManager.WriteConfiguration("TestConfiguration",mytest);
Test mytest2 =
(Test)ConfigurationManager.GetConfiguration("TestConfiguration") as Test;
}
}
}
**************************
I can serialize a SqlParameterCollection using
ConfigurationManager.WriteConfiguration() but GetConfiguration() does not seem to be able to deserialize that same ParameterCollection. The TestConfiguration.config file looks perfect... I actually said "Cool!" when I first saw it!
A small sample app follows.
**Note**
If I uncomment the three line in Main, the GetConfiguration() works fine... but then my reading indicates that at that point GetConfiguration is actually reading cached data, which is pointless.
Am I not corrrect in understanding that the config block should behave like the old *.ini files: a plain text and human readable config file that can be read at runtime?
How can I accomplish this?
In the example below, mytest2 is created with the _myName variable as "Billy"
but the _pcol variable as undefined.
****code example************
using System;
using System.Data.SqlClient;
using System.Data;
using Microsoft.Practices.EnterpriseLibrary.Configuration;
namespace AccountUserMigration
{
public class Test{
private SqlParameterCollection _pcol;
private string _myName;
public string myName{
get{return this._myName;}
set{this._myName = value;}
}
public SqlParameterCollection pcol{
get{return this._pcol;}
set{this._pcol = value;}
}
public Test(){}
public void PrepForSerialization(){
SqlCommand cmd = new SqlCommand();
cmd.Parameters.Add("@one",SqlDbType.VarChar);
cmd.Parameters.Add("@two",SqlDbType.Int);
this.pcol = cmd.Parameters;
this.myName = "Billy";
}
static void Main(){
//Test mytest = new Test(), mytest2 = new Test();
//mytest.PrepForSerialization();
//ConfigurationManager.WriteConfiguration("TestConfiguration",mytest);
Test mytest2 =
(Test)ConfigurationManager.GetConfiguration("TestConfiguration") as Test;
}
}
}
**************************