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

C#

 
AnswerRe: How can i know if user pressed on minimize windows or maximize ? Pin
Luc Pattyn24-Jun-08 1:29
sitebuilderLuc Pattyn24-Jun-08 1:29 
AnswerRe: How can i know if user pressed on minimize windows or maximize ? Pin
stancrm24-Jun-08 1:33
stancrm24-Jun-08 1:33 
QuestionSharepoint WorkFlow Pin
Zeyad Jalil23-Jun-08 23:48
professionalZeyad Jalil23-Jun-08 23:48 
Questionregister the dll using C# Pin
wasimsharp23-Jun-08 23:47
wasimsharp23-Jun-08 23:47 
AnswerRe: register the dll using C# Pin
Christian Graus24-Jun-08 0:02
protectorChristian Graus24-Jun-08 0:02 
QuestionGDI / Disposing of objects question Pin
Harvey Saayman23-Jun-08 23:35
Harvey Saayman23-Jun-08 23:35 
AnswerRe: GDI / Disposing of objects question Pin
leppie23-Jun-08 23:43
leppie23-Jun-08 23:43 
GeneralRe: GDI / Disposing of objects question Pin
Harvey Saayman23-Jun-08 23:47
Harvey Saayman23-Jun-08 23:47 
GeneralRe: GDI / Disposing of objects question Pin
leppie23-Jun-08 23:54
leppie23-Jun-08 23:54 
GeneralRe: GDI / Disposing of objects question Pin
Harvey Saayman24-Jun-08 0:05
Harvey Saayman24-Jun-08 0:05 
AnswerRe: GDI / Disposing of objects question Pin
Christian Graus23-Jun-08 23:57
protectorChristian Graus23-Jun-08 23:57 
GeneralRe: GDI / Disposing of objects question Pin
Harvey Saayman24-Jun-08 0:10
Harvey Saayman24-Jun-08 0:10 
GeneralRe: GDI / Disposing of objects question Pin
Christian Graus24-Jun-08 0:14
protectorChristian Graus24-Jun-08 0:14 
GeneralRe: GDI / Disposing of objects question Pin
Harvey Saayman24-Jun-08 0:22
Harvey Saayman24-Jun-08 0:22 
GeneralRe: GDI / Disposing of objects question Pin
Luc Pattyn24-Jun-08 0:37
sitebuilderLuc Pattyn24-Jun-08 0:37 
GeneralRe: GDI / Disposing of objects question Pin
Harvey Saayman24-Jun-08 0:39
Harvey Saayman24-Jun-08 0:39 
AnswerRe: GDI / Disposing of objects question Pin
Daniel Grunwald24-Jun-08 0:25
Daniel Grunwald24-Jun-08 0:25 
QuestionDateTimePicker select just date Pin
laziale23-Jun-08 23:02
laziale23-Jun-08 23:02 
AnswerRe: DateTimePicker select just date Pin
DaveyM6924-Jun-08 0:13
professionalDaveyM6924-Jun-08 0:13 
GeneralRe: DateTimePicker select just date Pin
laziale24-Jun-08 0:21
laziale24-Jun-08 0:21 
GeneralRe: DateTimePicker select just date Pin
PIEBALDconsult24-Jun-08 4:43
mvePIEBALDconsult24-Jun-08 4:43 
QuestionCannot take the address of, get the size of, or declare a pointer to a managed type? Pin
cristi_alonso23-Jun-08 22:47
cristi_alonso23-Jun-08 22:47 
I wrote code to access structre from C# .net where structure is in C dll .here are the two files .When i build i get the error message saying that "Cannot take the address of, get the size of, or declare a pointer to a managed type ('StructureExample.Program.Detail')"

------------------------- StrcutreDisplay.dll---------------------------------

#include<iostream.h>

#include<conio.h>

#include<malloc.h>

#include<string.h>

extern "C"

{

typedef struct

{

char *fname;

char *lname;


char abc[5];

}Detail;




__declspec(dllexport) Detail * Disp()

{

Detail *ptr=(Detail *)malloc(sizeof(Detail));

ptr->fname = (char*)malloc(50);

memset(ptr->fname, 0x00, 50);

ptr->lname = (char*)malloc(50);

memset(ptr->lname, 0x00, 50);


memset(ptr->abc, 0x00, 5);

strcpy(ptr->fname, "larson");

strcpy(ptr->lname, "scolari");


strcpy(ptr->abc, "ABC");
return ptr;

}

}


----------------------------StructureExample---------------------------------





using System;

using System.Collections.Generic;

using System.Text;

using System.Runtime.InteropServices;

namespace StructureExample

{

class Program

{

[StructLayout(LayoutKind.Explicit)]

public struct Detail

{ // [MarshalAs(UnmanagedType.LPStr)]

public unsafe sbyte* fname;

public unsafe sbyte* lname;

public char[] arr;

}





// strucure DLL

[DllImport("StructureDisplay.dll")]

public static unsafe extern Detail * Disp();//here i get error

static void Main(string[] args)

{

unsafe

{

Detail * var = Disp();


string a = new string(var->fname);

string b = new string(var->lname);



string e = new string(var->abc);


}


Console.WriteLine("hello world");


Console.WriteLine(a);

Console.WriteLine(b);



Console.WriteLine(e);


Console.Read();

}

}

}


------------------------------------------------------------------------------------------------

How to solve this problem?can anyone help me out?





Any help appreciated.
Thanks in advance. Smile | :)
AnswerRe: Cannot take the address of, get the size of, or declare a pointer to a managed type? Pin
leppie23-Jun-08 23:08
leppie23-Jun-08 23:08 
QuestionRe: Cannot take the address of, get the size of, or declare a pointer to a managed type? Pin
cristi_alonso24-Jun-08 1:29
cristi_alonso24-Jun-08 1:29 
AnswerRe: Cannot take the address of, get the size of, or declare a pointer to a managed type? Pin
leppie24-Jun-08 1:40
leppie24-Jun-08 1:40 

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.