Can't instanciate MyApp class

Hello. Thanks Mikael and Fabrizio. I'm trying to define my own "MyApplication_Application" class but I must be missing something. I've created a project with "CAS.CADE Viewer AppWizzard" with all option disable. (I still get a runtime error if I use a 2DViewer option) Then I defined my class inheriting from TDocStd_Application. I've opened the "SampleOCAF" project and made my class exact same way. I copied the code in TSampleOcaf_Application.cxx, hxx, ixx and jxx files. I've also copied Handle_TSampleOcaf_Application.hxx and the OCAF includes in stdAfx.h It worked fine until I tried to instanciate my class.

I've tried to create the object in two ways:

Handle(MyApplication_Application) = new MyApplication_Application();

and

Handle(TDocStd_Application) app = new MyApplication_Application ();

I got no build error but when I try to execute the application I get a "runtime error".

If I try to debug it I get: "Unhandled excepption in MyApplication.exe (KERNEL32.DLL): 0xE06D7363: Microsoft C++ Exception."

I also think all system variables are correctly set: CASROOT = D:\CASCADE CSF_GraphicShr = D:\CASCADE\windows_nt\dll\OpenGl.dll CSF_MDTVFontDirectory = D:\CASCADE\src\Textures CSF_UnitsDefinition=D:\CASCADE\src\UnitsAPI\Units.dat CSF_UnitsLexicon=D:\CASCADE\src\UnitsAPI\LexiExpr.dat DRAWDEFAULT=D:/CASCADE/DrawResources/DrawDefault DRAWHOME=D:/CASCADE/DrawResources

and added D:\CASCADE\windows_nt\dll in PATH

Can anyone help me

Thanks

fabrizio's picture

Hello

> I got no build error but when I try to
> execute the application I get a
> "runtime error".

> If I try to debug it I get: "Unhandled
> excepption in MyApplication.exe
> (KERNEL32.DLL): 0xE06D7363: Microsoft C++
> Exception."

I see your environment variables and I think that you forgot to set four variables. The TDocStd_Application uses those variables to load/save document and other internal setting. This variablas are set to:

CSF_PluginDefaults= (DIR)\Plugin CSF_PluginUserDefaults= (DIR)\Plugin

CSF_ResourcesDefaults = (DIR)\Resources CSF_ResourcesUserDefaults = (DIR)\Resources

Where (DIR) is some directory in which there are the Plugin and Rsources file provides whith OCAF sample by CAS.CADE.

"Resources" is the name that you return in ResourcesName() method in your application.

Fabrizio