473,414 Members | 1,862 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,414 software developers and data experts.

Descendant form will not display in design mode

I have a winform base class in which I dynamically set a web reference Url:

myService.Url = <WebServer> + "MyService.asmx";

where <WebServer> is pulled from my App.config file.

There is no problem working with this base class and the solution compiles
and runs fine. However, I am unable to display any descendant forms in
design mode in VS.NET 2003. I get a message indicating that:

"An exception occurred while trying to create and instance of <form base
class>. The exception was "Invalid URI: The format of th URI could not be
determined."

Clearly, it cannot resolve the dynamic web reference in the base class. The
immediate work-around is to:

1. comment out the assignment and rebuild
2. do any descendant form design
3. uncomment the assignment and rebuild

Surely, there is a mode elegant mechanism to address this issue?

Thanks,
Chris.
Nov 16 '05 #1
6 1931
if (!this.DesignMode)
{
myService.Url = <WebServer> + "MyService.asmx";
}

I've found that in many cases I've had to put this at the beginning of
forms methods so that they don't bother running in design mode:

if (this.DesignMode)
{
return;
}

Nov 16 '05 #2
Yes, 'this.DesignMode' was my first thought but, alas, does not work. That
would be too easy. ;-)

Thanks,
Chris.
Nov 16 '05 #3
Can you post more code surrounding your problem?

Every problem I've had with the designer refusing to display a child
form has been because some method is running and trying to do "run
time" stuff in a design environment, and this.DesignMode is the
solution.

However, figuring out exactly which method it is and what it's trying
to do can be a bear. To this day I have two forms that _sometimes_ fail
to display in design mode with a message that there is a null
reference. Do you think I can figure out which method is being run
(which shouldn't be)? Naaah....

It's likely that it's not failing on the line of code you think it is:
that it's failing somewhere else.

Nov 16 '05 #4
"Bruce Wood" <br*******@canada.com> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.com...
Can you post more code surrounding your problem?

There is nothing else in the base form constructor other that the
InitializeComponent() call and the instantiation of the myService class
prior to setting the URL.
Every problem I've had with the designer refusing to display a child
form has been because some method is running and trying to do "run
time" stuff in a design environment, and this.DesignMode is the
solution.

However, figuring out exactly which method it is and what it's trying
to do can be a bear. To this day I have two forms that _sometimes_ fail
to display in design mode with a message that there is a null
reference. Do you think I can figure out which method is being run
(which shouldn't be)? Naaah....

It's likely that it's not failing on the line of code you think it is:
that it's failing somewhere else.


Well, all I need to do to get the descendant to display is comment out the
one line. Another option is to move the assignment line to the descendant
constructor and no problem. I guess this is just one of those things you
live with.

Thanks again,
Chris.
Nov 16 '05 #5
Ah... that makes sense.

DesignMode isn't set until your form has a window handle. The
constructor is too soon for that, so it returns "false".

The solution is to do as little as possible in the constructor, and do
as much set-up as possible in the form's ..._Load() method, where you
_do_ have a window handle and you _can_ use DesignMode effectively.

Perhaps if you set up Load method for your form (virtual, of course, so
your child classes can override it) and do your initialization in there?

Nov 16 '05 #6

"Bruce Wood" <br*******@canada.com> wrote in message
news:11**********************@l41g2000cwc.googlegr oups.com...
Ah... that makes sense.

DesignMode isn't set until your form has a window handle. The
constructor is too soon for that, so it returns "false".


Light bulb!

Thank you sir; all is well using the Load.

Chris.

Nov 16 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Codeman II | last post by:
Hi there, I am building a form where the user must upload a picture and fill in his details. Now I have a problem as all of this is on the same form. How will I be able to have the Browse...
4
by: Kevin Myers | last post by:
Hello, Please forgive my reposting of this note with hopefully a more relevant subject line. On an Access 2000 form under Windows 2000 I would like to use a Kodak Image Edit Control to...
2
by: ColinWard | last post by:
Hi. I have a form which has as its recordsource an SQL string. The SQL String is as follows: SELECT * from CONTACTS where false. this ensures that there is no data loaded in the form when the...
9
by: Lyn | last post by:
Hi, I have a form which is opened from a button on another form. The form is used to display a list of records from a recordset in Continuous Mode. It is sized vertically to display about 25...
6
by: Salad | last post by:
Hi: I have a Bill of Lading template from the printer that I saved as a BMP. I created a new report and in the report's picture property told it the BMP file name. It brought the image in just...
2
by: TerryStone | last post by:
I have created a control that displays a list of items. During design mode I fill it with junk data using calls from the constructor. So when I look at a form with the control on, instead of...
18
by: Diogenes | last post by:
Hi All; I, like others, have been frustrated with designing forms that look and flow the same in both IE and Firefox. They simply did not scale the same. I have discovered, to my chagrin,...
3
by: underground | last post by:
I found this form on the scripts. However when I attemp to open the php file on the sever I get a error message Parse error: syntax error, unexpected $end on line 238 <? /** * Main.php * *...
9
GazMathias
by: GazMathias | last post by:
Hi Guys, Acc2003. I have a form that is misbehaving by suddenly refusing to apply a filter I am passing to it. In a nutshell, I use a public variable to control the form's behaviour called...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.