Results 1 to 2 of 2

Thread: CALL Vb 6 DLL from C#- entry point error

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2010
    Posts
    2

    CALL Vb 6 DLL from C#- entry point error

    I am getting the error : Unable to find an entry point named "Myfunc" in DLL "C:\myfunc\my.dll" from the following call from a simple VB 6.0 DLL from C# in VS2005.

    This is the code and the steps I have taken.
    Visual Basic 6.0 - compile the following as an ActiveX DLL.

    Option Explicit
    Private Declare Function MyFunc Lib "my.dll" (ByVal cmd As String) As Boolean
    Private Sub Command1_Click()
    If MyFunc("abc") Then

    End If
    End Sub



    Visual Stuido 2005 - compile and run the following.

    using System;
    using System.Collections.Generic;
    using System.Text;
    using System.Runtime.InteropServices;

    namespace MyFunction
    {
    class Program
    {
    [DllImport("c:\\myfunc\\my.DLL")]
    public static extern bool MyFunc(string cmd);
    public static void Main(string[] args)
    {
    if (MyFunc("abc"))
    {
    }
    }
    }
    }

    To me, the following error indicates that the my.dll is being loaded okay but it can't find the function.
    Here is the error:

    An unhandled exception of type 'System.EntryPointNotFoundException' occurred in MyFunction.exe
    Additional information: Unable to find an entry point named 'MyFunc' in DLL 'c:\myfunc\my.DLL'.

  2. #2
    PowerPoster abhijit's Avatar
    Join Date
    Jun 1999
    Location
    Chit Chat Forum.
    Posts
    3,228

    Re: CALL Vb 6 DLL from C#- entry point error

    Is this a COM DLL? If it was compiled using VB6, it most likely is.
    In that case you do not need to resort to the DllImport method.
    You need to register the DLL before it can be made available to your projects in C#.

    C# lets you add references to COM Dlls.
    Everything that has a computer in will fail. Everything in your life, from a watch to a car to, you know, a radio, to an iPhone, it will fail if it has a computer in it. They should kill the people who made those things.- 'Woz'
    save a blobFileStreamDataTable To Text Filemy blog

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width