Click here to Skip to main content
15,892,161 members
Home / Discussions / C#
   

C#

 
GeneralRe: Windows Service Question Pin
Ernest Laurentin6-Mar-08 7:26
Ernest Laurentin6-Mar-08 7:26 
GeneralRe: Windows Service Question Pin
#realJSOP6-Mar-08 8:34
mve#realJSOP6-Mar-08 8:34 
GeneralRe: Windows Service Question Pin
PIEBALDconsult6-Mar-08 7:01
mvePIEBALDconsult6-Mar-08 7:01 
GeneralRe: Windows Service Question Pin
#realJSOP6-Mar-08 7:17
mve#realJSOP6-Mar-08 7:17 
GeneralRe: Windows Service Question Pin
PIEBALDconsult6-Mar-08 9:50
mvePIEBALDconsult6-Mar-08 9:50 
GeneralRe: Windows Service Question Pin
#realJSOP6-Mar-08 10:31
mve#realJSOP6-Mar-08 10:31 
GeneralRe: Windows Service Question Pin
PIEBALDconsult6-Mar-08 16:48
mvePIEBALDconsult6-Mar-08 16:48 
Generalreference a C++ dll in a C# program Pin
steve_rm6-Mar-08 5:42
steve_rm6-Mar-08 5:42 
Hello,

VS 3.5

I have created a simple C++ DLL, and I want to use this in my C# program.

However, I am getting a Can't find PInvoke DLL 'TEST_SIP.dll

I have placed the DLL in my debug folder where my C# program is executed from. I am not sure if that is the correct place to put it.

Not sure where I am going wrong with this one.

many thanks for any suggestions,

Steve

Code in my C#
<br />
[DllImport("TEST_SIP.dll")]<br />
        public static extern double Add(double a, double b);<br />
<br />
         private void btnLogin_Click_1(object sender, EventArgs e)<br />
        {<br />
            string msg = SendData("Hello how are you");//Can't find PInvoke DLL 'TEST_SIP.dll'.<br />
            MessageBox.Show(msg);<br />
        }<br />


C++ header
<br />
//TEST_SIP.h<br />
#include <iostream><br />
<br />
namespace TEST_SIP<br />
{<br />
	class TEST_SIP_Phone<br />
	{<br />
	public:<br />
		static _declspec(dllexport) double Add(double a, double b);<br />
		static _declspec(dllexport) double Subtract(double a, double b);<br />
		static _declspec(dllexport) double Multiply(double a, double b);<br />
		static _declspec(dllexport) double Divide(double a, double b);<br />
		static _declspec(dllexport) std::string SendData(std::string data);<br />
	};<br />
}


C++ Functions
<br />
//TEST_SIP.cpp<br />
#include "TEST_SIP.h"<br />
#include <stdexcept><br />
#include <cctype><br />
<br />
using namespace std;<br />
<br />
namespace TEST_SIP<br />
{<br />
	double TEST_SIP_Phone::Add(double a, double b)<br />
	{<br />
		return a + b;<br />
	}<br />
	double TEST_SIP_Phone::Subtract(double a, double b)<br />
	{<br />
		return a - b;<br />
	}<br />
	double TEST_SIP_Phone::Multiply(double a, double b)<br />
	{<br />
		return a * b;<br />
	}<br />
	double TEST_SIP_Phone::Divide(double a, double b)<br />
	{<br />
		if(b == 0)<br />
		{<br />
			throw new invalid_argument("b cannot be zero!");<br />
		}<br />
<br />
		return a / b;<br />
	}<br />
	std::string TEST_SIP_Phone::SendData(std::string data)<br />
	{<br />
		return data;		<br />
	}	<br />
}<br />

GeneralRe: reference a C++ dll in a C# program [modified] Pin
Ernest Laurentin6-Mar-08 7:02
Ernest Laurentin6-Mar-08 7:02 
GeneralRe: reference a C++ dll in a C# program Pin
PIEBALDconsult6-Mar-08 7:04
mvePIEBALDconsult6-Mar-08 7:04 
QuestionIn briefly, What's mean this sentence : (C# is strongly typed language) ? Pin
hdv2126-Mar-08 4:42
hdv2126-Mar-08 4:42 
AnswerRe: In briefly, What's mean this sentence : (C# is strongly typed language) ? Pin
Pete O'Hanlon6-Mar-08 4:45
mvePete O'Hanlon6-Mar-08 4:45 
GeneralRe: In briefly, What's mean this sentence : (C# is strongly typed language) ? Pin
phannon866-Mar-08 5:02
professionalphannon866-Mar-08 5:02 
GeneralRe: In briefly, What's mean this sentence : (C# is strongly typed language) ? Pin
Pete O'Hanlon6-Mar-08 5:17
mvePete O'Hanlon6-Mar-08 5:17 
GeneralRe: In briefly, What's mean this sentence : (C# is strongly typed language) ? Pin
Colin Angus Mackay6-Mar-08 11:35
Colin Angus Mackay6-Mar-08 11:35 
GeneralRe: In briefly, What's mean this sentence : (C# is strongly typed language) ? Pin
Pete O'Hanlon6-Mar-08 22:01
mvePete O'Hanlon6-Mar-08 22:01 
GeneralRe: In briefly, What's mean this sentence : (C# is strongly typed language) ? Pin
Luc Pattyn6-Mar-08 6:41
sitebuilderLuc Pattyn6-Mar-08 6:41 
AnswerRe: In briefly, What's mean this sentence : (C# is strongly typed language) ? Pin
#realJSOP6-Mar-08 5:57
mve#realJSOP6-Mar-08 5:57 
GeneralRe: In briefly, What's mean this sentence : (C# is strongly typed language) ? Pin
Judah Gabriel Himango6-Mar-08 9:59
sponsorJudah Gabriel Himango6-Mar-08 9:59 
GeneralRe: In briefly, What's mean this sentence : (C# is strongly typed language) ? Pin
Colin Angus Mackay6-Mar-08 11:38
Colin Angus Mackay6-Mar-08 11:38 
QuestionOpenFileDialog with setting View mode to small icon Pin
arbrsoft6-Mar-08 4:27
arbrsoft6-Mar-08 4:27 
GeneralRe: OpenFileDialog with setting View mode to small icon Pin
Luc Pattyn6-Mar-08 4:33
sitebuilderLuc Pattyn6-Mar-08 4:33 
Generalauto update Pin
damianrda6-Mar-08 4:15
damianrda6-Mar-08 4:15 
GeneralRe: auto update Pin
led mike6-Mar-08 4:41
led mike6-Mar-08 4:41 
GeneralRe: auto update Pin
Judah Gabriel Himango6-Mar-08 4:49
sponsorJudah Gabriel Himango6-Mar-08 4:49 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.