Determine where I am running 
Author Message
 Determine where I am running

I need to be able to determine whether or not my WinForm is running in the IDE (design mode) or is running as an application.

I have created a base form class from which I inherit other forms with similar behaviour. Unfortunately, the base form tries to connect to a database but the connection is not available from within the IDE. This then causes an error whenever I try and open the inherited form in the form designer.

There was a property in VB6 (UserControl.Ambient.UserMode) that performed the same as I am now looking to do (though only in User Controls) but I cannot find an equivalent in C#.

Thanks in advance.



Fri, 25 Jun 2004 04:53:26 GMT  
 Determine where I am running
Martin,
Look at Component.DesignMode, which Controls & Forms inherit.

Hope this helps
Jay


I need to be able to determine whether or not my WinForm is running in the
IDE (design mode) or is running as an application.

I have created a base form class from which I inherit other forms with
similar behaviour. Unfortunately, the base form tries to connect to a
database but the connection is not available from within the IDE. This then
causes an error whenever I try and open the inherited form in the form
designer.

There was a property in VB6 (UserControl.Ambient.UserMode) that performed
the same as I am now looking to do (though only in User Controls) but I
cannot find an equivalent in C#.

Thanks in advance.



Fri, 25 Jun 2004 05:25:39 GMT  
 Determine where I am running
Jay,

That is exactly what I wanted, however, how do I link the 'ISite' as without
it DesignMode is always false. The help only mentions that ISite exists.

I have also tried this.Site.DesignMode, however, this.Site = null and again,
I do not know how to set it in the first place.

An example would be great if available?

Thanks



Quote:
> Martin,
> Look at Component.DesignMode, which Controls & Forms inherit.

> Hope this helps
> Jay



> I need to be able to determine whether or not my WinForm is running in the
> IDE (design mode) or is running as an application.

> I have created a base form class from which I inherit other forms with
> similar behaviour. Unfortunately, the base form tries to connect to a
> database but the connection is not available from within the IDE. This
then
> causes an error whenever I try and open the inherited form in the form
> designer.

> There was a property in VB6 (UserControl.Ambient.UserMode) that performed
> the same as I am now looking to do (though only in User Controls) but I
> cannot find an equivalent in C#.

> Thanks in advance.



Sat, 26 Jun 2004 05:12:01 GMT  
 Determine where I am running
Martin,
Good question, as I thought it worked in my one of my simple little tests...
(Beta 2)

I'll try and get back to you...

Jay


Quote:
> Jay,

> That is exactly what I wanted, however, how do I link the 'ISite' as
without
> it DesignMode is always false. The help only mentions that ISite exists.

> I have also tried this.Site.DesignMode, however, this.Site = null and
again,
> I do not know how to set it in the first place.

> An example would be great if available?

> Thanks


message

> > Martin,
> > Look at Component.DesignMode, which Controls & Forms inherit.

> > Hope this helps
> > Jay



> > I need to be able to determine whether or not my WinForm is running in
the
> > IDE (design mode) or is running as an application.

> > I have created a base form class from which I inherit other forms with
> > similar behaviour. Unfortunately, the base form tries to connect to a
> > database but the connection is not available from within the IDE. This
> then
> > causes an error whenever I try and open the inherited form in the form
> > designer.

> > There was a property in VB6 (UserControl.Ambient.UserMode) that
performed
> > the same as I am now looking to do (though only in User Controls) but I
> > cannot find an equivalent in C#.

> > Thanks in advance.



Sat, 26 Jun 2004 08:13:07 GMT  
 Determine where I am running
Martin,
Excuse me, but I did not say use ISite.DesignMode I said use
Component.DesignMode.

I am working on an example, but try:

    this.DesignMode

Now if this.DesignMode internally maps to this.Site.DesignMode, then I am
sorry...

Hope this helps
Jay


Quote:
> Jay,

> That is exactly what I wanted, however, how do I link the 'ISite' as
without
> it DesignMode is always false. The help only mentions that ISite exists.

> I have also tried this.Site.DesignMode, however, this.Site = null and
again,
> I do not know how to set it in the first place.

> An example would be great if available?

> Thanks


message

> > Martin,
> > Look at Component.DesignMode, which Controls & Forms inherit.

> > Hope this helps
> > Jay



> > I need to be able to determine whether or not my WinForm is running in
the
> > IDE (design mode) or is running as an application.

> > I have created a base form class from which I inherit other forms with
> > similar behaviour. Unfortunately, the base form tries to connect to a
> > database but the connection is not available from within the IDE. This
> then
> > causes an error whenever I try and open the inherited form in the form
> > designer.

> > There was a property in VB6 (UserControl.Ambient.UserMode) that
performed
> > the same as I am now looking to do (though only in User Controls) but I
> > cannot find an equivalent in C#.

> > Thanks in advance.



Sat, 26 Jun 2004 10:08:39 GMT  
 Determine where I am running
Martin,
Just tried it in VB.NET.

Using Me.DesignMode (this.DesignMode) correctly identifies if the control is
in design mode. I had to put the control in a seperate project...

