Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DLL Talk / DBP plugin crashes on program start

Author
Message
Diggsey
18
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 6th May 2007 19:16
This is my first DBP plugin that actually accesses internal DBPro stuff, but whenever I use one of the commands, it crashes.

Here is the main code:


It compiles with 0 errors, and 0 warnings in VS

Attached is the compiled dll.

Compiling code with one of the functions in the dll works, but as soon as the executable runs, I get a crash.

Attachments

Login to view attachments
TKF15H
20
Years of Service
User Offline
Joined: 20th Jul 2003
Location: Rio de Janeiro
Posted: 6th May 2007 20:08
Put the DBP EXE in the same folder as MSVC's build target for the DLL, then use the debugger. It should tell you exactly where something's going wrong.

IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 7th May 2007 03:47 Edited at: 7th May 2007 03:49
The problem is this:

#define EXPORT extern "C" __declspec(dllexport)

Combined with this:

EXPORT void ReceiveCoreDataPtr ( LPVOID Core_ )

You can't use 'extern "C"' when exporting this function because it changes the exported name of the function to something that DBPro isn't looking for.

Also, you can't populate your function pointers GetDBObject & GetDBImage like that because the Core pointer isn't set when that code gets run. Keep the function pointer variables where they are, and move the GetProcAddress bit into the ReceiveCoreDataPtr function.

[EDIT]... and how in the heck does this line compile?

for each (LockedImage* i in ImgArr)

It's not valid C++.

Diggsey
18
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 7th May 2007 12:03
Quote: "he problem is this:

#define EXPORT extern "C" __declspec(dllexport)

Combined with this:

EXPORT void ReceiveCoreDataPtr ( LPVOID Core_ )"

Thanks I will try that.

Quote: "and how in the heck does this line compile?

for each (LockedImage* i in ImgArr)

It's not valid C++."

Ummm... it is
Look here

Anyway, thanks again for the help

John Y
Synergy Editor Developer
21
Years of Service
User Offline
Joined: 4th Sep 2002
Location: UK
Posted: 7th May 2007 12:58
The for each loop is a managed (.Net) addition, hence requiring the /CLR compiler flag.

The dll will therefore be incompatible with the DBP compiler.

Get the new DarkBasic Professional IDE for only $19.99/~£9.85
Http://synergyide.thegamecreators.com
Http://www.digitalzenith.net
Diggsey
18
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 7th May 2007 13:33
@John Y
Umm... my dll is working at the moment

Benjamin
21
Years of Service
User Offline
Joined: 24th Nov 2002
Location: France
Posted: 7th May 2007 13:35
If it is apparently 'working', then why is it crashing?

Tempest (DBP/DBCe)
Multisync V1 (DBP/DBCe)
Diggsey
18
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 7th May 2007 13:38
I did what IanM said, and it is now working

Diggsey
18
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 7th May 2007 23:58
The plugin is here if anyone wnats it

IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 8th May 2007 10:04
Oh, using managed extensions in VC++ is perfectly OK and will produce a usable DLL ... but it does mean that anyone who uses this DLL will need the right .NET runtime installed, whichever one that you used

... and all to save you a few characters of typing that instead of this:


As a rule of thumb, try to remove dependencies that are outside your control when you release DLL's.

Login to post a reply

Server time is: 2024-05-20 17:36:20
Your offset time is: 2024-05-20 17:36:20