Problems with C# sample

I rebuilt (after much difficulty) the C# sample (IE, OCC, shell) with VS2010. I had to change a few things: set up include and lib directories, change shell and occ to .NET 4 framework (because that was the framework that IE targeted after import to VS2010).

Since I am running 64-bit Windows 7, I had to change the IE target from "Any CPU" to x86 (since that is what shell and OCC targeted) otherwise I would get a cryptic MSoft error message saying a DLL had a bad format (attempt to call a 32-bit dll from 64-bit executable).

Now the program comes up but when I click File/New I get an error that it cannot find shell.dll or one of its dependencies. Shell.dll is in fact in the same directory as IE.exe and OCC.dll. So presumably it is complaining about one if its dependencies.

Am I missing something obvious? I don't see how to figure out what shell.dll dependencies are.

Pawel's picture

Hi Michael,

on Windows 7 you can use sxstrace.exe to find what (assembly) the program exactly complains about.

Have a look here: http://www.codeproject.com/Articles/43681/Side-by-Side-Configuration-Inc...

Pawel

MichaelBate_98386's picture

Pawel,

Thank you, but I tried what they suggest and sxstrace produced a log that was essentially empty: the parsed log had only three characters. I tried looking at the original log with a hex viewer and could see that it mainly contained kilobytes of "FF" characters.

I used ildasm to get a dump of the DLLs that it needed and found many (such as TKXSBase.dll) from the OpenCascade DLL directory (c:\opencascade6.5.3\ros\win32\vc9\bin). I tried adding the OpenCascade directory of DLLs at the front of my PATH, then invoked the program (IE.EXE) from the command line and got the same error. I even tried compiling IE.EXE and the two DLLs that are part of the solution (shell.dll and occ.dll) into the OpenCascade DLL directory and invoked it from there. This time IE.EXE did not even display its window and Windows reported that it had "stopped working."

Has anyone succeeded in getting the C# sample to work with VS 2010?

Carlos's picture

Hi,

IE.exe must find all the proper dependencies to work and this is most likely the source of this error.

A good practice is the last test you have done putting ie.exe, shell.dll and occ.dll in the binary folder as you assure that all the dlls are in the same path.

Some points I would check:

Environtment variables ($Casroot) specially of the installation. You can use setenvirontmentvariable
You are saying that the dll's directory is \win32\vc9\bin but you use VS2010 so the directory should be VC10. If you are using precompiled dlls check this point.
IE.exe depends on Shell.dll and this on OCC.dll, that calls to the OCCT TK's libraries. But please consider that these TK's libraries also depends on some third party dlls, depending on your configuration (for example freeimage.dll). Check that you also have these dlls on the same directory.
I use Dependency walker to see the depencencies on a dll. I think that it is also provided with VS 2010 and if not is free. If you open OCC.dll you will see if someone is missing.
Another point to check is to be sure that all the dll's and the executable are Win32

Regards,

MichaelBate_98386's picture

I solved my problem. I overlooked the need to set all the environment variables. Stupid mistake. The overview documentation describes these environment variables in gory detail, so I should have known.

I have some other questions (about C# wrappers), but I will start a new thread.