Click here to Skip to main content
16,005,316 members
Home / Discussions / C#
   

C#

 
AnswerRe: How to Encrypting Username and Password in C# Pin
Stanciu Vlad25-Nov-05 6:45
Stanciu Vlad25-Nov-05 6:45 
QuestionControl visibility Problem in Inheriting WinForm! Pin
majidbhutta25-Nov-05 6:12
majidbhutta25-Nov-05 6:12 
AnswerRe: Control visibility Problem in Inheriting WinForm! Pin
Stanciu Vlad25-Nov-05 6:36
Stanciu Vlad25-Nov-05 6:36 
QuestionMultiple Inheritence problem Pin
rnvrnv25-Nov-05 5:10
rnvrnv25-Nov-05 5:10 
AnswerRe: Multiple Inheritence problem Pin
sjdevo3gsr25-Nov-05 5:30
sjdevo3gsr25-Nov-05 5:30 
GeneralRe: Multiple Inheritence problem Pin
rnvrnv25-Nov-05 5:49
rnvrnv25-Nov-05 5:49 
GeneralRe: Multiple Inheritence problem Pin
Colin Angus Mackay25-Nov-05 6:30
Colin Angus Mackay25-Nov-05 6:30 
QuestionPassing ref of a struct Pin
sjdevo3gsr25-Nov-05 4:55
sjdevo3gsr25-Nov-05 4:55 
I have to interface to an OEM unmanaged library that uses structs. My code mostly works but I'm stuck on one point. The library .H contains
<code>typedef struct
{ unsigned long size;
unsigned long _private_data[64];
} Settings;</code>
and
<code>ReadSettings (HANDLE h, Settings* pSettings);</code>

which I've coded in C# as
<code>[StructLayoutAttribute(LayoutKind.Explicit)]
public struct Settings
{
[FieldOffsetAttribute(0)]
public uint size;
[FieldOffsetAttribute(4)]
public uint[] _private_data; // 64

public void InitSettings() // because my constructor does not get called...
{
size = 260; // size in bytes
_private_data = new uint[64];
}
public QCam_Settings(int zero) // required but not called ...why?
{
size = 260; // size in bytes (is this correct? Its OK in C++.)
_private_data = new uint[64];
}
}</code>and
<code>ReadSettings(IntPtr myHandle, ref Settings mySettings);</code>

then later
<code> Settings mySettings = new Settings();
mySettings.InitSettings();</code>
This gets used in a call to
<code>ReadSettings(handle, ref mySettings);</code>

This compiles correctly but generates a "Object reference not set to an instance of an object." error at runtime. Also tried using an array so the ref might work
<code>Settings mySettings[] = new Settings[1];
mySettings[0].InitSettings();
ReadSettings(handle, ref mySettings[0]);</code>
but get the same runtime error.

The OEM library has another struct that I can call successfully using the above. I've been on this for three days: anyone got an idea what I'm doing wrong?










Stewart DIBBS
Ottawa, Canada
AnswerRe: Passing ref of a struct Pin
leppie25-Nov-05 5:42
leppie25-Nov-05 5:42 
GeneralRe: Passing ref of a struct Pin
sjdevo3gsr25-Nov-05 8:08
sjdevo3gsr25-Nov-05 8:08 
QuestionC# Drawings.Image animation Pin
Ryotsuke25-Nov-05 3:41
Ryotsuke25-Nov-05 3:41 
AnswerRe: C# Drawings.Image animation Pin
Curtis Schlak.25-Nov-05 4:38
Curtis Schlak.25-Nov-05 4:38 
GeneralRe: C# Drawings.Image animation Pin
Ryotsuke25-Nov-05 10:23
Ryotsuke25-Nov-05 10:23 
GeneralRe: C# Drawings.Image animation Pin
Dave Kreskowiak25-Nov-05 10:31
mveDave Kreskowiak25-Nov-05 10:31 
GeneralRe: C# Drawings.Image animation Pin
Ryotsuke26-Nov-05 10:42
Ryotsuke26-Nov-05 10:42 
Questionhow to cancel a tab page change Pin
NikoTanghe25-Nov-05 3:22
NikoTanghe25-Nov-05 3:22 
AnswerRe: how to cancel a tab page change Pin
Curtis Schlak.25-Nov-05 4:34
Curtis Schlak.25-Nov-05 4:34 
Questiondrag and drop Pin
rakesh_nits25-Nov-05 2:32
rakesh_nits25-Nov-05 2:32 
Questionquestion about OLE Pin
KVEbek25-Nov-05 2:29
KVEbek25-Nov-05 2:29 
QuestionThreading Pin
1nsp1r3d25-Nov-05 2:26
1nsp1r3d25-Nov-05 2:26 
AnswerRe: Threading Pin
Curtis Schlak.25-Nov-05 4:44
Curtis Schlak.25-Nov-05 4:44 
QuestionArray Index Problem Pin
ytubis25-Nov-05 1:45
ytubis25-Nov-05 1:45 
AnswerRe: Array Index Problem Pin
the last free name25-Nov-05 2:16
the last free name25-Nov-05 2:16 
GeneralRe: Array Index Problem Pin
ytubis25-Nov-05 2:25
ytubis25-Nov-05 2:25 
GeneralRe: Array Index Problem Pin
Curtis Schlak.25-Nov-05 2:50
Curtis Schlak.25-Nov-05 2:50 

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.