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
- :
- Unknown Name error when accessing .NET dll
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
‎Nov 09, 2007
04:04 PM
Unknown Name error when accessing .NET dll
Hello, Macrovision Community! I need your help on a very frustrating issue.
I need to call a DLL to validate a license key during my installation. I'm writing a TEST installscript to prove the concept.
I am able to load the dll successfully with DotNetCoCreateObject but am receiving an 'Unknown Name' error with an error number of -2147352570 when attempting to access a public function.
My support files make it into the specified directory successfully. I've also written a C# test project to call the dll and pass a key and it works just fine.
Code snippets below:
Visual Studio AssemblyInfo.cs file:
[CODE]using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
//
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
//
[assembly: AssemblyTitle("")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("")]
[assembly: AssemblyCopyright("")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: ComVisible(true)]
ETC...[/CODE]
Visual Studio Validation.cs file:
Installscript Code:
Thank you for your help!
Len
I need to call a DLL to validate a license key during my installation. I'm writing a TEST installscript to prove the concept.
I am able to load the dll successfully with DotNetCoCreateObject but am receiving an 'Unknown Name' error with an error number of -2147352570 when attempting to access a public function.
My support files make it into the specified directory successfully. I've also written a C# test project to call the dll and pass a key and it works just fine.
Code snippets below:
Visual Studio AssemblyInfo.cs file:
[CODE]using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
//
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
//
[assembly: AssemblyTitle("")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("")]
[assembly: AssemblyCopyright("")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: ComVisible(true)]
ETC...[/CODE]
Visual Studio Validation.cs file:
using System;
using System.Collections;
using System.Text.RegularExpressions;
using ServerIdentifier;
namespace ServerValidation
{
///
/// Summary description for Validation.
///
public class Validation
{
//
// Member variables and constants
private static bool m_blnUseMachineIdentifier = true;
#region Public Interface
public static bool ValidateKey(string strKey)
{
if(ValidateMachineKey(strKey))
{
return true;
}
else
{
if(ValidateTimeKey(strKey))
{
return true;
}
else
{
return false;
}
}
}
ETC...
Installscript Code:
#define DLL_NAME "ServerValidation.dll"
// Include Ifx.h for built-in InstallScript function prototypes.
#include "Ifx.h"
// Prototype MydllReturn in Mydll.dll.
//prototype BOOL ServerValidation.ValidateKey (BYVAL STRING);
//prototype BOOL ServerValidation.VerifyLoading ();
export prototype ExFn_UseDLL(HWND);
function ExFn_UseDLL(hMSI)
STRING svString;
INT nValue;
POINTER psvString;
NUMBER nResult;
BOOL bValidKey;
STRING szMSISUPPORTDIR;
STRING szPathCompletDll;
NUMBER nTemp;
OBJECT objValidateKey;
begin
//Get the path to the MSI SUPPORTDIR
MsiGetProperty(hMSI, "SUPPORTDIR", szMSISUPPORTDIR, nResult);
szPathCompletDll = szMSISUPPORTDIR ^ DLL_NAME;
// Load the .dll file into memory.
set objValidateKey = DotNetCoCreateObject( szPathCompletDll, "ServerValidation.Validation", "");
// bValidKey controls the following while loop.
bValidKey = FALSE;
// Loop while bValidKey is FALSE.
while (bValidKey = FALSE)
try
// Call ValidateKey .
bValidKey = objValidateKey.ValidateKey("0000-1111-2222-3333");
catch
/* Exception handler. */
//nTemp = Err.Number;
//svString = Err.Description;
/* Handle the exception based on its cause. */
SprintfBox (INFORMATION, "Error","Error occured: %i\n\n%s\n\n%s",
Err.Number, Err.Description, Err.LastDllError);
abort;
endcatch;
// Display the string to observe how it was altered by MydllReturn.
if (bValidKey) then
MessageBox ("Valid Key", INFORMATION);
else
MessageBox ("Invalid Key", INFORMATION);
endif;
endwhile;
end;
Thank you for your help!
Len
(4) Replies
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Nov 10, 2007
09:09 AM
One quick thing to test: in your InstallScript, does szPathCompletDll have the correct value? Your MsiGetProperty call to get SUPPORTDIR might fail if you haven't set the buffer-size variable nResult to a large enough value (say, MAX_PATH+1) before calling MsiGetProperty...
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Nov 12, 2007
07:42 AM
RobertDickau wrote:
One quick thing to test: in your InstallScript, does szPathCompletDll have the correct value? Your MsiGetProperty call to get SUPPORTDIR might fail if you haven't set the buffer-size variable nResult to a large enough value (say, MAX_PATH+1) before calling MsiGetProperty...
Robert,
I believe I have the correct value. I added a SprintfBox statement to check. szPathCompletDll is correct. I can leave the installer open and verify the DLL's presence in the temp folder.
I also placed the DLL in a static location and directed the installer to use that. Same problem.
Code snippet of my SprintfBox statement:
//Get the path to the MSI SUPPORTDIR
MsiGetProperty(hMSI, "SUPPORTDIR", szMSISUPPORTDIR, nResult);
SprintfBox(INFORMATION, "nResult", "%s\n\n%s\n\n%d\n\n%d", szMSISUPPORTDIR ^ DLL_NAME, szMSISUPPORTDIR, nResult, StrLength(szMSISUPPORTDIR));
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Nov 12, 2007
12:29 PM
Might it help to remove static from public static bool ValidateKey(string strKey)? It strikes me as odd that one would try to call a static method from an object instance, COM or otherwise.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Nov 12, 2007
01:14 PM
MichaelU wrote:
Might it help to remove static from public static bool ValidateKey(string strKey)? It strikes me as odd that one would try to call a static method from an object instance, COM or otherwise.
Right on, Michael! I thought about it after your post and I realized that the class methods would not be available to my instantiation of the class into my object in the installer.
I added a non-static method to the class and called the validation method from there. Works like a charm!
Quite a 'duh' moment.
Thank you again!
Len
😄 😄