cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
zaknixon
Level 2

DotNetCoCreateObject issues

All,

I am trying to call my .NET dll from InstallScript. For instance, I am doing the following :


prototype void callLogger();


function void callLogger()
string simpleMessage,dllPath,className;
object myDLLObj;


begin
dllPath = SUPPORTDIR ^ "MyCompany.Logging.dll";

MessageBox("Path to DLL: " + dllPath,INFORMATION);
className = "Com.Logging.Log";

try
set myDLLObj = DotNetCoCreateObject(dllPath,className,"");
catch

MessageBox(Err.Number , SEVERE);
//MessageBox("It finally worked....",INFORMATION);
endcatch;
// myDLLObj.log();
end;


I call this method from the OnBegin() callback method from InstallShield.

I run the installer, look at the support directory and my DLL is there. The dllPath is correct, but when the DotNetCoCreateObject is called I get an error code : -2147219705 . Does anyone know what the issue could be?

My dll has its assembly info set as ComVisible(true) as well.

Any help would be great.

Zak
Labels (1)
0 Kudos
(4) Replies
Max_wong
Level 2

You should add "UseDLL(dllPath);" before your "try" statement,

And "UnUseDLL(dllPath);" after "endcatch;".
0 Kudos
nlamka
Level 3

I have the same issue. My sample/test code is very simple

nResult = UseDLL(SUPPORTDIR^"TastingMasterGacUtil.dll");
if (0 = nResult)
then
try
set GacUtil = DotNetCoCreateObject( SUPPORTDIR^"TastingMasterGacUtil.dll", "TastingMasterGacUtil.GacUtil", "");
GacUtil.Add("Test");
catch
MessageBox(Err.Number, SEVERE);
GacUtil = NULL;
endcatch;
UnUseDLL( SUPPORTDIR^"TastingMasterGacUtil.dll");
endif;

What I get is the same -2147219705 error code on return.

Anyone know how this really works?

Neil
0 Kudos
jharveyjr
Level 3

nlamka wrote:
I have the same issue. My sample/test code is very simple

nResult = UseDLL(SUPPORTDIR^"TastingMasterGacUtil.dll");
if (0 = nResult)
then
try
set GacUtil = DotNetCoCreateObject( SUPPORTDIR^"TastingMasterGacUtil.dll", "TastingMasterGacUtil.GacUtil", "");
GacUtil.Add("Test");
catch
MessageBox(Err.Number, SEVERE);
GacUtil = NULL;
endcatch;
UnUseDLL( SUPPORTDIR^"TastingMasterGacUtil.dll");
endif;

What I get is the same -2147219705 error code on return.

Anyone know how this really works?

Neil


Try using variables in the call to DotNetCoCreateObject. I had string constants in there (like "junk.dll") and was getting a vague error. I changed to just using variables like the top example in this thread and it worked.

Also, for IS 2008 (maybe 12 too) you don't need UseDLL. As for the issue on top, I don't know. I would just verify your names. My DLL name only has a single "." in it, not two. Maybe try and rename your DLL and see if that helps.
0 Kudos
manomatt
Level 8

My sample code looks like this and it worked:

begin
//Get the path to the MSI SUPPORTDIR
MsiGetProperty(hMSI, "SUPPORTDIR", szMSISUPPORTDIR, nResult);
szPathCompletDll = szMSISUPPORTDIR ^ "SampleShowDll.dll";

// Load the .dll file into memory.
set GacObject = DotNetCoCreateObject( szPathCompletDll, "SampleShowDll.Class1", "");

try
GacObject.showMessage();
catch
SprintfBox (INFORMATION, "Error","Error occured: %i\n\n%s\n\n%s",
Err.Number, Err.Description, Err.LastDllError);
endcatch;

end;

what is the version of IS that u are using ???
0 Kudos