Click here to Skip to main content
15,892,161 members
Home / Discussions / C#
   

C#

 
GeneralRe: FileSystemWatcher & FTP Pin
MStanbrook1-Oct-03 15:59
MStanbrook1-Oct-03 15:59 
GeneralPaging Mr. Regex Pin
afronaut1-Oct-03 13:11
afronaut1-Oct-03 13:11 
GeneralRe: Paging Mr. Regex Pin
Wjousts1-Oct-03 14:54
Wjousts1-Oct-03 14:54 
GeneralRe: Paging Mr. Regex Pin
Daniel Turini2-Oct-03 1:53
Daniel Turini2-Oct-03 1:53 
Generalcapture command line output Pin
IsaacB1-Oct-03 11:33
IsaacB1-Oct-03 11:33 
GeneralRe: capture command line output Pin
Wjousts1-Oct-03 11:37
Wjousts1-Oct-03 11:37 
GeneralRe: capture command line output Pin
IsaacB3-Oct-03 4:06
IsaacB3-Oct-03 4:06 
GeneralCOM interop and data types Pin
lpvoid1-Oct-03 10:07
lpvoid1-Oct-03 10:07 
I've been using a number of third party COM components with VC6 and now that I am migrating to C# I beginning to dive into Interop. The manufacturer of these components won't support .Net and have no intention of migrating in the near future so I am creating wrappers for the components in question. The tlbimp utility fails with a number of errors when converting the type libraries so I am creating the wrappers by hand. So far so good - sort of. I've gotten a number of the functions in a number of the components to be accessible, my problem is finding the right data type to marshal the data as. For instance:

typedef StructList __RPC_FAR *RCStructList;

typedef struct tagSTRUCT1
{
long nVal1;
long nVal2;
double dVal1;
} Struct1;

typedef struct tagSTRUCT2
{
Struct1 S1;
Struct1 S2;
} Struct2;

struct StructNode{
Struct2 __RPC_FAR *pNext;
StructNode node;
};

struct StructList
{
StructNode __RPC_FAR *pFrst;
};

virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE
GetList(
/* [in] */ RCStructList rslRequested,
/* [in] */ DWORD dwMin,
/* [in] */ DWORD dwMax,
/* [retval][out] */ StructList rslFetched
) = 0;

OK, so, I converted the first two structures like this:

public struct Struct1
{
public Int32 nVal1;
public Int32 nVal2;
public double dVal1;
}

public struct Struct2
{
Struct1 S1;
Struct1 S2;
}

It seems to work alright. So what do I do about the other two and the function call? And what happens when one of the parameters is a BSTR pointer? I've tried the UnmanagedType.BSTR to no avail, it just keeps throwing a null reference exception. On another note, I've been able to wrap the function calls alright except when the return [retval] is an interface. I use

[return: MarshalAs(UnmanagedType.Interface)] Object func_call();

But it throws an exception saying there's no such interface.

Thank you in advance for any assistance you may provide.


GeneralRe: COM interop and data types Pin
Corinna John1-Oct-03 23:48
Corinna John1-Oct-03 23:48 
GeneralSelf Upgrading Executables (C# Windows App) Pin
OBRon1-Oct-03 9:45
OBRon1-Oct-03 9:45 
GeneralRe: Self Upgrading Executables (C# Windows App) Pin
SimonS2-Oct-03 1:24
SimonS2-Oct-03 1:24 
GeneralRe: Self Upgrading Executables (C# Windows App) Pin
OBRon2-Oct-03 2:54
OBRon2-Oct-03 2:54 
QuestionCOM Ports in C# - How ? Pin
raheela1-Oct-03 9:42
raheela1-Oct-03 9:42 
GeneralArray question Pin
Joe Woodbury1-Oct-03 7:56
professionalJoe Woodbury1-Oct-03 7:56 
GeneralRe: Array question Pin
jparsons1-Oct-03 9:20
jparsons1-Oct-03 9:20 
GeneralRe: Array question Pin
Joe Woodbury1-Oct-03 10:59
professionalJoe Woodbury1-Oct-03 10:59 
GeneralRe: Array question Pin
Frank Olorin Rizzi2-Oct-03 4:12
Frank Olorin Rizzi2-Oct-03 4:12 
GeneralRe: Array question Pin
jparsons2-Oct-03 5:29
jparsons2-Oct-03 5:29 
GeneralRe: Array question Pin
Julian Bucknall [MSFT]2-Oct-03 6:13
Julian Bucknall [MSFT]2-Oct-03 6:13 
GeneralRe: Array question Pin
Joe Woodbury2-Oct-03 6:40
professionalJoe Woodbury2-Oct-03 6:40 
GeneralInspiration needed - end user form editing Pin
Member 961-Oct-03 6:59
Member 961-Oct-03 6:59 
GeneralRe: Inspiration needed - end user form editing Pin
Michael P Butler2-Oct-03 1:42
Michael P Butler2-Oct-03 1:42 
GeneralRe: Inspiration needed - end user form editing Pin
Member 962-Oct-03 5:05
Member 962-Oct-03 5:05 
Generalremoting event problem Pin
manusha1-Oct-03 5:37
manusha1-Oct-03 5:37 
Generalimporting VB 6.0 into C# project... Pin
Anonymous1-Oct-03 4:47
Anonymous1-Oct-03 4:47 

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.