cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
ChristopheOce
Level 7

call a function in dll dotnet !!!!

Hi,

I have a basic msi project made with installshield 2008 who installs some dll dotnet, xml file and others.

I have a library CheckUserLogon who have a method CheckUser who take 3 string parameters.
this dll is in the package.

Now when i call this method in installscript with this code :


begin

cchbValueBuffer = 512;
nResult = MsiGetProperty(hMSI, "SOURCEDIR", szPathSupport, cchValueBuf);


szPathCompletDll = szPathSupport+"program files\\****\\****\\CheckUserLogon.dll";
MessageBox("Path complet :" + szPathCompletDll, INFORMATION );

nResult=UseDLL(szPathCompletDll);

if (nResult = 0) then
MessageBox ("UseDLL successful \n\n.DLL file loaded.", INFORMATION);
else
MessageBox ("UseDLL :"+ szPathCompletDll +" failed.\n\nCouldn't load .DLL file.", INFORMATION);
abort;
endif;

//Gets the domain
cchValueBuf = 512;
nResult = MsiGetProperty(hMSI, "WINDOMAINNAME", szWinDomain, cchValueBuf);

//Gets the user
cchValueBuf = 512;
nResult = MsiGetProperty(hMSI, "WINUSERNAME", szWinUser, cchValueBuf);

//Gets the password
cchValueBuf = 512;
nResult = MsiGetProperty(hMSI, "WINUSERPASSWORD", szWinPass, cchValueBuf);

//Test all properties
MessageBox("Domain name :"+ szWinDomain + " User name : " + szWinUser+ " Password : " +szWinPass, INFORMATION);

//Call the dll
szRet = CheckUserLogon.CheckUser(szWinDomain, szWinUser, szWinPass);
MessageBox(szRet, INFORMATION);


the installer fails without no message !!! i call this dll in a dialog when a user click next !if a click next i go to the end of the installation !!!!!!

Someone can tell me how i can call a method made in net in installscript !?

Thanks for all
Christophe
Labels (1)
0 Kudos
(4) Replies
RobertDickau
Flexera Alumni

If you haven't yet, perhaps see if CoCreateObjectDotNet or DotNetCoCreateObject will help; UseDLL is for C-callable DLL functions...
0 Kudos
ChristopheOce
Level 7

Yo Robert,

That"'s works really fine and i've use the function :
DotNetCoCreateObject


set objectUserLogon = DotNetCoCreateObject( szPathCompletDll, "CheckUserLogon.CheckUserLogon", "");

try
szRet = objectUserLogon.CheckUser( szWinDomain, szWinUser, szWinPass );
//MessageBox(szRet, INFORMATION);

if (szRet = "OK") then
....


Ouf ..i'm happy one problem less 🙂

thanks for your reply and have a nice week end
Christophe
0 Kudos
ChristopheOce
Level 7

It's enough me !
I'm not on week end ..:-) !

that's work as i said but if i try to install my package on a share network with the path for example \\mycomputer\myshare ... the package can't load the dll !

i can solve the problem by copy the complete package in the computer and run again ! but how i can use the function DotNetCoCreateObject with a network path or there is a other solution !

thanks for all
Christophe
0 Kudos
ChristopheOce
Level 7

We have found why we can load the dll with a network drive !

the problem comes if you try to execute some net code in a network path \\...

the problem is the security permission of the net framework doesn't ALLOW this operation !

Have a nice day
Christophe
0 Kudos