ANY COM Interop GURUS out there!? - Nested Structs with arrays of

G

Guest

I've got a doozie of a problem! I and others have been trying to figure this
out for too long and I've come to the conclusion that I should probably look
for some support..

Ok, I have a COM component written in C++ (I don't have the source just the
binary) and am referencing it from VB. I would say about 99% of the
functionality exposed by this COM component works fine from vb .net but I am
having a problem calling a method which has a parameter that is a struct
defined in the COM component. This struct has a member which is a struct
which contains an array of another struct. When I call the method I receive a
TypeLoadException with very little detail (thats about it) Here is the MSIL
for the structures.. The members who are causing the problems (i am about 99%
sure) are the members that end in "list"

'I have removed all of the members of the following struct who I feel are
defined correctly (i removed about 19 members of this struct). This is done
for the sake of simplicity

..class public sequential ansi sealed beforefieldinit tcsGroupAttributes_t
extends [mscorlib]System.ValueType
{
..pack 4
..size 0
..field public valuetype Nokia.TCSapi.tcsSubscriberAddress_t groupAddress
..field public valuetype Nokia.TCSapi.tcsOrgBlockAttributes2List_t
entryRightsList //THIS GUYS THE PROBLEM! 99% SURE!
} // end of class tcsGroupAttributes_t

' Here is the definition of tcsOrgBlockAttributes2List
..class public sequential ansi sealed beforefieldinit
tcsOrgBlockAttributes2List_t
extends [mscorlib]System.ValueType
{
..pack 2
..size 0
..field public unsigned int16 length
..field public marshal( fixed array [75]) valuetype
Nokia.TCSapi.tcsOrgBlockAttributes2_t[] orgBlockAttributes2List
} // end of class tcsOrgBlockAttributes2List_t

'Here is the definition of tcsOrgBlockAttributes2_t

..class public sequential ansi sealed beforefieldinit tcsOrgBlockAttributes2_t
extends [mscorlib]System.ValueType
{
..pack 2
..size 0
..field public marshal( fixed array [6]) unsigned int16[] orgBlockId
..field public marshal( fixed array [32]) unsigned int8[] orgBlockMnemonic
} // end of class tcsOrgBlockAttributes2_t

Ok, Here is the signature of the method that I am calling
(tcsGroupAttributesMask structure is straightforward and similiar objects
work in other calls so this structure is not the problem. Its the
tcsGroupAttributes)

..method public hidebysig newslot abstract virtual
instance int32 Create([in] valuetype Nokia.TCSapi.tcsGroupAttributes_t&
groupAttributes,
[in] valuetype Nokia.TCSapi.tcsGroupAttributesMask_t& groupAttributesMask,
[in] int16 cookie) runtime managed internalcall
{
}

This is an incredibley difficult problem and much respect to anyone that can
help or solve this. I have googled the ** out of this and have read nearly
every resource out there discussing COM interop. I have tried editing the
disassembled il and setting the member valuetypes to IntPtrs but then I get a
MissingFieldException.. Appreciate any help in advance!

Aaron
 
G

Guest

First of all, thanks for the response Mattias! I notice you consistently
help us problem ridden posters and let me just say we really appreciate the
time you take helping us.

Regarding my issue, I don't have the source code for the COM component so am
unable to change the type definitions for the Struct members. This dll does
not export these methods either, so, if I understand PInvoke correctly, I am
unable to use PInvoke since the method isn't exported. So, knowing what I
know now from the info contained in the link you referred to, if I were able
to flatten the struct members (get rid of array references, which I would
like to do anyways since I am always just passing in 1) this method would
complete S_OK. <- :s

So the question now is, is it possible to _redefine_ a structure which is
declared in the namespace of the COM component? So I would be able to call
'pseudo code
Structure MyNewlyRedefinedGroupAttribute
....
.... ' redefine the array structure to be non-arrays
end structure
Dim myNewlyRedefinedGroupAttributes as MyNewlyRedefinedGroupAttribute

