4 Replies - 1538 Views - Last Post: 29 January 2010 - 04:48 AM Rate Topic: -----

#1 Q8y  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 54
  • Joined: 06-April 09

Problem with calling dll in vb.net

Posted 28 January 2010 - 04:28 AM

I have problem in calling DLL file in VB.Net that I had Created it in C++... it give me this error message

"An unhandled exception of type 'System.EntryPointNotFoundException' occurred in test_dll_1.exe
Additional information: Unable to find an entry point named 'add_1' in DLL 't1.dll'."


this is my code in C++ (header file)


__declspec(dllexport) double add_1(double a, double b);
__declspec(dllexport) double sub_1(double a, double b);





the one in the main

#include "header_1.h"


double add_1(double a, double b){
return (a+b);
}

double sub_1(double a, double b){
return (a-b);
}






this code only for creating dll and I did created it correctly and i had tested it in c++ and it did works.... but in the Vb.net I had no luck with it...


This is the code that I wrote it in the VB.net

Imports System.Runtime.InteropServices

Public Class Form1

	<DllImport("t1.dll")> Public Shared Function add_1(ByVal a1 As Double, ByVal a2 As Double) As Double

	End Function


	Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
		TextBox1.Text = add_1(4, 3)

	End Sub

	Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load


	End Sub

	Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged

	End Sub
End Class




and, I did put the .dll file in the bin folder, but also with no luck...


thank u very much in advance.... I hope u can help me Guys.....

Is This A Good Question/Topic? 0
  • +

Replies To: Problem with calling dll in vb.net

#2 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 8939
  • View blog
  • Posts: 33,509
  • Joined: 12-June 08

Re: Problem with calling dll in vb.net

Posted 28 January 2010 - 09:23 AM

If I remember this right - I believe .NET is bitching there is no class containing your c++ functions. Wrap a class around it and go from there.
Was This Post Helpful? 1
  • +
  • -

#3 Rickster0  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 16
  • View blog
  • Posts: 236
  • Joined: 08-July 08

Re: Problem with calling dll in vb.net

Posted 28 January 2010 - 09:37 AM

This PDF should give you all the information you need.

it's helped me out allot.

http://edais.mvps.or...s%20in%20VB.pdf
Was This Post Helpful? 1
  • +
  • -

#4 Q8y  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 54
  • Joined: 06-April 09

Re: Problem with calling dll in vb.net

Posted 28 January 2010 - 10:53 AM

modi123_1: I will do that & I will give u the result.

Rickster0: Thank u very very much for the pdf, I can u use this pdf as a reference. and I will try it with my code now.


Thank u very much Guys for ur help... you helped me alot , I a preciate that ;)
Was This Post Helpful? 0
  • +
  • -

#5 Rickster0  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 16
  • View blog
  • Posts: 236
  • Joined: 08-July 08

Re: Problem with calling dll in vb.net

Posted 29 January 2010 - 04:48 AM

Not a problem. It should work fine,. if there are any problems let me know :D
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1