Click here to Skip to main content
15,887,175 members
Home / Discussions / .NET (Core and Framework)
   

.NET (Core and Framework)

 
GeneralRe: Please Heeelp - ShouldSerializeMyProperty problem Pin
Uriel16-Mar-03 18:14
Uriel16-Mar-03 18:14 
QuestionWhich .NET developer magazine? Pin
Oyvind Bratland4-Mar-03 2:24
Oyvind Bratland4-Mar-03 2:24 
GeneralWhere to get the COM+ Current Object Count Pin
Gaul3-Mar-03 9:23
Gaul3-Mar-03 9:23 
GeneralHelp: Unable To Copy Data (In Structure) from Unmanged MFC/C++ App to .NET Pin
Gaul3-Mar-03 9:05
Gaul3-Mar-03 9:05 
QuestionSystem.Drawing.Drawing3D? Pin
Ioncycle3-Mar-03 5:30
Ioncycle3-Mar-03 5:30 
AnswerRe: System.Drawing.Drawing3D? Pin
leppie3-Mar-03 8:59
leppie3-Mar-03 8:59 
GeneralRe: System.Drawing.Drawing3D? Pin
Ioncycle21-Mar-03 11:56
Ioncycle21-Mar-03 11:56 
GeneralInterop - Marshaling nested structs Pin
Nathan Tran2-Mar-03 19:03
Nathan Tran2-Mar-03 19:03 
Hi,

I'm getting a System.ArgumentException trying to call the following
IActiveDesktop method:

STDMETHOD (AddDesktopItem)(THIS_ LPCCOMPONENT pcomp, DWORD dwReserved) PURE;

This is how I'm marshaling the call.

void AddDesktopItem(
[In, MarshalAs( UnmanagedType.LPStruct )] COMPONENT pcomp,
[In] int dwReserved
);

I believe the problem is with marshaling the COMPONENT structure. Could
some one point out to me if I'm marshaling the nested structures correctly.
Here is the original typedef for the struct and my c# attempt at marshaling
it.

typedef struct _tagCOMPONENT
{
DWORD dwSize; //Size of this structure
DWORD dwID; //Reserved: Set it always to zero.
int iComponentType; //One of COMP_TYPE_*
BOOL fChecked; // Is this component enabled?
BOOL fDirty; // Had the component been modified and not
BOOL fNoScroll; // Is the component scrollable?
COMPPOS cpPos; // Width, height etc.,
WCHAR wszFriendlyName[MAX_PATH];
WCHAR wszSource[INTERNET_MAX_URL_LENGTH]; //URL of the component.
WCHAR wszSubscribedURL[INTERNET_MAX_URL_LENGTH]; //Subscrined URL

DWORD dwCurItemState; // Current state of the Component.
COMPSTATEINFO csiOriginal;
COMPSTATEINFO csiRestored; // Restored state of the component.
}
COMPONENT;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode )]
public class COMPONENT
{
public int dwSize; // Size of the structure.
public int dwID; // Reserved. Set to zero.
public COMP_TYPE iComponentType;
[MarshalAs( UnmanagedType.Bool )]
public bool fChecked;
[MarshalAs( UnmanagedType.Bool )]
public bool fDirty;
[MarshalAs( UnmanagedType.Bool )]
public bool fNoScroll;
[MarshalAs( UnmanagedType.Struct )]
public COMPPOS cpPos;
[MarshalAs( UnmanagedType.ByValTStr, SizeConst = 260 )]
public string wszFriendlyName;
[MarshalAs( UnmanagedType.ByValTStr, SizeConst = 2083 )]
public string wszSource;
[MarshalAs( UnmanagedType.ByValTStr, SizeConst = 2083 )]
public string wszSubscribedURL;
public ITEM_STATE dwCurItemState;
[MarshalAs( UnmanagedType.Struct )]
public COMPSTATEINFO csiOriginal;
[MarshalAs( UnmanagedType.Struct )]
public COMPSTATEINFO csiRestored;

}

StructLayout( LayoutKind.Sequential )]
public class COMPSTATEINFO
{
public int dwSize;
public int iLeft;
public int iTop;
public int dwWidth;
public int dwHeight;
public ITEM_STATE dwItemState;
}

[StructLayout(LayoutKind.Sequential)]
public class COMPPOS
{
public int dwSize;
public int iLeft;
public int iTop;
public int dwWidth;
public int dwHeight;
public int izIndex;
[MarshalAs( UnmanagedType.Bool )]
public bool fCanResize;
[MarshalAs( UnmanagedType.Bool )]
public bool fCanResizeX;
[MarshalAs( UnmanagedType.Bool )]
public bool fCanResizeY;
public int iPreferredLeftPercent;
public int iPreferredTopPercent;
}

GeneralRemoting over internet (events) Pin
Richard P S2-Mar-03 9:24
Richard P S2-Mar-03 9:24 
GeneralRe: Remoting over internet (events) Pin
John Davis2-Mar-03 10:48
John Davis2-Mar-03 10:48 
GeneralRe: Remoting over internet (events) Pin
Richard P S3-Mar-03 0:29
Richard P S3-Mar-03 0:29 
GeneralRe: Remoting over internet (events) Pin
John Davis3-Mar-03 4:33
John Davis3-Mar-03 4:33 
Generalwfc in J# Pin
ashwathi1-Mar-03 18:26
ashwathi1-Mar-03 18:26 
General.NET Serialization Pin
LindaK28-Feb-03 9:54
LindaK28-Feb-03 9:54 
QuestionHow to remove assembly at runtime Pin
nguyentuancuong27-Feb-03 15:06
nguyentuancuong27-Feb-03 15:06 
AnswerRe: How to remove assembly at runtime Pin
leppie28-Feb-03 6:13
leppie28-Feb-03 6:13 
QuestionWhere is SourceSafe 6.0 in .NET located?? Pin
IrishSonic27-Feb-03 12:24
IrishSonic27-Feb-03 12:24 
AnswerRe: Where is SourceSafe 6.0 in .NET located?? Pin
leppie28-Feb-03 6:15
leppie28-Feb-03 6:15 
GeneralExtensive API Library Pin
Poolbeer27-Feb-03 3:18
Poolbeer27-Feb-03 3:18 
GeneralRe: Extensive API Library Pin
leppie27-Feb-03 9:43
leppie27-Feb-03 9:43 
GeneralRe: Extensive API Library Pin
Poolbeer27-Feb-03 21:46
Poolbeer27-Feb-03 21:46 
GeneralIf 2 people are working on the exact same project, how do we get each others new parts of the project... Pin
IrishSonic26-Feb-03 9:41
IrishSonic26-Feb-03 9:41 
GeneralRe: If 2 people are working on the exact same project, how do we get each others new parts of the project... Pin
Ray Cassick26-Feb-03 9:47
Ray Cassick26-Feb-03 9:47 
GeneralRe: If 2 people are working on the exact same project, how do we get each others new parts of the project... Pin
leppie26-Feb-03 11:25
leppie26-Feb-03 11:25 
Questionexception handling broken is vs2k3 final beta? Pin
Domster26-Feb-03 1:34
Domster26-Feb-03 1:34 

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.