Be able to use my redefined flattened structure without getting
"There is no interface that accepts these parameters
(myapp.MyNewlyRedefinedGroupAttribute, Nokia.TCSapi.tcsGroupAttributesMask_t,
int16)"

Create(myNewlyRedefinedGroupAttributes, groupAttributesMask, cookie)

Is it possible to just edit the IL and reassemble or will I get that
"missingfieldexception"?

Thanks in advance Mattias!

Aaron
 
G

Guest

In other words, how do I go about _flattening_ my structure when I don't have
the source code for the COM component to change the c++ source and do a
recompile. Can I do something with the IL or a switch to the TLBIMP.exe? Any
help appreciated!
 
G

Guest

One last thing.. Does anyone know what the pack and size attributes represnt?

..class public sequential ansi sealed beforefieldinit
tcsOrgBlockAttributes2List_t
extends [mscorlib]System.ValueType
{
.pack 2
.size 0
.field public unsigned int16 length
.field public marshal([ + 0]) valuetype
Nokia.TCSapi.tcsOrgBlockAttributes2_t[] orgBlockAttributes2List
} // end of class tcsOrgBlockAttributes2List_t


In addition, I just want this call to the COM component to work, no matter
how hackey it is. I can make it pretty l8r.

Aaron said:
I've got a doozie of a problem! I and others have been trying to figure this
out for too long and I've come to the conclusion that I should probably look
for some support..

Ok, I have a COM component written in C++ (I don't have the source just the
binary) and am referencing it from VB. I would say about 99% of the
functionality exposed by this COM component works fine from vb .net but I am
having a problem calling a method which has a parameter that is a struct
defined in the COM component. This struct has a member which is a struct
which contains an array of another struct. When I call the method I receive a
TypeLoadException with very little detail (thats about it) Here is the MSIL
for the structures.. The members who are causing the problems (i am about 99%
sure) are the members that end in "list"

'I have removed all of the members of the following struct who I feel are
defined correctly (i removed about 19 members of this struct). This is done
for the sake of simplicity

.class public sequential ansi sealed beforefieldinit tcsGroupAttributes_t
extends [mscorlib]System.ValueType
{
.pack 4
.size 0
.field public valuetype Nokia.TCSapi.tcsSubscriberAddress_t groupAddress
.field public valuetype Nokia.TCSapi.tcsOrgBlockAttributes2List_t
entryRightsList //THIS GUYS THE PROBLEM! 99% SURE!
} // end of class tcsGroupAttributes_t

' Here is the definition of tcsOrgBlockAttributes2List
.class public sequential ansi sealed beforefieldinit
tcsOrgBlockAttributes2List_t
extends [mscorlib]System.ValueType
{
.pack 2
.size 0
.field public unsigned int16 length
.field public marshal( fixed array [75]) valuetype
Nokia.TCSapi.tcsOrgBlockAttributes2_t[] orgBlockAttributes2List
} // end of class tcsOrgBlockAttributes2List_t

'Here is the definition of tcsOrgBlockAttributes2_t

.class public sequential ansi sealed beforefieldinit tcsOrgBlockAttributes2_t
extends [mscorlib]System.ValueType
{
.pack 2
.size 0
.field public marshal( fixed array [6]) unsigned int16[] orgBlockId
.field public marshal( fixed array [32]) unsigned int8[] orgBlockMnemonic
} // end of class tcsOrgBlockAttributes2_t

Ok, Here is the signature of the method that I am calling
(tcsGroupAttributesMask structure is straightforward and similiar objects
work in other calls so this structure is not the problem. Its the
tcsGroupAttributes)

.method public hidebysig newslot abstract virtual
instance int32 Create([in] valuetype Nokia.TCSapi.tcsGroupAttributes_t&
groupAttributes,
[in] valuetype Nokia.TCSapi.tcsGroupAttributesMask_t& groupAttributesMask,
[in] int16 cookie) runtime managed internalcall
{
}

