This website uses cookies. By clicking Accept, you consent to the use of cookies. Click Here to learn more about how we use cookies.
Turn on suggestions
Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
- Revenera Community
- :
- InstallShield
- :
- InstallShield Forum
- :
- How to make DotNetCoCreateObject work
Subscribe
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Feb 19, 2008
03:39 PM
DotNetCoCreateObject issues
All,
I am trying to call my .NET dll from InstallScript. For instance, I am doing the following :
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
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
(4) Replies
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Feb 20, 2008
03:08 AM
You should add "UseDLL(dllPath);" before your "try" statement,
And "UnUseDLL(dllPath);" after "endcatch;".
And "UnUseDLL(dllPath);" after "endcatch;".
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎May 06, 2008
04:32 PM
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
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
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Jul 31, 2008
04:55 PM
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.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Dec 13, 2010
11:43 AM
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 ???
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 ???
![](/skins/images/D60DF682EA37BF37032955CE10F3F0BB/responsive_peak/images/icon_anonymous_message.png)