Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / Design Time / October 2004

Tip: Looking for answers? Try searching our database.

Constructors/Initializers/ConfigurationSettings in design time...

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Mike Edenfield - 26 Oct 2004 18:45 GMT
I have a series of user controls which internally contain datasets.  At
run-time, these datasets are loaded from XML documents in the following
manner:

private string _xmlPath = ConfigurationSettings.AppSettings["XML.Path"];

public UserControl1()
{
  InitializeComponent();
  this._xmlPath = ConfigurationSettings.AppSettings["XML.Path"];
  string s = Path.Combine(this._xmlPath, "Doc1.xml");
  this.UserControlData.ReadXml(fileName);
}

The problem is that "this._xmlPath" is never properly initialized at
design-time.  I always encounter "Value cannot be null. Parameter:
path1" errors on the Path.Combine function call.

I don't actually need this data at design-time, so I could just not let
this code run in the designers.  But I can't figure out how to tell when
a control is being designed or is being run.  Ideally it should just
work as is, but I cannot get the configuration settings to properly load
at design-time.  (I have an app.config in my project and it has been
subsequently built into an EXENAME.config file in the Debug folder...)

Any ideas?

--Mike
joeycalisay - 27 Oct 2004 06:02 GMT
> I don't actually need this data at design-time, so I could just not let
> this code run in the designers.  But I can't figure out how to tell when
> a control is being designed or is being run.

perhaps the retrieval of data for the UserControl should be on the OnLoad
event of the UserControl.  At that event, you can test if the control is
being loaded at runtime or designtime using its DesignMode property and
execute your data retrieval statements if it is not at DesignMode (meaning
runtime).

>Ideally it should just
> work as is, but I cannot get the configuration settings to properly load
> at design-time.  (I have an app.config in my project and it has been
> subsequently built into an EXENAME.config file in the Debug folder...)

app.config file becomes application.exe.config when build, i believe it's by
default.  I have no idea about loading from configuration file which is part
of the project at designtime.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.