This is an incredibley difficult problem and much respect to anyone that can
help or solve this. I have googled the ** out of this and have read nearly
every resource out there discussing COM interop. I have tried editing the
disassembled il and setting the member valuetypes to IntPtrs but then I get a
MissingFieldException.. Appreciate any help in advance!

Aaron
 
T

tcarvin

Couldn't you just alter the typelib for your COM component? You can use a tool
like OLE View to extract the type lib from the COM component, which you could
then modify and rebuild. Be forewarned, I haven't tried this specifically.

Tom
 
G

Guest

Be forewarned, I haven't tried this specifically.

Hehe, sounds fun, I'll give it a shot!
Thx for the response man.
 
G

Guest

OLEView allowed me to view the types but not edit/rebuild. Any other
suggestions?

I tried editing the IL file, but once I change the field definitions for a
struct, I get a MissingFieldException after reassembling/deploying/running my
app. I tried changing the valuetype myobject[] struct members to pointers
(native int) and thats when I get a *runtime* error of missingFieldException
(although it does compile). Anyways, any other ideas?
 
T

tcarvin

Sorry I wasn't clear. You can use OLE View to capture the IDL source (copy-n-
paste). You can then edit it, and then recompile it using MIDL. It is the
TypeLib that Visual Studio uses to map to the component's signitures. Of
course, you have to be sure to not actually break one of those signitures, just
"bend" it a little. Like flattening your array to let .NET call it. It doesn't
change the actual data layout in memory so the COM component will be none the
wiser.

I hope that helps,
Tom

Aaron said:
OLEView allowed me to view the types but not edit/rebuild. Any other
suggestions?

I tried editing the IL file, but once I change the field definitions for a
struct, I get a MissingFieldException after reassembling/deploying/running my
app. I tried changing the valuetype myobject[] struct members to pointers
(native int) and thats when I get a *runtime* error of missingFieldException
(although it does compile). Anyways, any other ideas?

tcarvin said:
Couldn't you just alter the typelib for your COM component? You can use a tool
like OLE View to extract the type lib from the COM component, which you could
then modify and rebuild. Be forewarned, I haven't tried this specifically.

Tom
 
G

Guest

*gulp* K I'll try it.. *he said with a nervous twitch ;)

<>

tcarvin said:
Sorry I wasn't clear. You can use OLE View to capture the IDL source (copy-n-
paste). You can then edit it, and then recompile it using MIDL. It is the
TypeLib that Visual Studio uses to map to the component's signitures. Of
course, you have to be sure to not actually break one of those signitures, just
"bend" it a little. Like flattening your array to let .NET call it. It doesn't
change the actual data layout in memory so the COM component will be none the
wiser.

I hope that helps,
Tom

Aaron said:
OLEView allowed me to view the types but not edit/rebuild. Any other
suggestions?

I tried editing the IL file, but once I change the field definitions for a
struct, I get a MissingFieldException after reassembling/deploying/running my
app. I tried changing the valuetype myobject[] struct members to pointers
(native int) and thats when I get a *runtime* error of missingFieldException
(although it does compile). Anyways, any other ideas?

tcarvin said:
Couldn't you just alter the typelib for your COM component? You can use a tool
like OLE View to extract the type lib from the COM component, which you could
then modify and rebuild. Be forewarned, I haven't tried this specifically.

Tom

In other words, how do I go about _flattening_ my structure when I don't have
the source code for the COM component to change the c++ source and do a
recompile. Can I do something with the IL or a switch to the TLBIMP.exe? Any
help appreciated!

:

First of all, thanks for the response Mattias! I notice you consistently
help us problem ridden posters and let me just say we really appreciate the
time you take helping us.

Regarding my issue, I don't have the source code for the COM component so am
unable to change the type definitions for the Struct members. This dll does
not export these methods either, so, if I understand PInvoke correctly, I am
unable to use PInvoke since the method isn't exported. So, knowing what I
know now from the info contained in the link you referred to, if I were able
to flatten the struct members (get rid of array references, which I would
like to do anyways since I am always just passing in 1) this method would
complete S_OK. <- :s

