Warning 1 warning LNK4248: unresolved typeref token (0100001D) for 'Message_ProgressIndicator'; image may not run C:\Opencascade

Hello.

I managed to build the C# sample but when try to create a new doc I get the following exception:
BadImageFormatException
Could not load file or assembly 'shell, Version=0,0,0,0, Culture Neutral, PublicKeyToken=null or one of its dependencies. And attempt was made to load a program with an incorrect format.

When building the shell project I got the warning described in the subject of this thread.

The exception occur at
static void Main()
{
Application.Run(new Form1());
}

Here is the exception copied from the program.

System.BadImageFormatException was unhandled
Message=Could not load file or assembly 'shell, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. An attempt was made to load a program with an incorrect format.
Source=IE
FileName=shell, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
FusionLog==== Pre-bind state information ===
LOG: User = molokai\jsantos
LOG: DisplayName = shell, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
(Fully-specified)
LOG: Appbase = file:///C:/Opencascade/samples/c#/IE/bin/Debug/
LOG: Initial PrivatePath = NULL
Calling assembly : IE, Version=1.0.4797.20468, Culture=neutral, PublicKeyToken=null.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Opencascade\samples\c#\IE\bin\Debug\IE.vshost.exe.Config
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Attempting download of new URL file:///C:/Opencascade/samples/c#/IE/bin/Debug/shell.DLL.
ERR: Failed to complete setup of assembly (hr = 0x8007000b). Probing terminated.

StackTrace:
at IE.Form1.toolBar1_ButtonClick(Object sender, ToolBarButtonClickEventArgs e)
at System.Windows.Forms.ToolBar.WmReflectCommand(Message& m)
at System.Windows.Forms.ToolBar.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.WmCommand(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.Form.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.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ToolBar.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(IntPtr 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 IE.Form1.Main() in C:\Opencascade\samples\c#\IE\Form1.cs:line 609
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException:

Any help will be appreciated
TIA
Jair Santos

Patrik Mueller's picture

Hi,

I haven't use OCC with C#, but normally, "System.BadImageFormatException" is shows a problem of your .net settings: check your project platform settings for C#. Don't use "any CPU"!

Best regards,

Patrik

jairds's picture

Thank you Patrik.

Actually that's the first change that I made to the project. I saw some information in another thread and set the platform to x86. I still got the same error. I suspect that the exception is related to the warning that I get when building the shell project.

Warning 1 warning LNK4248: unresolved typeref token (0100001D) for 'Message_ProgressIndicator'; image may not run C:\Opencascade\samples\c#\OCC\OCCViewer.obj OCC

Pawel's picture

Hi Jair,

I don't think the warning LNK4248 is the reason why the application does not start. I know the warning but do not have a problem with starting ma OCCT-based C# application.

Make sure all the necessary Dlls are visible to the application.

If you use the precompiled OCCT version, make sure your side-by-side configuration is correct.

Hope this helps,
Pawel

Mihai Ciocan's picture

Hello Jair,

I wanted to check if you managed to identify the cause of the error. |I'm new to open cascade and I'm trying to better understand what is happening.

Mihai Ciocan's picture

I have managed to fix the issue on my side by switching to win32/x86.

PS I am using VS10