Click here to Skip to main content
15,905,963 members
Home / Discussions / C#
   

C#

 
AnswerRe: socket programing Pin
Judah Gabriel Himango13-Oct-06 6:31
sponsorJudah Gabriel Himango13-Oct-06 6:31 
GeneralRe: socket programing Pin
Airtel_nokia13-Oct-06 21:15
Airtel_nokia13-Oct-06 21:15 
GeneralRe: socket programing Pin
Airtel_nokia15-Oct-06 8:47
Airtel_nokia15-Oct-06 8:47 
GeneralRe: socket programing Pin
Judah Gabriel Himango15-Oct-06 10:38
sponsorJudah Gabriel Himango15-Oct-06 10:38 
QuestionUserControl event handling Pin
CoolASL13-Oct-06 5:01
CoolASL13-Oct-06 5:01 
AnswerRe: UserControl event handling Pin
Dave Kreskowiak13-Oct-06 7:00
mveDave Kreskowiak13-Oct-06 7:00 
AnswerRe: UserControl event handling Pin
Nader Elshehabi13-Oct-06 11:47
Nader Elshehabi13-Oct-06 11:47 
QuestionProblem using legacy C++ dll with C# Pin
JohnnyB71713-Oct-06 4:49
JohnnyB71713-Oct-06 4:49 
I am trying to use a C++ dll designed in VS 6.0 with C# .net. The problem is with passing a pointer into the dll that expects a char* (not unicode). I have tried passing a IntPtr, a StringBuilder, and a Byte[], but I get the same results "AccessViolationException was unhandled" "Atempted to read or write protected memory. Any help would be appreciated.

Heres the C++ dll code:

extern "C" __declspec(dllexport) BOOL ExGetDeviceSerialNumber(DWORD nDevice, char *pSerialNum)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
TRACE(_T("Entering LogiComm2GD ExGetDeviceSerialNumber\n"));

return DllGetApp()->GetDeviceSerialNumber(nDevice, pSerialNum);
}

BOOL CLogiComm2GDApp::GetDeviceSerialNumber(DWORD nDevice, char *pSerialNum)
{
if(nDevice >= m_NumL2GDDevices)
return FALSE;

strcpy(pSerialNum, &m_USBSerialNumbers[nDevice][0]); // exception here
return TRUE;
}

and here's the C# code:

// dllImport declaration
// get the device serial numbers
[DllImport(@"C:\Documents and Settings\jbroderick\My Documents\Visual Studio 2005\Projects\\USB_D2XX_App\LogiComm2GD.dll",
EntryPoint = "ExGetDeviceSerialNumber",
ExactSpelling = false,
CharSet = CharSet.Ansi,
CallingConvention = CallingConvention.Cdecl)]
public static extern unsafe bool ExGetDeviceSerialNumber(long nDevice, IntPtr ptr);

// access the dll

IntPtr ptrSN = IntPtr.Zero;
ExGetDeviceSerialNumber(Device, ptrSN); // exception here


AnswerRe: Problem using legacy C++ dll with C# Pin
led mike13-Oct-06 7:58
led mike13-Oct-06 7:58 
GeneralRe: Problem using legacy C++ dll with C# Pin
JohnnyB71713-Oct-06 8:23
JohnnyB71713-Oct-06 8:23 
AnswerRe: Problem using legacy C++ dll with C# Pin
Nader Elshehabi13-Oct-06 11:43
Nader Elshehabi13-Oct-06 11:43 
GeneralRe: Problem using legacy C++ dll with C# Pin
JohnnyB71716-Oct-06 9:17
JohnnyB71716-Oct-06 9:17 
QuestionAdding a button (or other controls) to a form i have handle to Pin
ranzask13-Oct-06 3:34
ranzask13-Oct-06 3:34 
AnswerRe: Adding a button (or other controls) to a form i have handle to Pin
Christian Graus13-Oct-06 3:50
protectorChristian Graus13-Oct-06 3:50 
QuestionSecurity Centre API Pin
Soundman32.213-Oct-06 2:47
Soundman32.213-Oct-06 2:47 
QuestionExport data to datagerid Pin
Mamphekgo13-Oct-06 2:20
Mamphekgo13-Oct-06 2:20 
AnswerRe: Export data to datagerid Pin
basumca14-Oct-06 0:11
basumca14-Oct-06 0:11 
QuestionMulticolor Ellipse Pin
The underdog13-Oct-06 2:14
The underdog13-Oct-06 2:14 
AnswerRe: Multicolor Ellipse Pin
rah_sin13-Oct-06 2:45
professionalrah_sin13-Oct-06 2:45 
GeneralRe: Multicolor Ellipse Pin
The underdog13-Oct-06 3:07
The underdog13-Oct-06 3:07 
AnswerRe: Multicolor Ellipse Pin
mav.northwind13-Oct-06 5:21
mav.northwind13-Oct-06 5:21 
QuestionMSMQ queuing vba process sends, C# process receive Pin
rodrigorodriquez13-Oct-06 2:01
rodrigorodriquez13-Oct-06 2:01 
QuestionCall C# Code within DTS Pin
Zeeshan Gulzar13-Oct-06 1:25
Zeeshan Gulzar13-Oct-06 1:25 
QuestionNewbie: Problem invoking?? Pin
Phillip Hodges13-Oct-06 1:07
Phillip Hodges13-Oct-06 1:07 
AnswerRe: Newbie: Problem invoking?? Pin
Christian Graus13-Oct-06 1:24
protectorChristian Graus13-Oct-06 1:24 

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.