So the question now is, is it possible to _redefine_ a structure which is
declared in the namespace of the COM component? So I would be able to call
'pseudo code
Structure MyNewlyRedefinedGroupAttribute
...
... ' redefine the array structure to be non-arrays
end structure
Dim myNewlyRedefinedGroupAttributes as MyNewlyRedefinedGroupAttribute

Be able to use my redefined flattened structure without getting
"There is no interface that accepts these parameters
(myapp.MyNewlyRedefinedGroupAttribute, Nokia.TCSapi.tcsGroupAttributesMask_t,
int16)"

Create(myNewlyRedefinedGroupAttributes, groupAttributesMask, cookie)

Is it possible to just edit the IL and reassemble or will I get that
"missingfieldexception"?

Thanks in advance Mattias!

Aaron
:

Aaron,

This struct has a member which is a struct
which contains an array of another struct.

That's unfortunately not supported by the marshaler. See

http://dotnetinterop.com/faq/?q=StructWithStructArray



Mattias
 
T

tcarvin

I tried posting a followup a day ago, so I'll try again:

OLE View will let you capture the IDL from the TypeLib. You can cut and
paste that into another file, modify it, and then use MIDL to recreate the
TypeLib.

Regards,
Tom ([email protected])


Aaron said:
OLEView allowed me to view the types but not edit/rebuild. Any other
suggestions?

I tried editing the IL file, but once I change the field definitions for a
struct, I get a MissingFieldException after reassembling/deploying/running my
app. I tried changing the valuetype myobject[] struct members to pointers
(native int) and thats when I get a *runtime* error of missingFieldException
(although it does compile). Anyways, any other ideas?

tcarvin said:
Couldn't you just alter the typelib for your COM component? You can use a tool
like OLE View to extract the type lib from the COM component, which you could
then modify and rebuild. Be forewarned, I haven't tried this specifically.

Tom
 
T

tcarvin

I know what Pack is at least. It refers to the "alignment" of data when it
does not fall on integer boundries. VB6 always used 4 byte alignment such
that a structure that contained:

A As Byte
B As Byte
C As Long

would in memory look like this:

A As Byte
B As Byte
Pad1 As Byte
Pad2 As Byte
C As Long

In .NET you can control this.

HTH,
Tom

PS - I responded to your other OLE View question as well, but I can't seem to
find it via groups.google.com. If you didn't get it, email me.


Aaron said:
One last thing.. Does anyone know what the pack and size attributes represnt?

.class public sequential ansi sealed beforefieldinit
tcsOrgBlockAttributes2List_t
extends [mscorlib]System.ValueType
{
.pack 2
.size 0
.field public unsigned int16 length
.field public marshal([ + 0]) valuetype
Nokia.TCSapi.tcsOrgBlockAttributes2_t[] orgBlockAttributes2List
} // end of class tcsOrgBlockAttributes2List_t


In addition, I just want this call to the COM component to work, no matter
how hackey it is. I can make it pretty l8r.

Aaron said:
I've got a doozie of a problem! I and others have been trying to figure this
out for too long and I've come to the conclusion that I should probably look
for some support..

Ok, I have a COM component written in C++ (I don't have the source just the
binary) and am referencing it from VB. I would say about 99% of the
functionality exposed by this COM component works fine from vb .net but I am
having a problem calling a method which has a parameter that is a struct
defined in the COM component. This struct has a member which is a struct
which contains an array of another struct. When I call the method I receive a
TypeLoadException with very little detail (thats about it) Here is the MSIL
for the structures.. The members who are causing the problems (i am about 99%
sure) are the members that end in "list"

'I have removed all of the members of the following struct who I feel are
defined correctly (i removed about 19 members of this struct). This is done
for the sake of simplicity

