Click to See Complete Forum and Search --> : [RESOLVED] VB6 DLL "Unable to find an entry point named" Error
dspinner
Jan 19th, 2011, 03:08 PM
I'm having trouble getting a VB6 dll working in C#. I believe that I have everything setup in the C# program correctly because it doesn't complain until I try to call a function from my VB6 ActiveX dll. When it tries to call the function, I get the following error:
Unable to find an entry point named 'startImport' in DLL 'ImportActiveX.dll'
I tried a bunch of things and nothing has worked so far. I believe that there is something wrong with my dll because I checked it with Dependency Walker and none of the functions show up. Here is the code from the class interface:
Option Explicit
Public Event Finished(message As String)
Public Function startImport(inSiteName As String, inDriver As String, inServer As String, inUserID As String, inPassword As String, inDatabase As String) As String
'Declarations
'Valid input checks
'Call private functions if input is good
RaiseEvent Finished(g_sImportError)
startImport = g_sImportError
End Function
g_sImportError is declared in a module.
I'm probably missing something obvious or basic so please don't leave those out. If any more information is needed, I'll be glad to provide it. Thanks in advance for any help provided.
honeybee
Jan 20th, 2011, 02:09 AM
The error seems to indicate that the dll is not a COM dll. Or it does not have a public function named startImport??
.
dspinner
Jan 20th, 2011, 09:01 AM
It works just fine with my VB6 testbed program but that doesn't mean it will work in C#.
The public function is there but I may not have it setup properly as a COM dll. This is probably a dumb question but I'm fairly new to VB6 (not by choice, long story) and I have to ask: How do I make sure that it is configured to be a COM dll? I'll do some research on my own in the mean time and post if I make any progress.
techgnome
Jan 20th, 2011, 09:07 AM
OK... so the code above is in your VB6 COM dll? Right? The problem may be your C# code... what does that look like?
-tg
dspinner
Jan 20th, 2011, 09:48 AM
Here is the C# class implementing it:
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
using ImportActiveX;
namespace Analyst
{
class ImportTool
{
[DllImport("ImportActiveX.dll")]
public static extern string startImport(string inSiteName, string inDriver, string inServer, string inUserID, string inPassword, string inDatabase);
public string beginImport(string inSiteName, string inDriver, string inServer, string inUserID, string inPassword, string inDBName)
{
string retString;
retString = startImport(inSiteName, inDriver, inServer, inUserID, inPassword, inDBName);
return retString;
}
}
}
And here is the class declaration:
ImportTool myImporter = new ImportTool();
importerStatus = myImporter.beginImport("Test Site", "{SQL Database}", "localtest", "Test", "Test", "TestDB");
The code could use some cleaning up. I'm also not too familiar with C# so I may have missed something. I added the reference to the dll to the project and the dll is registered. Everything seems to work fine until I get to the retString = startImport() line. That's when I get the aforementioned error. I don't have a using Analyst; declaration in the project setting up the ImportTool object. Could that have something to do with it?
techgnome
Jan 20th, 2011, 09:55 AM
Right... that's what I suspected. the DLLImport tag is for using standard c-style unmanaged DLLs... what you're trying to access is an unmanaged ActiveX DLL ... create the reference... which should add some kind of interop wrapper around it (it'll end up looking something like "AxMyActiveXControl" or something like that, either way, it'll be preceded with "ax" ... then it's just creating an instance of the class and using it like you would any other object.
-tg
dspinner
Jan 21st, 2011, 04:12 PM
I get a file called Interop.ImportActiveX.dll after I add the reference. I'm using Visual Studio 2010. Is that the same thing? I will give that a try and will post if it works.
EDIT: That took care of it. It works just fine now. Thanks again for your help!
techgnome
Jan 21st, 2011, 04:16 PM
yes... NET adds an interop wrapper that acts as a gateway between the managed .NET code and the unmanaged ActiveX component. So that's expected.
-tg
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.