How to tell if you're in DesignMode in Compact framework?

G

Guest

I'm in C# on Mobile 5 and I need to know if I'm in DesignMode. The
DesignMode bool doesn't seem to be supported in the Compact Framework.
TIA,
Jim
 
S

Simon Hart

Use the conditional compilation syntax for example:

#if DESIGN
MessageBox.Show("Design mode.");
#else
MessageBox.Show("Runtime mode.");
#endif

Regards
Simon.
 
G

Guest

Hi Simon,
I must be missing something.
Are you saying that there are automatically two versions of a program
generated? One for design and one for runtime?
Thanks,
Jim
 
I

Ilya Tumanov [MS]

For NETCF V1 you have to use separate design time assemblies so it would
work.

For NETCF V2 you could use the following (assuming 'this' is a Component):

if ((this.Site != null) && this.Site.DesignMode) {
// Design mode
}

--
Best regards,

Ilya

This posting is provided "AS IS" with no warranties, and confers no rights.

*** Want to find answers instantly? Here's how... ***

1. Go to
http://groups-beta.google.com/group/microsoft.public.dotnet.framework.compactframework?hl=en
2. Type your question in the text box near "Search this group" button.
3. Hit "Search this group" button.
4. Read answer(s).
 
G

Guest

Yesss!
This works!
Thanks Ilya, this was just what I needed.
My lack of experience with the compact framework is showing. I didn't
realize that previous versions required two versions of a control.
You learn something every day, if you're not carefull!
Thanks again,
Jim
 
C

Chris Tacke, eMVP

We use the following:

private static bool IsDesignTime
{
get
{
// Determine if this instance is running against .NET Framework by
using the MSCoreLib PublicKeyToken
System.Reflection.Assembly mscorlibAssembly = typeof(int).Assembly;
if ((mscorlibAssembly != null))
{
if
(mscorlibAssembly.FullName.ToUpper().EndsWith("B77A5C561934E089"))
{
return true;
}
}
return false;
}
}


--

Chris Tacke, Embedded MVP
OpenNETCF Consulting
Giving back to the embedded community
http://community.OpenNETCF.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top