Field token out of range (System.BadImageFormatException)

G

Guest

I've converted a VB6 project to VB.Net 2005. (Actually using vstudio pro
2005).
I'm on a machine that also has VB6 and Vstudio.net 2003 on it. The project
uses Word, Excel, MapPoint and SqlClient (database is SqlServer 2000). OS is
WinXP SP2.

When I run the project, it opens the MDI form (MdiMain.vb) fine, but when I
open one of the child forms and try to select something in a combo box
(cboFilter2) it stops on a line of the MdiMain.Designer.vb file. The line it
stops on is the very first statement:
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()>
Partial Class MdiMain
--

Roger Aikin

I've copied the stack trace below: It's long and ugly! I haven't been able
to find any information on this "Field token out of range" error. Anyone
have any good ideas as to where I should start looking?

System.BadImageFormatException was unhandled
Message="Field token out of range."
Source="JWFLTerritory"
StackTrace:
at JWFLTerritory.frmList.cboFilter2_SelectedIndexChanged(Object
eventSender, EventArgs eventArgs)
at System.Windows.Forms.ComboBox.OnSelectedIndexChanged(EventArgs e)
at System.Windows.Forms.ComboBox.WmReflectCommand(Message& m)
at System.Windows.Forms.ComboBox.WndProc(Message& m)
at
System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd,
Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.SendMessage(HandleRef
hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)
at System.Windows.Forms.Control.SendMessage(Int32 msg, IntPtr wparam,
IntPtr lparam)
at System.Windows.Forms.Control.ReflectMessageInternal(IntPtr hWnd,
Message& m)
at System.Windows.Forms.Control.WmCommand(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.ContainerControl.WndProc(Message& m)
at System.Windows.Forms.Form.WndProc(Message& m)
at
System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd,
Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.CallWindowProc(IntPtr
wndProc, IntPtr hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)
at System.Windows.Forms.NativeWindow.DefWndProc(Message& m)
at System.Windows.Forms.Control.DefWndProc(Message& m)
at System.Windows.Forms.Control.WmCommand(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ComboBox.WndProc(Message& m)
at
System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd,
Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.CallWindowProc(IntPtr
wndProc, IntPtr hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)
at System.Windows.Forms.NativeWindow.DefWndProc(Message& m)
at System.Windows.Forms.ComboBox.DefChildWndProc(Message& m)
at System.Windows.Forms.ComboBox.ChildWndProc(Message& m)
at
System.Windows.Forms.ComboBox.ComboBoxChildNativeWindow.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 JWFLTerritory.MdiMain.Main() in
C:\Work\AikinsServices\EvanstonJW\JWFLTerritory.NET\MdiMain.Designer.vb:line 2
 
S

Stephany Young

You are reading the stack trace upside-down.

The place to start looking is the
JWFLTerritory.frmList.cboFilter2_SelectedIndexChanged event handler.
 
S

Stephany Young

.... and the key word you are looking for in help is BadImageFormatException.
 
G

Guest

I also notice that the MapPoint 11.0 Object Library is actually a .TLB
instead of a DLL, and unlike the Word or Office Object Libraries, MapPoint
gets Referenced with "Copy Local" = true. Does this bring to mind any
possible causes of the error below?
 
G

Guest

Sorry it took awhile to reply. This is a "volunteer" project, so it doesn't
get the highest priority.

I've tried looking for both "BadImageFormatException" and "Field Token out
of range". Neither of which yielded any useful information.
How can I figure out what "Image" it's trying to load? Why would it be in
MdiMain.Designer.vb:line 2 (code it wrote for itself) when it's already been
through there before. I've stepped through this code when the program
started, and it made it through fine. I haven't unloaded the main form, and
yet now I'm doing something on the child form (selecting an item in a combo
box) and the program stops back in MdiMain.Designer.vb. I'm not reading the
stack trace upside-down: it really is stopping in debug mode with the
execution point is on this line in the MDI form's designer module:
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()>
Partial Class MdiMain
How can that happen?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top