.class public sequential ansi sealed beforefieldinit tcsGroupAttributes_t
extends [mscorlib]System.ValueType
{
.pack 4
.size 0
.field public valuetype Nokia.TCSapi.tcsSubscriberAddress_t groupAddress
.field public valuetype Nokia.TCSapi.tcsOrgBlockAttributes2List_t
entryRightsList //THIS GUYS THE PROBLEM! 99% SURE!
} // end of class tcsGroupAttributes_t

' Here is the definition of tcsOrgBlockAttributes2List
.class public sequential ansi sealed beforefieldinit
tcsOrgBlockAttributes2List_t
extends [mscorlib]System.ValueType
{
.pack 2
.size 0
.field public unsigned int16 length
.field public marshal( fixed array [75]) valuetype
Nokia.TCSapi.tcsOrgBlockAttributes2_t[] orgBlockAttributes2List
} // end of class tcsOrgBlockAttributes2List_t

'Here is the definition of tcsOrgBlockAttributes2_t

.class public sequential ansi sealed beforefieldinit tcsOrgBlockAttributes2_t
extends [mscorlib]System.ValueType
{
.pack 2
.size 0
.field public marshal( fixed array [6]) unsigned int16[] orgBlockId
.field public marshal( fixed array [32]) unsigned int8[] orgBlockMnemonic
} // end of class tcsOrgBlockAttributes2_t

Ok, Here is the signature of the method that I am calling
(tcsGroupAttributesMask structure is straightforward and similiar objects
work in other calls so this structure is not the problem. Its the
tcsGroupAttributes)

.method public hidebysig newslot abstract virtual
instance int32 Create([in] valuetype Nokia.TCSapi.tcsGroupAttributes_t&
groupAttributes,
[in] valuetype Nokia.TCSapi.tcsGroupAttributesMask_t& groupAttributesMask,
[in] int16 cookie) runtime managed internalcall
{
}

This is an incredibley difficult problem and much respect to anyone that can
help or solve this. I have googled the ** out of this and have read nearly
every resource out there discussing COM interop. I have tried editing the
disassembled il and setting the member valuetypes to IntPtrs but then I get a
MissingFieldException.. Appreciate any help in advance!

Aaron
 
G

Guest

Ok, I used OleView to get the IDL, then I changed the array from being an
array to a non-array (I made Variable[172] look like Variable). I use MIDL
to create a tlb file. I then use tlbimp to make it a dll. Now I get a
COMException when I call the method. Anyone have any ideas? Is there a
workaround to this behaviour->
http://dotnetinterop.com/faq/?q=StructWithStructArray ?

tcarvin said:
I tried posting a followup a day ago, so I'll try again:

OLE View will let you capture the IDL from the TypeLib. You can cut and
paste that into another file, modify it, and then use MIDL to recreate the
TypeLib.

Regards,
Tom ([email protected])


Aaron said:
OLEView allowed me to view the types but not edit/rebuild. Any other
suggestions?

I tried editing the IL file, but once I change the field definitions for a
struct, I get a MissingFieldException after reassembling/deploying/running my
app. I tried changing the valuetype myobject[] struct members to pointers
(native int) and thats when I get a *runtime* error of missingFieldException
(although it does compile). Anyways, any other ideas?

tcarvin said:
Couldn't you just alter the typelib for your COM component? You can use a tool
like OLE View to extract the type lib from the COM component, which you could
then modify and rebuild. Be forewarned, I haven't tried this specifically.

Tom

In other words, how do I go about _flattening_ my structure when I don't have
the source code for the COM component to change the c++ source and do a
recompile. Can I do something with the IL or a switch to the TLBIMP.exe? Any
help appreciated!

:

First of all, thanks for the response Mattias! I notice you consistently
help us problem ridden posters and let me just say we really appreciate the
time you take helping us.

Regarding my issue, I don't have the source code for the COM component so am
unable to change the type definitions for the Struct members. This dll does
not export these methods either, so, if I understand PInvoke correctly, I am
unable to use PInvoke since the method isn't exported. So, knowing what I
know now from the info contained in the link you referred to, if I were able
to flatten the struct members (get rid of array references, which I would
like to do anyways since I am always just passing in 1) this method would
complete S_OK. <- :s

