EnableThemingInScope Error???

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am getting the following error when starting a winform app that causes the
app to simply hang and I have to end up killing it from taskmgr

Error loading main form : Object reference not set to an instance of an
object.

at System.Windows.Forms.EnableThemingInScope..ctor(Boolean enable)
at System.Windows.Forms.ThreadContext.RunMessageLoop(Int32 reason,
ApplicationContext context)
at System.Windows.Forms.Application.DoEvents()
at msSQLed.MainForm..ctor()

Any ideas why this would be hosing??? I looked in .NET code (using
reflector) and it looks like this method EnableThemingInScope is simply
checking to see if Themes are supported and I can't see why it would hang the
app???

Thanks,

Ashton
 
Hi Ashton,

That's an odd looking callstack. Are you launching the MainForm using
Application.Run(new MainForm())?

Why does your MainForm's constructor call Application.DoEvents()?

Perhaps posting the code from your main method or the MainForm might enable
us to make some more suggestions.

Hope this helps.

Regards,
Matt Garven
 
Matt,

I do things maybe a little non-standard. In my main method, I have
something like the following:

public class Start
{
public static Form m_Form;

static void Main()
{
Start.m_Form = new Form();
Application.Run(Start.m_Form);
}
}

In the ctor for the form I'm creating I do call DoEvents but I can't figure
out why it only breaks on one PC out of several hundred users??? Do I need
to handle things differently or might there be something specific on this
users PC?

My ctor basically checks some settings, shows an activation/registration
form if user is not registered, etc. I could definitely remove the DoEvents
if that is what is causing the issue.

Thanks,

Ashton
 
Hi Ashton,

If it's only breaking on one PC, perhaps you could post the specs of that
machine to the group? We've had a horrible time with our customers running
..NET software on Windows 98 machines, for example.

If you have the PC available to you for testing, I would certainly try
removing the call to Application.DoEvents(). It would be unusual to require
it before the form has become visible, especially the mainform of the
application. It's worth a shot, and if it doesn't work it would be
interesting to see the callstack of where it crashed without the call to
Application.DoEvents().

Hope this helps.

Regards,
Matt Garven

Ho
 
Back
Top