EXTERNALEXCEPTION in simple dll call
-
- Posts: 149
- Joined: Fri Oct 21, 2005 8:42 am
- Location: UK
EXTERNALEXCEPTION in simple dll call
I am having trouble getting IA to call a simple DLL.
The DLL has a single entry point
fnTest
and takes 2 arguments
TESTDLL_API long fnTest(TCHAR* text, long random)
It returns the second input argument.
If I call this from IA using the command
~InstallAware Clipboard Data~
~Call DLL Function~
~{A50FBE6A-1E02-46E4-8676-0A378DD824CE}~
~testdll.dll,fnTest,long,OUTPUTNUMBER,"pointer to string",$INPUTSTRING$,long,$INPUTNUMBER$,$~
~~mIDEFunc.dll\\mEXEFunc.dll~~
~Set Variable~
~{42B6993E-CFD8-4548-8FA5-D90E995FD2EE}~
~INPUTSTRING~
~Hello World~
~Set Variable~
~{A993EAAD-251C-4F54-98CB-65A6F3F2D4C9}~
~OUTPUTNUMBER~
~0000~
~Set Variable~
~{15FAC04D-90D8-4666-8F4F-909491B43ABB}~
~INPUTNUMBER~
~1234~
The output number just gets set to EXTERNALEXCEPTION
Any Ideas?
I have attached the DLL source.
File Attached:
testdll.rar
The DLL has a single entry point
fnTest
and takes 2 arguments
TESTDLL_API long fnTest(TCHAR* text, long random)
It returns the second input argument.
If I call this from IA using the command
~InstallAware Clipboard Data~
~Call DLL Function~
~{A50FBE6A-1E02-46E4-8676-0A378DD824CE}~
~testdll.dll,fnTest,long,OUTPUTNUMBER,"pointer to string",$INPUTSTRING$,long,$INPUTNUMBER$,$~
~~mIDEFunc.dll\\mEXEFunc.dll~~
~Set Variable~
~{42B6993E-CFD8-4548-8FA5-D90E995FD2EE}~
~INPUTSTRING~
~Hello World~
~Set Variable~
~{A993EAAD-251C-4F54-98CB-65A6F3F2D4C9}~
~OUTPUTNUMBER~
~0000~
~Set Variable~
~{15FAC04D-90D8-4666-8F4F-909491B43ABB}~
~INPUTNUMBER~
~1234~
The output number just gets set to EXTERNALEXCEPTION
Any Ideas?
I have attached the DLL source.
File Attached:
testdll.rar
-
- Posts: 3452
- Joined: Thu Dec 22, 2005 7:17 pm
- Contact:
As described in the help file for the Call DLL Function plug-in, it would seem the exception handler InstallAware is using to protect the DLL call is catching an exception that occurs in your DLL. I am sorry but I am not well versed in C/C++ so I cannot help you with the DLL in particular. It could be any number of things including DLL code, DLL dependencies, and so on.
Michael Nesmith
InstallAware
Home of The Next Generation MSI Installer
Get your free copy today - http://www.installaware.com/
InstallAware
Home of The Next Generation MSI Installer
Get your free copy today - http://www.installaware.com/
-
- Posts: 149
- Joined: Fri Oct 21, 2005 8:42 am
- Location: UK
DLL works fine when called from other applications.
This one does absolutely nothing, just returning the input value, so there should be now issues there.
I have had a go at debugging the DLL, the values comming into it are correct, and the return value is ok as it is about to leave the DLL.
There is definately an issue somewhere between the DLL return value and what IA is getting, but it is not something I can debug.
Please Help
This one does absolutely nothing, just returning the input value, so there should be now issues there.
I have had a go at debugging the DLL, the values comming into it are correct, and the return value is ok as it is about to leave the DLL.
There is definately an issue somewhere between the DLL return value and what IA is getting, but it is not something I can debug.
Please Help

