using odbrbrepedgetraverser in a dll
using odbrbrepedgetraverser in a dll
a quick background history first:
we use borland builder 6, but because of problems with the dwgdirect borland libraries have decided to create a dll using visual studio 2005 and then make calls to this from our borland application.
this seems to work fine except when i try to use the edge traverser. the code looks a bit like this:-
odbrbrep brep;
if ( pent->iskindof( oddbregion::desc() ) )
oddbregionptr( pent )->brep( brep );
odbrbrepedgetraverser bet;
bet.setbrep( brep );
this worked ok when we linked dwgdirect as a static library, but now i get an 'unhandled exception' at the call to setbrep.
i know i am supposed to have modelergeometry.drx, but i'm not sure where it should go. should it be in the same location as my borland executable, my visual studio dll or somewhere else?
also, should it be renamed from modelergeometry_2.03_8.drx to modelergeometry.drx or should it retain that name?
a further complication to my situation is that i have made another visual studio application which i can use to call the dwgdirect dll as this is the only way i can debug the dwgdirect dll. again, i'm not sure where modelergeometry.drx should go.
i hope i have made myself clear with this explanation.
last edited by
geoff@ardensoftware.com; 8th february 2008 at 01:45 amfff">.
i think that modeler.drx should be with all other toolkit drx. usually it is application.exe folder.
thanks for the response, alexander. i've tried putting modelergeometry_2.03_8.drx (and a copy of it renamed as modelergeometry.drx) into the same folder as my borland application.exe and i still get the same problem.
any more ideas anyone?
could you please check the next code
code:
#define rx_modeler_geometry_appname dd_t("modelergeometry")
odrxclassptr pservice = odrxservicedictionary()->getat(dd_t("odmodelergeometrycreator"));
if (pservice.isnull())
{
odrxmoduleptr pmodule = odrxdynamiclinker()->loadapp(rx_modeler_geometry_appname);
if (pmodule.get())
{
pservice = odrxservicedictionary()->getat(dd_t("odmodelergeometrycreator"));
}
}loadapp(rx_modeler_geometry_appname)
should return non null value.
did you use any other drx with your application ? please, test this drx name with load code.
may be problem in the filefind function of application.
this won't compile for me, alexander. i get the following compiler error:-
smartptr.h(334) : error c2440: 'static_cast' : cannot convert from 'odrxobject *' to 'odrxmodule *'
types pointed to are unrelated; conversion requires reinterpret_cast, c-style cast or function-style cast
smartptr.h(333) : while compiling class template member function 'odrxmodule *odsmartptr<t>::get(void)'
with
[
t=odrxmodule
]
cdwgfile.cpp(36) : see reference to class template instantiation 'odsmartptr<t>' being compiled
with
[
t=odrxmodule
]
no, i don't use any other .drx files.
unfortunately, i won't have time to look at this any further until monday. thanks for your help so far.
have a good weekend.
ok, replace odrxmoduleptr to odrxobjectptr. you don't need type - just a result.
sorry, alexander, i was in a bit of a rush on friday.
in fact i could compile your original code, i just needed to #include "rxmodule.h"
so now i can see that loadapp is returning a null value.
hi,
i have checked the code of loadapp. the last call is
code:
hmodule hmodule = loadlibrary(name)so the next 'strong' drx name should work...
code:
odrxmoduleptr pmodule = odrxdynamiclinker()->loadapp(dd_t("d:\\modelergeometry"));also search rules for modelergeometry is standard search rules for windows loadlibrary:
the directory where the executable module for the current process is located.
the current directory.
the windows system directory. the getsystemdirectory function retrieves the path of this directory.
the windows directory. the getwindowsdirectory function retrieves the path of this directory.
the directories listed in the path environment variable.
hi alexander,
ok, i've put a copy of modelergeometry.drx into the following places:-
the windows directory
the location of the .exe
the location of the .vcproj (which i presume is the current directory)
at least one location from my path environment variable.
i've tried this with both dd_t("d:\\modelergeometry") and dd_t("modelergeometry") and still loadapp is returning a null value.
thanks,
geoff
hi alexander,
i don't know if this helps, but i tried the following line of code:-
code:
hmodule hmodule = loadlibrary( "modelergeometry.drx" );and got the following message:-
"application failed to start because dd_alloc_2.03_8.dll was not found..."
however, i do have dd_vc8md_alloc.lib in my list libraries.
thanks,
geoff
second thoughts, that probably isn't anything. i've copied all the .dll files from exe\vc8\release into the application.exe folder and the loadlibrary function works ok, but no change with loadapp.
try loadapp with full path to your application. it should load drx.
application is in d:\dwgdirect 2.03.01\exe\vc8\debug
i've tried:-
code:
odrxmoduleptr pmodule = odrxdynamiclinker()->loadapp(dd_t("d:\\dwgdirect 2.03.01\\exe\\vc8\\debug\\modelergeometry"));and
code:
odrxmoduleptr pmodule = odrxdynamiclinker()->loadapp(dd_t("d:\\dwgdirect 2.03.01\\exe\\vc8\\debug\\modelergeometry.drx"));and they both return null.
i'm getting rather confused, now. i've built this dll based around the odreadex example, but i've just realised there is also an odreadexdll example. this example uses library files such as dd_db_dll.lib etc., whereas i am using dd_vc8md_db.lib etc. (however, this example is still generating a .exe - i am generating a .dll)
should i be using these .lib files? i've tried replacing all my .lib files with the equivalent ones, but i get lots of unresolved externals, which isn't encouraging.
hi,
you should use name like in the mfcapp = rx_modeler_geometry_appname dd_t("modelergeometry")
index and .drx will be add inside loadapp. you shouldn't rename modelergeometry_2.03_8.drx to modelergeometry.drx.
i see only two reasons why it cannot be loaded:
- folder isn't application exe.
- missed linked dll in exe folder.
you said that loadlibrary was loaded for release after all dlls were moved to application.exe folder. i think that it will be loaded too for debug, after debug dlls moving. it is very strange that loadlibrary is succeed, but loadapp - not. loadapp just add .drx index and '2.3_8' to file name and call for loadlibrary.