BadImageFormationException when using static variables

I am having a problem that may be a bug. When I use static variable declarations inside a sub (timer_tick in one case). When I do this, just before the sub executes, I get an error. If I change the static variable to be dimensioned outside the sub at the form level, everything works. Below is the exception description:

System.BadImageFormatException was unhandled
Message="Field token out of range."
Source="LoggerMonitor"
StackTrace:
at LoggerMonitor.frmLoggerMonitor.Timer1_Tick(Object eventSender, EventArgs eventArgs)

at System.Windows.Forms.Timer.OnTick(EventArgs e)

at System.Windows.Forms.Timer.TimerNativeWindow.WndProc(Message& m)

at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)

at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)

at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)

at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)

at System.Windows.Forms.Application.Run(Form mainForm)

at LoggerMonitor.frmLoggerMonitor.Main() in D:\Library\TCPmonitor\LoggerMonitor.NET\LoggerMonitor.Designer.vb:line 1

at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)

at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)

at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()

at System.Threading.ThreadHelper.ThreadStart_Context(Object state)

at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)

at System.Threading.ThreadHelper.ThreadStart()

[2024 byte] By [rockybooth] at [2007-12-16]
# 1

Sounds like a bug, report it at the Microsoft Product Feedback Center.

DavidM.Kean at 2007-9-8 > top of Msdn Tech,Visual Basic,Visual Basic General...
# 2
I've got the same Problem. So, ...
... thanks for your problem description.
After i removed the static variable from my function body and put it to private class Attribute back my code works fine.
bugfix ?!?
SeniorDevman at 2007-9-8 > top of Msdn Tech,Visual Basic,Visual Basic General...