-
- Posts: 3452
- Joined: Thu Dec 22, 2005 7:17 pm
- Contact:
I really wish I could do more - unfortunately my own knowledge of this issue is limited so I am unable to help. I am hoping some of our MVPs will look into this for you...
Michael Nesmith
InstallAware
Home of The Next Generation MSI Installer
Get your free copy today - http://www.installaware.com/
InstallAware
Home of The Next Generation MSI Installer
Get your free copy today - http://www.installaware.com/
hi,
I have looked at this code sample and tested with 5.0, not the latest. I believe this is what we in the industry call an issue with InstallAWARE.
The dll can't return a value.
To work around this another way you can just return the function value as a parameter. For example:
TESTDLL_API void fnTest(TCHAR* text, long *numb)
{
MessageBox(0, text, "DEBUG", MB_OK);
*numb = 5;
return;
}
Then in InstallAWARE you can define the second param as "pointer to long".
Do i get to be MVP yet? What is that good for? Free updates? Tea with Sinan?
I have looked at this code sample and tested with 5.0, not the latest. I believe this is what we in the industry call an issue with InstallAWARE.
The dll can't return a value.
To work around this another way you can just return the function value as a parameter. For example:
TESTDLL_API void fnTest(TCHAR* text, long *numb)
{
MessageBox(0, text, "DEBUG", MB_OK);
*numb = 5;
return;
}
Then in InstallAWARE you can define the second param as "pointer to long".
Do i get to be MVP yet? What is that good for? Free updates? Tea with Sinan?
-
- Posts: 149
- Joined: Fri Oct 21, 2005 8:42 am
- Location: UK
-
- Posts: 904
- Joined: Thu Dec 22, 2005 7:03 pm
- Contact:
Hi!
As far as we know, there are no issues with return values in DLLs. However if you are having problems with return values, it may seem that parameter passing and calling conventions might be wrongly declared - just a guess. WinAPI calls all use return values and these work correctly with Call DLL Function.
Steve, Sinan thanks you very much for helping out Gareth here, and wants me to tell you you are well on your way to being initiated into the mysterious circle of InstallAware MVPs with its secret benefits
As far as we know, there are no issues with return values in DLLs. However if you are having problems with return values, it may seem that parameter passing and calling conventions might be wrongly declared - just a guess. WinAPI calls all use return values and these work correctly with Call DLL Function.
Steve, Sinan thanks you very much for helping out Gareth here, and wants me to tell you you are well on your way to being initiated into the mysterious circle of InstallAware MVPs with its secret benefits

Candice Jones
InstallAware
Home of The Next Generation MSI Installer
Get your free copy today - http://www.installaware.com/
InstallAware
Home of The Next Generation MSI Installer
Get your free copy today - http://www.installaware.com/
-
- Posts: 149
- Joined: Fri Oct 21, 2005 8:42 am
- Location: UK
Is it possible for someone to send a working version of the DLL source code and the IA script?
I have managed to work arround the issue using the method suggested by stevew, but I would be very interested to see exactly what calling convention should be used to get the return value working.
It might be required in the future
I have managed to work arround the issue using the method suggested by stevew, but I would be very interested to see exactly what calling convention should be used to get the return value working.

It might be required in the future
-
- Posts: 904
- Joined: Thu Dec 22, 2005 7:03 pm
- Contact:
Yes, please email them to Michael, we'll see what we can dig up here for you.
Candice Jones
InstallAware
Home of The Next Generation MSI Installer
Get your free copy today - http://www.installaware.com/
InstallAware
Home of The Next Generation MSI Installer
Get your free copy today - http://www.installaware.com/
also, regarding my mention of an issue. i suspect that the most probable problem is just a missing line in the help file ... not an actual software change.
I did my test compiling __cdecl. If there is not problem calling normal win32 API then likely this is because normal win32 API are compiled as __stdcall. Compiling any custom dll as __stdcall should allow the function to return from the DLL.
Just a guess. I did notice that Gareth's sample was written in something like version 2003. I am not as fluent in this version, only 6.0. I am not sure where this setting is in version 2003.
I did my test compiling __cdecl. If there is not problem calling normal win32 API then likely this is because normal win32 API are compiled as __stdcall. Compiling any custom dll as __stdcall should allow the function to return from the DLL.
Just a guess. I did notice that Gareth's sample was written in something like version 2003. I am not as fluent in this version, only 6.0. I am not sure where this setting is in version 2003.
-
- Posts: 904
- Joined: Thu Dec 22, 2005 7:03 pm
- Contact:
Exactly. The calling conventions need to be stdcall. I reviewed the help file entry for this command and this is the first line:
Call DLL Function
This plug-in provided command calls a function exported from a DLL. The function must be available under the specified function name and use the __stdcall calling convention.
Call DLL Function
This plug-in provided command calls a function exported from a DLL. The function must be available under the specified function name and use the __stdcall calling convention.
Candice Jones
InstallAware
Home of The Next Generation MSI Installer
Get your free copy today - http://www.installaware.com/
InstallAware
Home of The Next Generation MSI Installer
Get your free copy today - http://www.installaware.com/
-
- Posts: 149
- Joined: Fri Oct 21, 2005 8:42 am
- Location: UK
Never mind, I figured it out.
For the benefit of others here's how I did it using Microsoft Visual Studio 2005.
Header file - declare the function--------
extern "C" {bool __stdcall MyFunc(TCHAR* inputString);}
Source file - implementation--------
bool __stdcall MyFunc(TCHAR* inputString)
{
... do something
return true;
}
Defintion file - input this by specifying it in the linker input settings for the project--------
EXPORTS
MyFunc=_MyFunc<input>
For the benefit of others here's how I did it using Microsoft Visual Studio 2005.
Header file - declare the function--------
extern "C" {bool __stdcall MyFunc(TCHAR* inputString);}
Source file - implementation--------
bool __stdcall MyFunc(TCHAR* inputString)
{
... do something
return true;
}
Defintion file - input this by specifying it in the linker input settings for the project--------
EXPORTS
MyFunc=_MyFunc<input>
Who is online
Users browsing this forum: No registered users and 149 guests