I just discovered this appears to have something to do with the static declaration AND the fact that the class is a "Partial" class, 2 files, which I used to denote a specific purpose for some code...
So the actual error now appears like the following...
Friend class myclass sub StaticRuotineWithErrorOnCall() ' this routine raises the BadImageFormatException if called. Static iLoadedHour as integer = -1 if not iLoadedHour = hour(now) then 'reload the user data hourly and on the first pass. 'code here to load the user data from the database... iLoadedHour=hour(now) 'set last loaded hour to check against end if end sub end class
Partial class myclass sub StaticRoutineWithNoErrorOnCall() Static iLoadedHour as integer = -1 'This routine works while the other routine doesn't if not iLoadedHour = hour(now) then 'reload the user data hourly and on the first pass. 'code here to load the user data from the database... iLoadedHour=hour(now) 'set last loaded hour to check against end if end sub end class
additional notes... -Moving the subroutine with the static declaration from the partial class to the main class file/definitiion fixes the problem for some reason. -If an Event is in the main class file has a static declaration in it (my code uses a "system.timers.timer") the event never fires in compiled code, but doesn't complain.
This has got to be some kind of compiler issue. Sort of like the compiler only properly initializes the static variables in the first partial class or something.
|