PDA

View Full Version : Problem with luaCOM.Connect


Lizard
09-05-2006, 04:42 PM
I have a project which uses the luaCOM plugin to call a DLL (written in VB6) which updates a database by running a series of scripts. The DLL raises events whenever a script starts or stops. The following snippet shows what I'm doing:

DatabaseManager_events = {}
function DatabaseManager_events:OnScriptStart(Name)
SetupData.WriteToLogFile("Notice\tScript started: "..Name.."\r\n");
end
function DatabaseManager_events:OnScriptStop(Abort)
SetupData.WriteToLogFile("Notice\tScript stopped\r\n");
end
function UpdateDatabase(Action)
DatabaseManager = luacom.CreateObject("DBUpdate.DatabaseManager");
assert(DatabaseManager);
res, cookie = luacom.Connect(DatabaseManager, DatabaseManager_events);
DatabaseManager:UpdateDatabase();
DatabaseManager = nil;
collectgarbage();
end

The code executes fine, and the log has my lines showing the names of each script. The problem is that after the setup runs, I get a Windows popup saying "Setup Application has encountered an error and needs to close". If I comment out the luacom.Connect line, it works fine (but doesn't log the scripts, of course).

Anyone know what I'm doing wrong?

Lizard
09-10-2006, 03:55 PM
No one has an idea?

pww
09-12-2006, 05:17 PM
The problem may be in the dll, not in the SF generated setup
To check try with a dummy dll that makes nothing

Lizard
09-19-2006, 12:35 PM
Thanks for the suggestion. If I comment out the line that calls the DLL, so that the code looks like this:

DatabaseManager_events = {}
function DatabaseManager_events:OnScriptStart(Name)
SetupData.WriteToLogFile("Notice\tScript started: "..Name.."\r\n");
end
function DatabaseManager_events:OnScriptStop(Abort)
SetupData.WriteToLogFile("Notice\tScript stopped\r\n");
end
function UpdateDatabase(Action)
DatabaseManager = luacom.CreateObject("DBUpdate.DatabaseManager");
assert(DatabaseManager);
res, cookie = luacom.Connect(DatabaseManager, DatabaseManager_events);
--DatabaseManager:UpdateDatabase();
DatabaseManager = nil;
collectgarbage();
end

The same thing happens - I get the Windows application error.

pww
09-19-2006, 03:29 PM
I would put a message box after each operation to see where is the problem.

Other things that come to mind
- load & use the .dll from a vb6 exe to see if it will cause a crash when performing the same operations - this way debugging will be a lot easier, in case the problem is in the dll

- as I understand , you use this dll to write data to a DB. If this is a one-way process (setup only writes to but does not need to read from DB), try to simplify things and remove the dll at all. Make it exe which writes to DB parameters passed via command line. Or write events to a text file during setup and at the end call an exe that puts all of them together in the DB.

Lizard
09-20-2006, 12:14 PM
Thanks for the reply, pww. I have already put in debugging after every line, and have even commented out almost every line. For example, the following still gets the Windows system error:

DatabaseManager_events = {}
function DatabaseManager_events:OnScriptStart(Name)
--SetupData.WriteToLogFile("Notice\tScript started: "..Name.."\r\n");
end
--function DatabaseManager_events:OnScriptStop(Abort)
--SetupData.WriteToLogFile("Notice\tScript stopped\r\n");
--end
function UpdateDatabase(Action)
DatabaseManager = luacom.CreateObject("DBUpdate.DatabaseManager");
--assert(DatabaseManager);
res, cookie = luacom.Connect(DatabaseManager, DatabaseManager_events);
--DatabaseManager:UpdateDatabase();
--DatabaseManager = nil;
--collectgarbage();
end

I suspect there is a bug in the luaCOM plugin in the implementation of the event sink. I am investigating replacing the DLL COM call with an executable (as you suggest) to avoid the issue. I've reported the same problem on the Icy North forum, but no luck yet there either.