troubleshooting Question

DllImport - vb6 dll into C#

Avatar of Rama Tito
Rama TitoFlag for Malaysia asked on
C#
14 Comments1 Solution1985 ViewsLast Modified:
I did face error on calling VB6 dll into C#. DllNotFoundExeption was unhandled.
Please do advice.
' File : VB6
' Project Name : ProjectArea
' Class Name : ClassArea


Public Function Area(x As Integer, y As Integer) As Integer
 Area = x * y
End Function


##################################################################

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;

namespace Area_in_dll
{
    public partial class Form1 : Form
    {
        [DllImport("ProjectArea.dll",CharSet =  CharSet.Auto ,ExactSpelling = true)]
        public static extern Int16 Area(Int16 x, Int16 y) ;
        public Form1()
        {
            InitializeComponent();       
        }

        private void button1_Click(object sender, EventArgs e)
        {
            int z;
            z = Area(5, 6);
            textBox1.Text = Convert.ToString(z);
           
        }
    }
}
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 14 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 14 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros