New Posts New Posts RSS Feed: IdeaBlade.Core.TraceFns throws System.TypeInitializationException in WinForm Client
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

IdeaBlade.Core.TraceFns throws System.TypeInitializationException in WinForm Client

 Post Reply Post Reply
Author
sebma View Drop Down
Groupie
Groupie
Avatar

Joined: 19-Aug-2008
Location: Singapore
Posts: 66
Post Options Post Options   Quote sebma Quote  Post ReplyReply Direct Link To This Post Topic: IdeaBlade.Core.TraceFns throws System.TypeInitializationException in WinForm Client
    Posted: 20-Apr-2010 at 11:33pm
With reference to
 
IdeaBlade.Core.TraceFns throws System.TypeInitializationException just by having the following codes in in WinForm Client program's Main entry:
 
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
    IdeaBlade.Core.TraceFns.WriteLine("Hello");
 
System.TypeInitializationException: The type initializer for 'IdeaBlade.Core.TraceFns' threw an exception. ---> System.NullReferenceException: Object reference not set to an instance of an object.
   at IdeaBlade.Core.TraceFns.StackWriteLine(StackFrame pStackFrame, String pMessage)
   at IdeaBlade.Core.TraceFns.StackWriteLineIf(Boolean pCondition, String pMessage)
   at IdeaBlade.Core.TraceFns.WriteLine(Object value)
   at IdeaBlade.Core.AuthHelper.LoadRuntimeLicense(Action`1 errorCallback)
   at IdeaBlade.Core.IdeaBladeConfig.Initialize()
   at IdeaBlade.Core.IdeaBladeConfig.get_Instance()
   at IdeaBlade.Core.TraceFns.Initialize()
   at IdeaBlade.Core.TraceFns..cctor()
 
Remove the above line and WinForm Client works as usual, IdeaBlade logs written to:
<logging logFile="DebugLog.xml" />
 
I am still using DevForce v.5.2.3.1, server-side has no such problem. With DevForce supporting SilverLight clients now, is it now not possible to use IdeaBlade.Core.TraceFns in WinForm Client too?
 
Thanks
Sebastian
 
 
 
 
Back to Top
kimj View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 09-May-2007
Posts: 1391
Post Options Post Options   Quote kimj Quote  Post ReplyReply Direct Link To This Post Posted: 21-Apr-2010 at 10:37am
Hi Sebastian,
 
You can definitely use tracing from WinClient applications.  That unfortunate exception is due to a kind of race condition at startup -- TraceFns.WriteLine needs the TraceFns static class initialized, which in turn needs the IdeaBladeConfig.Instance loaded.  We're not correctly detecting this, or controlling initialization sequence, so you get this ugly error.
 
There's an easy workaround, however, and is what we actually do automatically in the server-side code (for slightly different reasons) -- just call the following before the TraceFns.WriteLine call:
 
  IdeaBlade.Core.IdeaBladeConfig.AssertNonDefaultVersion();
 
This will ensure that the IdeaBladeConfig is initialized, and you can then use TraceFns normally.
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down