- Revenera Community
- :
- InstallShield
- :
- InstallShield Forum
- :
- Re: freeing up CoCreateObjectDotNet or removing reference
- 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
Hi,
I am calling a .Net function inside a dll that is unpacked into the SUPPORTDIR folder.
I noticed that if CoCreateObjectDotNet() is called, that dll would not be deleted from SUPPORTDIR after installation ends.
Then, if I purposely don't call CoCreateObjectDotNet(), that dll is automatically deleted FROM SUPPORTDIR after installation. Which leads me to suspect that I might not be freeing up the object correctly. Here is my code below.
The documentation also mentions to use CoFreeLibrary(), however, I cannot use it as it's causing Build errors.
set oLib=CoCreateObjectDotNet(szDLLpath,"DllName.ClassName"); ret = oLib.MyMethod(param); set oLib= NOTHING; // this is not enough apparently.
Looking forward to an answer for this issue.
Thank you!
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
Hi @remondo ,
I could see "CoCreateObjectDotNet" function is deprecated in IS2014 onwards,how about using "DotNetCoCreateObject"?
What are the build error you get on using CoFreeLibrary()?
Thanks,
Jenifer
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
Hi @remondo ,
I could see "CoCreateObjectDotNet" function is deprecated in IS2014 onwards,how about using "DotNetCoCreateObject"?
What are the build error you get on using CoFreeLibrary()?
Thanks,
Jenifer
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
Thank you for your reply Jennifer! You have pointed me to the right direction.
I am using Installshield 2016.
1. Regarding CoFreeLibrary(), it's my mistake, I forgot to declare the prototype
prototype void ole32.CoFreeLibrary( byval int );
In order to call CoFreeLibrary(), I need to get the handle to the dll.
So I needed to call GetModuleHandle() first to get the handle. It didn't work.
2. I also tried the UseDLL() and UnUseDLL();
Didn't work.
Caveat: UnUseDLL()'s parameter according to the documentation should not include the path.
UseDLL() needs the path though.
3. DotNetCoCreateObject()
So I had to specify a temporary app domain name, then call DotNetUnloadAppDomain() afterwards.
This worked!
set oLib=DotNetCoCreateObject(szDLLpath,"MyDLLName.MyClassName", "tempdomain"); retDotNet = oLib.MyCSharpMethod(); retDotNet = DotNetUnloadAppDomain("tempdomain"); // returns 0