The informative error message:
An unhandled exception of type 'System.BadImageFormatException' occurred in .dll
Additional information: An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)
The detailed inner exception:
The code that caused the compiler to produce bad IL code:
Here's the Fix:
public class ActiveRecordForApp<T> : ActiveRecordBase<T>
where T : class
{
}
Yes, it's 100% true. If you put a generic constraint "T: class" then your code will generate bad IL which is completely undebugable. So why use a generic constraint "T : class" you ask? Because IT'S WRITTEN ON MSDN WITH NO WARNING!!!
http://msdn2.microsoft.com/en-us/library/d5x73970.aspx
Can someone please change this MSDN documentation to not encourage programmers to produce faulty IL?
The official fix & "workaround" can be found on the microsoft connect Website:
https://connect.microsoft.com/feedback/viewfeedback.aspx?FeedbackID=93389&wa=wsignin1.0&siteid=210