Re: This code compiles/runs but breaks designer...
- From: "Bryan Phillips" <bphillips@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Sun, 15 Apr 2007 13:25:59 +0000
Yes, that is what I am saying. Visual Studio will run the constructor and all properties for any component that you open in design mode.
If you need to step through the code, modify your project properties->debugging tab to start a new instance of Visual Studio.
Once the new instance of Visual Studio is open, open the project again and then open the form. You can set a breakpoint in the form's property in the first instance of Visual Studio so you can step through the code.
--
Bryan Phillips
MCSD, MCDBA, MCSE
Blog: http://bphillips76.spaces.live.com
Web Site: http://www.composablesystems.net
"Charlie@CBFC" <charlie@xxxxxxxxxxxxxxxxx> wrote in message news:#n$n9sufHHA.596@xxxxxxxxxxxxxxxxxxxx:
I don't understand Bryan. Are you saying that code runs when I open Form
for editing? So conditions might not be right at design time, but are right
at runtime? How do you troubleshoot something like this? Doesn't make
sense to me to have to kludge it just so it works at design time.
I get error "Object reference not set to an instance of an object" when I
open form, so it must be null. Not sure how to test it without running
program and stepping through code?
"Bryan Phillips" <bphillips@xxxxxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:eGvPpNufHHA.1244@xxxxxxxxxxxxxxxxxxxxxxx
> Did you try my suggestion? Code also runs at design-time too.
>
> --
> Bryan Phillips
> MCSD, MCDBA, MCSE
> Blog: http://bphillips76.spaces.live.com
> Web Site: http://www.composablesystems.net
>
>
>
> "Charlie@CBFC" <charlie@xxxxxxxxxxxxxxxxx> wrote in message
> news:OtJY9AtfHHA.3632@xxxxxxxxxxxxxxxxxxxx:
>
>> Code compiles and runs so it's getting connection string. Problem is
>> this
>> line of code...
>> System.Configuration.ConfigurationManager.ConnectionStrings["ConnectionString"].ToString()
>> breaks designer. Says "Object reference not set to an instance of an
>> object".
>>
>>
>>
>> "Bryan Phillips" <bphillips@xxxxxxxxxxxxxxxxxxxxxxxxxxxx> wrote in
>> message
>> news:efDNcusfHHA.3884@xxxxxxxxxxxxxxxxxxxxxxx
>> > Change your code to test if
>> > System.Configuration.ConfigurationManager.ConnectionStrings["ConnectionString"]
>> > is null before calling ToString().
>> >
>> > Ex:
>> >
>> > public static string _connectionString = String.Empty;
>> > public static string ConnectionString {
>> > get {
>> > if( _connectionString == String.Empty ) {
>> > if
>> > (System.Configuration.ConfigurationManager.ConnectionStrings["ConnectionString"]
>> > != null) {
>> > _connectionString =
>> > System.Configuration.ConfigurationManager.ConnectionStrings["ConnectionString"].ToString();
>> > }
>> > }
>> > return _connectionString;
>> > }
>> > }
>> >
>> > --
>> > Bryan Phillips
>> > MCSD, MCDBA, MCSE
>> > Blog: http://bphillips76.spaces.live.com
>> > Web Site: http://www.composablesystems.net
>> >
>> >
>> >
>> > "Charlie@CBFC" <charlie@xxxxxxxxxxxxxxxxx> wrote in message
>> > news:OYB$TYqfHHA.4064@xxxxxxxxxxxxxxxxxxxx:
>> >
>> >> Hi:
>> >>
>> >> This code compiles and runs fine, but I get this error when try to
>> >> open a
>> >> form in WinForm designer. Commenting it out fixes problem. Weird!
>> >>
>> >> "Object reference not set to an instance of an object.
>> >> at RepairShop.DataService.get_ConnectionString() in C:\My
>> >> Projects\RepairShop\DataService.cs:line 16"
>> >>
>> >>
>> >> public static string _connectionString = String.Empty;
>> >> public static string ConnectionString {
>> >> get {
>> >> if( _connectionString == String.Empty ) {
>> >> _connectionString =
>> >> System.Configuration.ConfigurationManager.ConnectionStrings["ConnectionString"].ToString();
>> >> }
>> >> return _connectionString;
>> >> }
>> >> }
>> >>
>> >> Thanks!
>> >> Charlie
>> >
>
.
- Follow-Ups:
- Re: This code compiles/runs but breaks designer...
- From: Charlie@CBFC
- Re: This code compiles/runs but breaks designer...
- References:
- Re: This code compiles/runs but breaks designer...
- From: Charlie@CBFC
- Re: This code compiles/runs but breaks designer...
- Prev by Date: Re: Datagridview help
- Next by Date: Re: Adding an event handler to a dynamically populated control
- Previous by thread: Re: This code compiles/runs but breaks designer...
- Next by thread: Re: This code compiles/runs but breaks designer...
- Index(es):
Relevant Pages
|