I'm refactoring my code to implement multi-database work. I use System.Data.Common classes and factory to create Exact objects for currently selected database engine. Some connection definitions in Designed looks like:
private System.Data.Common.DbConnection cn;
and assigment is:
private void InitializeComponent()
{
...
this.cn = SqlFactory.CreateConnection();
...
}
and SqlFactory code looks like:
public DbConnection getConnection()
{
return (TSqlConection)Activator.CreateInstance(typeof(TSqlConection));
}
It works okay at runtime, but when i'm trying to open any form in VS Designer i've got errors like the following:
The variable 'cn' is either undeclared or was never assigned.
And Designer can't display form for editing.
How can i fix it?