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

  • Thread starter Thread starter Guest
  • Start date Start date
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
 
Use the conditional compilation syntax for example:

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

Regards
Simon.
 
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
 
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).
 
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
 
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
 
Back
Top