473,795 Members | 3,279 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

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
TypeLoadExcepti on 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 tcsGroupAttribu tes_t
extends [mscorlib]System.ValueTyp e
{
..pack 4
..size 0
..field public valuetype Nokia.TCSapi.tc sSubscriberAddr ess_t groupAddress
..field public valuetype Nokia.TCSapi.tc sOrgBlockAttrib utes2List_t
entryRightsList //THIS GUYS THE PROBLEM! 99% SURE!
} // end of class tcsGroupAttribu tes_t

' Here is the definition of tcsOrgBlockAttr ibutes2List
..class public sequential ansi sealed beforefieldinit
tcsOrgBlockAttr ibutes2List_t
extends [mscorlib]System.ValueTyp e
{
..pack 2
..size 0
..field public unsigned int16 length
..field public marshal( fixed array [75]) valuetype
Nokia.TCSapi.tc sOrgBlockAttrib utes2_t[] orgBlockAttribu tes2List
} // end of class tcsOrgBlockAttr ibutes2List_t

'Here is the definition of tcsOrgBlockAttr ibutes2_t

..class public sequential ansi sealed beforefieldinit tcsOrgBlockAttr ibutes2_t
extends [mscorlib]System.ValueTyp e
{
..pack 2
..size 0
..field public marshal( fixed array [6]) unsigned int16[] orgBlockId
..field public marshal( fixed array [32]) unsigned int8[] orgBlockMnemoni c
} // end of class tcsOrgBlockAttr ibutes2_t

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

