I have created a .NET dll to be used in Installscript. It basically installs certificates, removes certificates and checks if a certificate already exists. This is my Exists method:
[ComVisible(true)]
public bool Exists(string thumbPrint)
{
try
{
...
//Check if the certificate exists on the store.
var certCollection = store.Certificates.Find(X509FindType.FindByThumbprint, thumbPrint, false);
return (certCollection.Count > 0);
}
catch (Exception exception)
{
...
}
}
This is the installscript code
szDLLPath = SUPPORTDIR ^ "X509Framework.dll";
szClassName = "X509Framework.X509StoreProcessor";
DotNetUnloadAppDomain("X509FrameworkDomain");
try
set oX509Store = DotNetCoCreateObject(szDLLPath, szClassName, "X509FrameworkDomain");
catch
SprintfBox (INFORMATION, "Error","Error occured: %i\n\n%s\n\n%s", Err.Number, Err.Description, Err.LastDllError);
abort;
endcatch;
try
nReturn = oX509Store.Exists(FinArchCodeSigningSha);
catch
SprintfBox (INFORMATION, "Error","Error occured: %i\n\n%s\n\n%s", Err.Number, Err.Description, Err.LastDllError);
abort;
endcatch;
In this example nReturn
is always -1
when I debug it in Installscript, whether the certificate exists or not. (of course from a .NET program it works fine)
Then I tried to use an int
as return value and this worked. So there is a workaround.
But I was wondering if anyone knows why I cannot use bool
as return value for a .NET dll that is used in Installscript.
In the end it turned out to be quite simple. Installshield cannot interpret the Boolean field from .NET. Had to use an int instead.
The .NET program had to return an int
value:
1
for TRUE
and 0
for FALSE
(pretty standard I know)
Then I set the return value into a BOOL
variable in Installshield.