Click here to Skip to main content
15,922,584 members
Home / Discussions / C#
   

C#

 
GeneralThreadPool and COM Interop Pin
DuaneP2-Oct-03 2:17
DuaneP2-Oct-03 2:17 
GeneralRe: ThreadPool and COM Interop Pin
DuaneP2-Oct-03 11:01
DuaneP2-Oct-03 11:01 
GeneralIsInRole Pin
devvvy2-Oct-03 1:35
devvvy2-Oct-03 1:35 
GeneralRe: IsInRole Pin
Julian Bucknall [MSFT]2-Oct-03 6:05
Julian Bucknall [MSFT]2-Oct-03 6:05 
GeneralRe: IsInRole Pin
devvvy2-Oct-03 6:25
devvvy2-Oct-03 6:25 
GeneralDatabase confusion question Pin
rama_ii2-Oct-03 1:33
rama_ii2-Oct-03 1:33 
GeneralRe: Database confusion question Pin
Daniel Turini2-Oct-03 1:49
Daniel Turini2-Oct-03 1:49 
GeneralSectionGroup and CMAB Pin
lionhurt20002-Oct-03 0:46
lionhurt20002-Oct-03 0:46 
GeneralRIP , Play and convert audio and video files Pin
Velichko Sarev2-Oct-03 0:36
Velichko Sarev2-Oct-03 0:36 
GeneralString question Pin
Mazdak1-Oct-03 23:23
Mazdak1-Oct-03 23:23 
GeneralRe: String question Pin
Corinna John1-Oct-03 23:38
Corinna John1-Oct-03 23:38 
GeneralRe: String question Pin
Mazdak2-Oct-03 1:14
Mazdak2-Oct-03 1:14 
GeneralRe: String question Pin
Rickard Andersson201-Oct-03 23:51
Rickard Andersson201-Oct-03 23:51 
GeneralRe: String question Pin
Mazdak2-Oct-03 1:16
Mazdak2-Oct-03 1:16 
GeneralRe: String question Pin
jparsons2-Oct-03 5:26
jparsons2-Oct-03 5:26 
Generaldatagrid problems Pin
brain2cpu1-Oct-03 21:41
professionalbrain2cpu1-Oct-03 21:41 
GeneralFileSystemWatcher & FTP Pin
MStanbrook1-Oct-03 15:09
MStanbrook1-Oct-03 15:09 
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.


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.