..method public hidebysig newslot abstract virtual
instance int32 Create([in] valuetype Nokia.TCSapi.tc sGroupAttribute s_t&
groupAttributes ,
[in] valuetype Nokia.TCSapi.tc sGroupAttribute sMask_t& groupAttributes Mask,
[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
MissingFieldExc eption.. Appreciate any help in advance!

Aaron
Nov 21 '05
17 1857
*gulp* K I'll try it.. *he said with a nervous twitch ;)

<>

"tcarvin" wrote:
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" <Aa***@discussi ons.microsoft.c om> wrote in message news:<72******* *************** ************@mi crosoft.com>...
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 MissingFieldExc eption 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 missingFieldExc eption
(although it does compile). Anyways, any other ideas?

"tcarvin" wrote:
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

"Aaron" <Aa***@discussi ons.microsoft.c om> wrote in message news:<35******* *************** ************@mi crosoft.com>...
> 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!
>
> "Aaron" wrote:
>
> > 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 MyNewlyRedefine dGroupAttribute
> > ...
> > ... ' redefine the array structure to be non-arrays
> > end structure
> > Dim myNewlyRedefine dGroupAttribute s as MyNewlyRedefine dGroupAttribute
> >
> > Be able to use my redefined flattened structure without getting
> > "There is no interface that accepts these parameters
> > (myapp.MyNewlyR edefinedGroupAt tribute, Nokia.TCSapi.tc sGroupAttribute sMask_t,
> > int16)"
> >
> > Create(myNewlyR edefinedGroupAt tributes, groupAttributes Mask, cookie)
> >
> > Is it possible to just edit the IL and reassemble or will I get that
> > "missingfieldex ception"?
> >
> > Thanks in advance Mattias!
> >
> > Aaron
> > "Mattias Sjögren" wrote:
> >
> > > 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
> > >
> > > --
> > > Mattias Sjögren [MVP] mattias @ mvps.org
> > > http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
> > > Please reply only to the newsgroup.
> > >

Nov 21 '05 #11
*gulp* K I'll try it.. *he said with a nervous twitch ;)

<>

"tcarvin" wrote:
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" <Aa***@discussi ons.microsoft.c om> wrote in message news:<72******* *************** ************@mi crosoft.com>...
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 MissingFieldExc eption 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 missingFieldExc eption
(although it does compile). Anyways, any other ideas?

"tcarvin" wrote:
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

"Aaron" <Aa***@discussi ons.microsoft.c om> wrote in message news:<35******* *************** ************@mi crosoft.com>...
> 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!
>
> "Aaron" wrote:
>
> > 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 MyNewlyRedefine dGroupAttribute
> > ...
> > ... ' redefine the array structure to be non-arrays
> > end structure
> > Dim myNewlyRedefine dGroupAttribute s as MyNewlyRedefine dGroupAttribute
> >
> > Be able to use my redefined flattened structure without getting
> > "There is no interface that accepts these parameters
> > (myapp.MyNewlyR edefinedGroupAt tribute, Nokia.TCSapi.tc sGroupAttribute sMask_t,
> > int16)"
> >
> > Create(myNewlyR edefinedGroupAt tributes, groupAttributes Mask, cookie)
> >
> > Is it possible to just edit the IL and reassemble or will I get that
> > "missingfieldex ception"?
> >
> > Thanks in advance Mattias!
> >
> > Aaron
> > "Mattias Sjögren" wrote:
> >
> > > 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
> > >
> > > --
> > > Mattias Sjögren [MVP] mattias @ mvps.org
> > > http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
> > > Please reply only to the newsgroup.
> > >

Nov 21 '05 #12
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 (NO***********@ lycos.com)
"Aaron" <Aa***@discussi ons.microsoft.c om> wrote in message news:<72******* *************** ************@mi crosoft.com>...
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 MissingFieldExc eption 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 missingFieldExc eption
(although it does compile). Anyways, any other ideas?

"tcarvin" wrote:
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

"Aaron" <Aa***@discussi ons.microsoft.c om> wrote in message news:<35******* *************** ************@mi crosoft.com>...
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!

"Aaron" wrote:

> 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 MyNewlyRedefine dGroupAttribute
> ...
> ... ' redefine the array structure to be non-arrays
> end structure
> Dim myNewlyRedefine dGroupAttribute s as MyNewlyRedefine dGroupAttribute
>
> Be able to use my redefined flattened structure without getting
> "There is no interface that accepts these parameters
> (myapp.MyNewlyR edefinedGroupAt tribute, Nokia.TCSapi.tc sGroupAttribute sMask_t,
> int16)"
>
> Create(myNewlyR edefinedGroupAt tributes, groupAttributes Mask, cookie)
>
> Is it possible to just edit the IL and reassemble or will I get that
> "missingfieldex ception"?
>
> Thanks in advance Mattias!
>
> Aaron
> "Mattias Sjögren" wrote:
>
> > 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
> >
> > --
> > Mattias Sjögren [MVP] mattias @ mvps.org
> > http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
> > Please reply only to the newsgroup.
> >

Nov 21 '05 #13
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.c om. If you didn't get it, email me.
"Aaron" <Aa***@discussi ons.microsoft.c om> wrote in message news:<10******* *************** ************@mi crosoft.com>...
One last thing.. Does anyone know what the pack and size attributes represnt?

.class public sequential ansi sealed beforefieldinit
tcsOrgBlockAttr ibutes2List_t
extends [mscorlib]System.ValueTyp e
{
.pack 2
.size 0
.field public unsigned int16 length
.field public marshal([ + 0]) valuetype
Nokia.TCSapi.tc sOrgBlockAttrib utes2_t[] orgBlockAttribu tes2List
} // end of class tcsOrgBlockAttr ibutes2List_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" wrote:
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
TypeLoadExcepti on 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 tcsGroupAttribu tes_t
extends [mscorlib]System.ValueTyp e
{
.pack 4
.size 0
.field public valuetype Nokia.TCSapi.tc sSubscriberAddr ess_t groupAddress
.field public valuetype Nokia.TCSapi.tc sOrgBlockAttrib utes2List_t
entryRightsList //THIS GUYS THE PROBLEM! 99% SURE!
} // end of class tcsGroupAttribu tes_t

' Here is the definition of tcsOrgBlockAttr ibutes2List
.class public sequential ansi sealed beforefieldinit
tcsOrgBlockAttr ibutes2List_t
extends [mscorlib]System.ValueTyp e
{
.pack 2
.size 0
.field public unsigned int16 length
.field public marshal( fixed array [75]) valuetype
Nokia.TCSapi.tc sOrgBlockAttrib utes2_t[] orgBlockAttribu tes2List
} // end of class tcsOrgBlockAttr ibutes2List_t

'Here is the definition of tcsOrgBlockAttr ibutes2_t

.class public sequential ansi sealed beforefieldinit tcsOrgBlockAttr ibutes2_t
extends [mscorlib]System.ValueTyp e
{
.pack 2
.size 0
.field public marshal( fixed array [6]) unsigned int16[] orgBlockId
.field public marshal( fixed array [32]) unsigned int8[] orgBlockMnemoni c
} // end of class tcsOrgBlockAttr ibutes2_t

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

.method public hidebysig newslot abstract virtual
instance int32 Create([in] valuetype Nokia.TCSapi.tc sGroupAttribute s_t&
groupAttributes ,
[in] valuetype Nokia.TCSapi.tc sGroupAttribute sMask_t& groupAttributes Mask,
[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
MissingFieldExc eption.. Appreciate any help in advance!

Aaron

Nov 21 '05 #14
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" wrote:
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 (NO***********@ lycos.com)
"Aaron" <Aa***@discussi ons.microsoft.c om> wrote in message news:<72******* *************** ************@mi crosoft.com>...
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 MissingFieldExc eption 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 missingFieldExc eption
(although it does compile). Anyways, any other ideas?

"tcarvin" wrote:
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

"Aaron" <Aa***@discussi ons.microsoft.c om> wrote in message news:<35******* *************** ************@mi crosoft.com>...
> 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!
>
> "Aaron" wrote:
>
> > 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 MyNewlyRedefine dGroupAttribute
> > ...
> > ... ' redefine the array structure to be non-arrays
> > end structure
> > Dim myNewlyRedefine dGroupAttribute s as MyNewlyRedefine dGroupAttribute
> >
> > Be able to use my redefined flattened structure without getting
> > "There is no interface that accepts these parameters
> > (myapp.MyNewlyR edefinedGroupAt tribute, Nokia.TCSapi.tc sGroupAttribute sMask_t,
> > int16)"
> >
> > Create(myNewlyR edefinedGroupAt tributes, groupAttributes Mask, cookie)
> >
> > Is it possible to just edit the IL and reassemble or will I get that
> > "missingfieldex ception"?
> >
> > Thanks in advance Mattias!
> >
> > Aaron
> > "Mattias Sjögren" wrote:
> >
> > > 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
> > >
> > > --
> > > Mattias Sjögren [MVP] mattias @ mvps.org
> > > http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
> > > Please reply only to the newsgroup.
> > >

Nov 21 '05 #15
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.?

"Mattias Sjögren" wrote:
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

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.

Nov 21 '05 #16
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" <Aa***@discussi ons.microsoft.c om> wrote in message news:<EA******* *************** ************@mi crosoft.com>...
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" wrote:
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 (NO***********@ lycos.com)
"Aaron" <Aa***@discussi ons.microsoft.c om> wrote in message news:<72******* *************** ************@mi crosoft.com>...
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 MissingFieldExc eption 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 missingFieldExc eption
(although it does compile). Anyways, any other ideas?

"tcarvin" wrote:

> 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
>
> "Aaron" <Aa***@discussi ons.microsoft.c om> wrote in message news:<35******* *************** ************@mi crosoft.com>...
> > 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!
> >
> > "Aaron" wrote:
> >
> > > 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 MyNewlyRedefine dGroupAttribute
> > > ...
> > > ... ' redefine the array structure to be non-arrays
> > > end structure
> > > Dim myNewlyRedefine dGroupAttribute s as MyNewlyRedefine dGroupAttribute
> > >
> > > Be able to use my redefined flattened structure without getting
> > > "There is no interface that accepts these parameters
> > > (myapp.MyNewlyR edefinedGroupAt tribute, Nokia.TCSapi.tc sGroupAttribute sMask_t,
> > > int16)"
> > >
> > > Create(myNewlyR edefinedGroupAt tributes, groupAttributes Mask, cookie)
> > >
> > > Is it possible to just edit the IL and reassemble or will I get that
> > > "missingfieldex ception"?
> > >
> > > Thanks in advance Mattias!
> > >
> > > Aaron
> > > "Mattias Sjögren" wrote:
> > >
> > > > 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
> > > >
> > > > --
> > > > Mattias Sjögren [MVP] mattias @ mvps.org
> > > > http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
> > > > Please reply only to the newsgroup.
> > > >
>

Nov 21 '05 #17
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" wrote:
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" <Aa***@discussi ons.microsoft.c om> wrote in message news:<EA******* *************** ************@mi crosoft.com>...
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" wrote:
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 (NO***********@ lycos.com)
"Aaron" <Aa***@discussi ons.microsoft.c om> wrote in message news:<72******* *************** ************@mi crosoft.com>...
> 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 MissingFieldExc eption 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 missingFieldExc eption
> (although it does compile). Anyways, any other ideas?
>
> "tcarvin" wrote:
>
> > 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
> >
> > "Aaron" <Aa***@discussi ons.microsoft.c om> wrote in message news:<35******* *************** ************@mi crosoft.com>...
> > > 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!
> > >
> > > "Aaron" wrote:
> > >
> > > > 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 MyNewlyRedefine dGroupAttribute
> > > > ...
> > > > ... ' redefine the array structure to be non-arrays
> > > > end structure
> > > > Dim myNewlyRedefine dGroupAttribute s as MyNewlyRedefine dGroupAttribute
> > > >
> > > > Be able to use my redefined flattened structure without getting
> > > > "There is no interface that accepts these parameters
> > > > (myapp.MyNewlyR edefinedGroupAt tribute, Nokia.TCSapi.tc sGroupAttribute sMask_t,
> > > > int16)"
> > > >
> > > > Create(myNewlyR edefinedGroupAt tributes, groupAttributes Mask, cookie)
> > > >
> > > > Is it possible to just edit the IL and reassemble or will I get that
> > > > "missingfieldex ception"?
> > > >
> > > > Thanks in advance Mattias!
> > > >
> > > > Aaron
> > > > "Mattias Sjögren" wrote:
> > > >
> > > > > 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
> > > > >
> > > > > --
> > > > > Mattias Sjögren [MVP] mattias @ mvps.org
> > > > > http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
> > > > > Please reply only to the newsgroup.
> > > > >
> >

Nov 21 '05 #18

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
2291
by: keefah | last post by:
Hi, I'm writing a C# web app that uses Outlook to send email. I use a reference to the Microsoft Outlook 11.0 Object Library, but it's giving me problems. I tracked down some stuff on the Net about the global assembly cache (GAC) and primary interop assemblies (PIA) and so forth, and did all the recommendations, in terms of tweeking Office, installing the .NET Office stuff for framework 1.1, etc. I got it to the point where it compiles ok,...
0
3009
by: Shashank Date | last post by:
/* C# Gurus, I am trying to use interop marshalling to call SetCommTimeouts win32 API. But I keep getting the "Object reference not set to an instance of an object" error. Can anybody help me figure out why ? TIA.
8
3426
by: Rob Edwards | last post by:
When trying to add the Microsoft CDO for Exchange Management Library (aka CDOEXM.dll) I receive the following message: "A reference to 'Microsoft CDO for Exchange Management Library' could not be added. Converting the type library to a .Net assembly failed. A depended type library 'CDO' could not be converted to a .NET assembly. A dependent type library 'ADODB' could not be converted to a .NET assembly. Item has already been added." ...
7
2853
by: Biao | last post by:
I have a web service writen by .NET: public string Greetings(string names) { string gs = new string; for (int i = 0; i < gs.Length; i++) gs = string.Format("Hello, {0}", names);
7
10964
by: R Reyes | last post by:
Can someone please explain to me why I can't get the MS Word Interop assembly to work in my VS2005 project? I'm trying to manipulate MS Word from my Web Form application and I can't get passed this screen below. Please help, thanks in advance... Configuration Error Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify...
6
1627
by: Vijay | last post by:
Hi, I am faced with the following common managed/unmanaged C++ interop problem: - I have a .NET form that acts as a front end GUI to a processing engine in the background. The processing engine runs as a thread that is managed by the front-end form class. - The processing engine must have a callback mechanism to update the form about progress, and to send status messages that will be displayed
2
1677
by: Philip Daniels | last post by:
I am doing some work with a client API via COM interop. I have reached the situation where after this call to their API: object someObj = con.Peek(1); "someObj" contains some type of COM object (shows type as System.__COMObject). I have no idea what someObj is, but it is likely to be some sort of wrapper around an image : con.Peek(1) is ultimately retrieving a
1
3175
by: Reg | last post by:
Hello, I have a WCF Web Service using wsHttpDualBinding because I need a callback to Java client. I read Mr. A.Gupta's blog that if WCF Service uses wsHttpDualBinding for interop working is not guaranteed. I also tried to config wsHttpDualBinding in WCF Service Config file as follows:
0
1142
by: Kaysetoaster | last post by:
Hi Gurus I wrote a "Active X" UserControl DLL in VB.NET and placed it on a iis 6 webserver. I embeded it with the object tag and the communication to functions and propertys in the vb.net control works great. As A reference I added the COM component UIRESOURCELib.dll in the Visual Studio 2005. When the DLL starts the functions from the UIRESOURCELib, i get the following error in the IE7 ************** Exception Text **************...
2
2462
by: Brad Isaac | last post by:
Hi, I have a working app that uses interop.outlook.dll to export items to Outlook calendar. I downloaded the Primary Interop Assemblies for Office 2k7 today and still cannot get a working outlook.interop.dll to import. Are there any dll gurus out there who can help me get this up and running with Outlook 2007? I am using VS 2005.
0
9672
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9519
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10435
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10213
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
7538
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6779
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4113
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3721
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2920
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.