Posted by Phil in .NET, .NET Examples
on Jun 18th, 2010 | Comments Off on Dealing with infinite recursion redux
In a previous post about infinite recursion I proposed the use of the ThreadStaticAttribute to deal with infinite recursion. This approach is fine so long as your recursion doesn’t cross threads, if it does the static variable will be reset for each new thread and offer not benefit.
Here’s an example, in .NET 4.0, to show you what I mean. In this example I have a simple logging setup, with a list of IListeners which handle messages that a logged with the LogMessage function. It’ll get into a infinite recursive loop becuase the LogToDiskListener attempts to log a message, and the...
Posted by Phil in .NET
on Aug 14th, 2009 | Comments Off on System.BadImageFormatException
Having recently started developing in Vista 64bit, this is an exception that I’ve bumped my head against a couple of times.
System.BadImageFormatException
“An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)”
If you’re in a 64bit environment, your solution is targeting “Any CPU” and you try to link to a 32bit library you’ll get this exception at runtime. Note that this doesn’t apply to just .NET libraries, if you’re linking to a native library you’ll get this exception...