So the question now is, is it possible to _redefine_ a structure which is
declared in the namespace of the COM component? So I would be able to call
'pseudo code
Structure MyNewlyRedefinedGroupAttribute
...
... ' redefine the array structure to be non-arrays
end structure
Dim myNewlyRedefinedGroupAttributes as MyNewlyRedefinedGroupAttribute

Be able to use my redefined flattened structure without getting
"There is no interface that accepts these parameters
(myapp.MyNewlyRedefinedGroupAttribute, Nokia.TCSapi.tcsGroupAttributesMask_t,
int16)"

Create(myNewlyRedefinedGroupAttributes, groupAttributesMask, cookie)

Is it possible to just edit the IL and reassemble or will I get that
"missingfieldexception"?

Thanks in advance Mattias!

Aaron
:

Aaron,

This struct has a member which is a struct
which contains an array of another struct.

That's unfortunately not supported by the marshaler. See

http://dotnetinterop.com/faq/?q=StructWithStructArray



Mattias
 
G

Guest

Mattias, how do I flatten the array when I just have the il and not the
source code.? When I make the struct member a non-array, it gives me a COM
Exception? Would it help to edit IDL.?
 
T

tcarvin

Aaron,

Sorry for the long delay, I didn't notice a response in this thread.

You said you "made made Variable[172] look like Variable".

Can you post the IDL before and after for the change you made?

Tom

PS - I'm hoping a real Interop expert (which I will make no claim to be)
will post here if what I have proposed won't work.

Aaron said:
Ok, I used OleView to get the IDL, then I changed the array from being an
array to a non-array (I made Variable[172] look like Variable). I use MIDL
to create a tlb file. I then use tlbimp to make it a dll. Now I get a
COMException when I call the method. Anyone have any ideas? Is there a
workaround to this behaviour->
http://dotnetinterop.com/faq/?q=StructWithStructArray ?

tcarvin said:
I tried posting a followup a day ago, so I'll try again:

OLE View will let you capture the IDL from the TypeLib. You can cut and
paste that into another file, modify it, and then use MIDL to recreate the
TypeLib.

Regards,
Tom ([email protected])


Aaron said:
OLEView allowed me to view the types but not edit/rebuild. Any other
suggestions?

I tried editing the IL file, but once I change the field definitions for a
struct, I get a MissingFieldException after reassembling/deploying/running my
app. I tried changing the valuetype myobject[] struct members to pointers
(native int) and thats when I get a *runtime* error of missingFieldException
(although it does compile). Anyways, any other ideas?

:

Couldn't you just alter the typelib for your COM component? You can use a tool
like OLE View to extract the type lib from the COM component, which you could
then modify and rebuild. Be forewarned, I haven't tried this specifically.

Tom

In other words, how do I go about _flattening_ my structure when I don't have
the source code for the COM component to change the c++ source and do a
recompile. Can I do something with the IL or a switch to the TLBIMP.exe? Any
help appreciated!

:

First of all, thanks for the response Mattias! I notice you consistently
help us problem ridden posters and let me just say we really appreciate the
time you take helping us.

Regarding my issue, I don't have the source code for the COM component so am
unable to change the type definitions for the Struct members. This dll does
not export these methods either, so, if I understand PInvoke correctly, I am
unable to use PInvoke since the method isn't exported. So, knowing what I
know now from the info contained in the link you referred to, if I were able
to flatten the struct members (get rid of array references, which I would
like to do anyways since I am always just passing in 1) this method would
complete S_OK. <- :s

So the question now is, is it possible to _redefine_ a structure which is
declared in the namespace of the COM component? So I would be able to call
'pseudo code
Structure MyNewlyRedefinedGroupAttribute
...
... ' redefine the array structure to be non-arrays
end structure
Dim myNewlyRedefinedGroupAttributes as MyNewlyRedefinedGroupAttribute

Be able to use my redefined flattened structure without getting
"There is no interface that accepts these parameters
(myapp.MyNewlyRedefinedGroupAttribute, Nokia.TCSapi.tcsGroupAttributesMask_t,
int16)"

