Open CASCADE, the 3D modelling kernel
3D modeling & numerical simulation

Search the Forums
See All Topics

Fallen at first hurdle using C# Example in OCC6.2

Fallen at first hurdle using C# Example in OCC6.2
Ernest Abbott 2008/01/28 06:33
About 1 hours experience in OCC. Just installed it. I'm interested in the C# link to OCC. I'm using C# Express. After When I tried to run IE in the samples/standard/C# folder I get the following error:
"FileLoadException Was unhandled"
"{A procedure imported by 'shell, Version=, Culture=neutral, PublicKeyToken=null' could not be loaded.":"shell, Version=, Culture=neutral, PublicKeyToken=null"}

This happens when at
"Form2 newForm = new Form2();" line of code.

What is wrong, and why isn't the sample set up to work correctly. Is this some kind of initiation rite?
Gerhard Hofmann 2008/01/28 15:08
Hello Ernest,
I dont know much about the C# example of OpenCascade, but there is a .NET warpper for many OpenCascade classes:

best regards
Mikael Aronsson 2008/01/29 09:43
I don't know if it has improved today but at least in the past you could not even compile the sample code or the libraries without modifing the project files, there where lot's of incorrect settings in them, most of the time in the debug versions.
Pawel 2008/01/30 22:16
Hi Ernest,

- is shell.dll in the EXE-directory of the application? If not just copy the output files of all projects into one directory.
- as far as I know in VS Express you cannot mix different languages in one solution (it was so before but might have changed). In that case you would have to compile the projects separately and copy corresponding files into the same directory.

I use VS professional. I guess, I used the provided sample from OCC5.2 and it worked fine. OK there are some bugs but at least I was able to start the application.

Jonathan Hill 2008/02/03 21:25
Hi Ernest,

Ive updated the MakeBottle sample and you can download it from:- (watch out for the case sensitive path)

Let me know if it works for you.


Gareth 2008/10/29 16:50
I've had a very similar problem. I get the FileLoadException for shell. The odd thing is that with a try catch around the load, somehow the shell does manage to load the second time. However, there is another problem that on some machines that I have installed the release of the application it will crash again. One factor seems to be that I have tried it on a machine that did not have Visual Studio and it did not work, but then when I install Visual Studio the application will work. I was thinking that this might be just that the Visual C++ Runtime library needs to be installed, but haven't had much luck fixing it. I added the Visual C++ Runtime as a prerequisite to the project and tried installing the redistributable C++ runtime library, but still no luck.

I tried doing dependency walker on the application and shell, but it did not find anything that was not being referenced.

I also tried using the Modules feature in Visual Studio to see which dlls are actually used when the shell is loaded and I added these dlls to the application install directory, but this did not help either. I wasn't sure whether I needed to set the dlls to register and/or set them as system (msvcp80.dll, etc.), but I tried some of these things and was not able to fix the problem.

Any ideas of anything to try? It seems like the underlying issue is that the "Form2 newForm = new Form2();" line does not work, but I guess that something installed with visual studio has some sort of debugging feature that catches it and fixes the reference somehow??? I'm not very comfortable with DLLs, so there may be something trivial that I am not doing that could solve the problem. Thanks for any advice.
Test user 2008/11/08 22:49
Have someone found a solution to this problem? (w/ Form2 newForm = new Form2();?)
Im using VS 2008 and I get the same error message..

A procedure imported by 'shell, Version=, Culture=neutral, PublicKeyToken=null' could not be loaded.":"shell, Version=, Culture=neutral, PublicKeyToken=null"

I also try to use the Wrapper to Gerhard Hofmann, but when I try to run the MakeBottle I get an error when executing this line
Geom.TrimmedCurve aArcOfCircle =(new GC.MakeArcOfCircle(ref aPnt2, etc

Error: unable to load DLL OCasToDotNet.dll The specified module could not be found. HRESULT 0x8007007F..

I have referenced this in the PATH variable and under VC++ Directories, but with no luck :(

Test user 2008/11/08 22:51
I have placed the OCasToDotNet.dll in the bin folder of my project
Test user 2008/11/10 08:06
After running Dependency Walker on OCasToDotNet.dll, I got the message that im missing some files;
This is not in the 6.3 version of OCC but maybe in some older version?
Test user 2008/11/10 07:14
Finally I found a solution to this error:

A procedure imported by 'shell, Version=, Culture=neutral, PublicKeyToken=null' could not be loaded.":"shell, Version=, Culture=neutral, PublicKeyToken=null"

For some reason, it works by commenting out this part of code in the OCC.cpp file

DWORD ul_reason_for_call,
LPVOID lpReserved
     return TRUE;

But I still have a problem to use the wrapper to Gerhard Hofmann in my VS2008 Solution.. :(
Adrian 2009/01/13 18:01
I have the same problem with the Wrapper.
Im also using VS 2008 and the error message is the same "Unable to load DLL OCasToDotNet.dll".
I try to put it the system32 folder and in C:\OpenCASCADE6.3.0\ros\win32\bin, but it dont work. :-(
Can anyone help me, please?


siyamalan 2009/01/21 10:16
I also have the same problem. Can anyone help me??????????????????????????????????????????????
Dmitry Khabi 2009/01/21 12:40
I HAD the same problem:
application could not find OCC's dll. The solution:
copy dll in the directory with .exe.

Beim release copy ../win32/bin/
bei Debug copy ../win32/bind

additional copy this directory from ./src/:

In system variablen you don#t need to set the OCC' variables...

HB 2009/08/19 07:46
I have copied the OCasToDotNet.dll in the ..\bin\Debug directory of my application.
But i get still the error that the DLL couldn't be find.

Could anyone help me?

PS: I'am using
Kenny Busine 2012/04/05 23:26
I have run into a similar problem. Were you successful solving this problem? Please let me know.

Kevin Malachowski 2012/06/05 23:33
Have you figured out the solution to the problem of not getting OCasToDotNet.dll to load?
Durgesh 2013/07/13 09:36

I have recently tried running this sample with OCCT6.6. Getting the same error. What's the solution?

Francisco Oblea 2013/12/04 02:56
Same here... I was able to compile the example code but when I click on the File->New menu item the application crashes. I'm using VS 2012 ultimate edition.

I've attached two screenshots showing the exception and the directory contents.

I appreciate the help.
You have to be logged in to download the attached file
Latest news
  • Open CASCADE CAD Assistant for iOS platform is available!
  • Open CASCADE Technology 6.9.0 is available for download!
  • JT Assistant for Android

  • © OPEN CASCADE 2000 - 2015  |  Search  |  Contacts   |  Site map