Click here to Skip to main content
15,891,248 members
Home / Discussions / C#
   

C#

 
GeneralRe: listBox Item Removal Pin
V.22-Oct-12 1:27
professionalV.22-Oct-12 1:27 
AnswerRe: listBox Item Removal Pin
BobJanova22-Oct-12 4:22
BobJanova22-Oct-12 4:22 
GeneralRe: listBox Item Removal Pin
electriac22-Oct-12 5:48
electriac22-Oct-12 5:48 
GeneralRe: listBox Item Removal Pin
DaveyM6922-Oct-12 11:41
professionalDaveyM6922-Oct-12 11:41 
GeneralRe: listBox Item Removal Pin
electriac23-Oct-12 10:22
electriac23-Oct-12 10:22 
GeneralRe: listBox Item Removal Pin
DaveyM6923-Oct-12 22:36
professionalDaveyM6923-Oct-12 22:36 
GeneralRe: listBox Item Removal Pin
BobJanova24-Oct-12 6:27
BobJanova24-Oct-12 6:27 
GeneralRe: listBox Item Removal Pin
DaveyM6924-Oct-12 21:30
professionalDaveyM6924-Oct-12 21:30 
GeneralRe: listBox Item Removal Pin
electriac24-Oct-12 12:35
electriac24-Oct-12 12:35 
AnswerRe: listBox Item Removal Pin
Braj_1223-Oct-12 2:36
Braj_1223-Oct-12 2:36 
GeneralRe: listBox Item Removal Pin
electriac23-Oct-12 10:24
electriac23-Oct-12 10:24 
Questionconstructor call Pin
anshumansingh7121-Oct-12 20:24
anshumansingh7121-Oct-12 20:24 
AnswerRe: constructor call PinPopular
J4amieC21-Oct-12 21:32
J4amieC21-Oct-12 21:32 
QuestionHow to Send & Receive data using USB port in C# Pin
willington.d21-Oct-12 19:35
willington.d21-Oct-12 19:35 
AnswerRe: How to Send & Receive data using USB port in C# Pin
Richard MacCutchan21-Oct-12 22:00
mveRichard MacCutchan21-Oct-12 22:00 
GeneralRe: How to Send & Receive data using USB port in C# Pin
willington.d21-Oct-12 23:02
willington.d21-Oct-12 23:02 
GeneralRe: How to Send & Receive data using USB port in C# Pin
Richard MacCutchan21-Oct-12 23:24
mveRichard MacCutchan21-Oct-12 23:24 
GeneralRe: How to Send & Receive data using USB port in C# Pin
Dave Kreskowiak22-Oct-12 2:08
mveDave Kreskowiak22-Oct-12 2:08 
GeneralRe: How to Send & Receive data using USB port in C# Pin
Marco Bertschi22-Oct-12 5:07
protectorMarco Bertschi22-Oct-12 5:07 
GeneralRe: How to Send & Receive data using USB port in C# Pin
Dave Kreskowiak22-Oct-12 10:25
mveDave Kreskowiak22-Oct-12 10:25 
GeneralRe: How to Send & Receive data using USB port in C# Pin
Marco Bertschi22-Oct-12 21:35
protectorMarco Bertschi22-Oct-12 21:35 
AnswerRe: How to Send & Receive data using USB port in C# Pin
Marco Bertschi22-Oct-12 5:02
protectorMarco Bertschi22-Oct-12 5:02 
GeneralRe: How to Send & Receive data using USB port in C# Pin
Richard Andrew x6422-Oct-12 7:48
professionalRichard Andrew x6422-Oct-12 7:48 
SuggestionRe: How to Send & Receive data using USB port in C# Pin
Marco Bertschi22-Oct-12 21:43
protectorMarco Bertschi22-Oct-12 21:43 
QuestionError: Calling C++ dll function in C# Pin
taibc21-Oct-12 17:33
taibc21-Oct-12 17:33 
Hi,

I am trying to use functions in C++ dll from C#, but I got an error: "attempt to read or write protected memory. This is often indication that other memory is corrupt"
Anyone know how to fix ?

Here is C++ functions:

typedef void *DGNHandle;

 __declspec(dllexport) DGNHandle CPL_DLL    DGNOpen( const char *, int );
 __declspec(dllexport) DGNElemCore CPL_DLL *DGNReadElement( DGNHandle )


Here is structure in C++:
typedef struct {
    int         offset;
    int         size;

    int         element_id;     /*!< Element number (zero based) */
    int         stype;          /*!< Structure type: (DGNST_*) */
    int         level;          /*!< Element Level: 0-63 */
    int         type;           /*!< Element type (DGNT_) */
    int         complex;        /*!< Is element complex? */
    int         deleted;        /*!< Is element deleted? */

    int         graphic_group;  /*!< Graphic group number */
    int         properties;     /*!< Properties: ORing of DGNPF_ flags */
    int         color;          /*!< Color index (0-255) */
    int         weight;         /*!< Line Weight (0-31) */
    int         style;          /*!< Line Style: One of DGNS_* values */

    int         attr_bytes;     /*!< Bytes of attribute data, usually zero. */
    unsigned char *attr_data;   /*!< Raw attribute data */

    int         raw_bytes;      /*!< Bytes of raw data, usually zero. */
    unsigned char *raw_data;    /*!< All raw element data including header. */
} DGNElemCore; 


And below converted codes are in C#:

[StructLayout(LayoutKind.Sequential )]
    public class DGNElemCore
    {
        public int attr_bytes;
        public byte[] attr_data;
        public int color;
        public int complex;
        public int deleted;
        public int element_id;
        public int graphic_group;
        public int level;
        public int offset;
        public int properties;
        public int raw_bytes;
        public byte[] raw_data;
        public int size;
        public int style;
        public int stype;
        public int type;
        public int weight;

    }

[DllImport("DgnLib.dll", EntryPoint = "DGNOpen")]
        public static extern IntPtr  DGNOpen(string fileName, int bUpdate);
[DllImport("DgnLib.dll", EntryPoint = "DGNReadElement")]
        public static extern DGNElemCore DGNReadElement(IntPtr DGNHandle)


Codes for testing:

DGNElemCore element = new DGNElemCore();
element = DgnFile.DGNReadElement(dgnFile.oDgnFile)

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.