I would not expect the form to be any different, as it inherits from
Control...

Hope this helps
Jay


Quote:
> Jay,

> That is exactly what I wanted, however, how do I link the 'ISite' as
without
> it DesignMode is always false. The help only mentions that ISite exists.

> I have also tried this.Site.DesignMode, however, this.Site = null and
again,
> I do not know how to set it in the first place.

> An example would be great if available?

> Thanks


message

> > Martin,
> > Look at Component.DesignMode, which Controls & Forms inherit.

> > Hope this helps
> > Jay



> > I need to be able to determine whether or not my WinForm is running in
the
> > IDE (design mode) or is running as an application.

> > I have created a base form class from which I inherit other forms with
> > similar behaviour. Unfortunately, the base form tries to connect to a
> > database but the connection is not available from within the IDE. This
> then
> > causes an error whenever I try and open the inherited form in the form
> > designer.

> > There was a property in VB6 (UserControl.Ambient.UserMode) that
performed
> > the same as I am now looking to do (though only in User Controls) but I
> > cannot find an equivalent in C#.

> > Thanks in advance.



Sat, 26 Jun 2004 10:18:00 GMT  
 Determine where I am running
No

It does not work on a form !



Quote:
> Martin,
> Just tried it in VB.NET.

> Using Me.DesignMode (this.DesignMode) correctly identifies if the control
is
> in design mode. I had to put the control in a seperate project...

> I would not expect the form to be any different, as it inherits from
> Control...

> Hope this helps
> Jay



> > Jay,

> > That is exactly what I wanted, however, how do I link the 'ISite' as
> without
> > it DesignMode is always false. The help only mentions that ISite exists.

> > I have also tried this.Site.DesignMode, however, this.Site = null and
> again,
> > I do not know how to set it in the first place.

> > An example would be great if available?

> > Thanks


> message

> > > Martin,
> > > Look at Component.DesignMode, which Controls & Forms inherit.

> > > Hope this helps
> > > Jay



> > > I need to be able to determine whether or not my WinForm is running in
> the
> > > IDE (design mode) or is running as an application.

> > > I have created a base form class from which I inherit other forms with
> > > similar behaviour. Unfortunately, the base form tries to connect to a
> > > database but the connection is not available from within the IDE. This
> > then
> > > causes an error whenever I try and open the inherited form in the form
> > > designer.

> > > There was a property in VB6 (UserControl.Ambient.UserMode) that
> performed
> > > the same as I am now looking to do (though only in User Controls) but
I
> > > cannot find an equivalent in C#.

> > > Thanks in advance.



Tue, 29 Jun 2004 03:43:13 GMT  
 Determine where I am running
Martin,
Interesting, even when the form is in a different assembly?

Like I said: with the control it did not work if the control was in the same
assembly, it did work in a different assembly.

Guess I will need to try that later.

This sounds like a bug, be sure to report it at http://beta.visualstudio.net

Hope this helps
Jay


Quote:
> No

> It does not work on a form !


message

> > Martin,
> > Just tried it in VB.NET.

> > Using Me.DesignMode (this.DesignMode) correctly identifies if the
control
> is
> > in design mode. I had to put the control in a seperate project...

> > I would not expect the form to be any different, as it inherits from
> > Control...

> > Hope this helps
> > Jay



> > > Jay,

> > > That is exactly what I wanted, however, how do I link the 'ISite' as
> > without
> > > it DesignMode is always false. The help only mentions that ISite
exists.

> > > I have also tried this.Site.DesignMode, however, this.Site = null and
> > again,
> > > I do not know how to set it in the first place.

> > > An example would be great if available?

> > > Thanks


> > message

> > > > Martin,
> > > > Look at Component.DesignMode, which Controls & Forms inherit.

> > > > Hope this helps
> > > > Jay



> > > > I need to be able to determine whether or not my WinForm is running
in
> > the
> > > > IDE (design mode) or is running as an application.

> > > > I have created a base form class from which I inherit other forms
with
> > > > similar behaviour. Unfortunately, the base form tries to connect to
a
> > > > database but the connection is not available from within the IDE.
This
> > > then
> > > > causes an error whenever I try and open the inherited form in the
form
> > > > designer.

> > > > There was a property in VB6 (UserControl.Ambient.UserMode) that
> > performed
> > > > the same as I am now looking to do (though only in User Controls)
but
> I
> > > > cannot find an equivalent in C#.

> > > > Thanks in advance.



Tue, 29 Jun 2004 07:53:31 GMT  
 
 [ 8 post ] 

 Relevant Pages 

1. help determine if a task is still running and kill it if it is running

2. Where am I running

3. How to determine if the control is running in the IDE

4. Determining type at run-time or compile-time

5. determining the available storage on the stack at run time

6. How to determine if program is running interactively???

7. determining which windows OS is running

8. determining which windows OS is running

9. Determine Column Data Type at run time

10. Determine if running Win95/95/NT/2000?

11. Determining Which Windows NT Service is running from inside the code

12. Determining if an application is running

 

 
Powered by phpBB® Forum Software