Create(myNewlyRedefinedGroupAttributes, groupAttributesMask, cookie)

Is it possible to just edit the IL and reassemble or will I get that
"missingfieldexception"?

Thanks in advance Mattias!

Aaron
:

Aaron,

This struct has a member which is a struct
which contains an array of another struct.

That's unfortunately not supported by the marshaler. See

http://dotnetinterop.com/faq/?q=StructWithStructArray



Mattias
 
G

Guest

Hey np dude,

I solved it by creating a wrapper dll in c++ and then converting the
structures. Thanks for your help man!

Aaron

tcarvin said:
Aaron,

Sorry for the long delay, I didn't notice a response in this thread.

You said you "made made Variable[172] look like Variable".

Can you post the IDL before and after for the change you made?

Tom

PS - I'm hoping a real Interop expert (which I will make no claim to be)
will post here if what I have proposed won't work.

Aaron said:
Ok, I used OleView to get the IDL, then I changed the array from being an
array to a non-array (I made Variable[172] look like Variable). I use MIDL
to create a tlb file. I then use tlbimp to make it a dll. Now I get a
COMException when I call the method. Anyone have any ideas? Is there a
workaround to this behaviour->
http://dotnetinterop.com/faq/?q=StructWithStructArray ?

tcarvin said:
I tried posting a followup a day ago, so I'll try again:

OLE View will let you capture the IDL from the TypeLib. You can cut and
paste that into another file, modify it, and then use MIDL to recreate the
TypeLib.

Regards,
Tom ([email protected])


OLEView allowed me to view the types but not edit/rebuild. Any other
suggestions?

I tried editing the IL file, but once I change the field definitions for a
struct, I get a MissingFieldException after reassembling/deploying/running my
app. I tried changing the valuetype myobject[] struct members to pointers
(native int) and thats when I get a *runtime* error of missingFieldException
(although it does compile). Anyways, any other ideas?

:

Couldn't you just alter the typelib for your COM component? You can use a tool
like OLE View to extract the type lib from the COM component, which you could
then modify and rebuild. Be forewarned, I haven't tried this specifically.

Tom

In other words, how do I go about _flattening_ my structure when I don't have
the source code for the COM component to change the c++ source and do a
recompile. Can I do something with the IL or a switch to the TLBIMP.exe? Any
help appreciated!

:

First of all, thanks for the response Mattias! I notice you consistently
help us problem ridden posters and let me just say we really appreciate the
time you take helping us.

Regarding my issue, I don't have the source code for the COM component so am
unable to change the type definitions for the Struct members. This dll does
not export these methods either, so, if I understand PInvoke correctly, I am
unable to use PInvoke since the method isn't exported. So, knowing what I
know now from the info contained in the link you referred to, if I were able
to flatten the struct members (get rid of array references, which I would
like to do anyways since I am always just passing in 1) this method would
complete S_OK. <- :s

So the question now is, is it possible to _redefine_ a structure which is
declared in the namespace of the COM component? So I would be able to call
'pseudo code
Structure MyNewlyRedefinedGroupAttribute
...
... ' redefine the array structure to be non-arrays
end structure
Dim myNewlyRedefinedGroupAttributes as MyNewlyRedefinedGroupAttribute

Be able to use my redefined flattened structure without getting
"There is no interface that accepts these parameters
(myapp.MyNewlyRedefinedGroupAttribute, Nokia.TCSapi.tcsGroupAttributesMask_t,
int16)"

Create(myNewlyRedefinedGroupAttributes, groupAttributesMask, cookie)

Is it possible to just edit the IL and reassemble or will I get that
"missingfieldexception"?

Thanks in advance Mattias!

Aaron
:

Aaron,

This struct has a member which is a struct
which contains an array of another struct.

That's unfortunately not supported by the marshaler. See

http://dotnetinterop.com/faq/?q=StructWithStructArray



Mattias
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top