.NET and COM Interoperability 
Author Message
 .NET and COM Interoperability

I have a legacy COM In-Proccess server, which has an interface
function:

STDMETHODIMP CMyObj::GetData( /*[out]*/ DataStruct* pData )
{
   ...

Quote:
}

where DataStruct is defined:

typedef struct AnotherStruct
{
    long ID[4];
    BSTR Name;

Quote:
}AnotherStruct;

typedef struct DataStruct
{
    AnotherStruct ArrayStruct[4];
    long          ArrayLong[4];

Quote:
}DataStruct;

now, when i'm calling this function from the .NET (C# for the matter)

MYOBJECTLib.MyObjectClass obj = new MYOBJECTLib.MyObjectClass();
MYOBJECTLib.DataStruct data;
obj.GetData( out data );

i get an exception: "Not enough storage is available to complete this
operation.", where the source of the exception was the interop.
I tried to look at the data struct and i found out that the C#
compiler, or the interop ( i don't know which one is responsible for
it ) ,that each primitve array in the struct was initialize
automaticly to the size that was defined in the COM typelib( for
example the ArrayLong was initialized to 4 int ) , but the array of
the struct ( ArrayStruct) was set to null.
I tried to modify the code to initialize it myself:

MYOBJECTLib.MyObjectClass obj = new MYOBJECTLib.MyObjectClass();
MYOBJECTLib.DataStruct data;
data.ArrauStruct = new MYOBJECTLib.AnotherStruct[4];
obj.GetData( out data );

but it didn't work.
worth mentioning that when i modified the struct:

typedef struct DataStruct
{
    AnotherStruct ArrayStruct;//ArrayStruct[4]
    long          ArrayLong[4];

Quote:
}DataStruct;

everything worked ok.
anybody???


Sat, 28 May 2005 18:03:53 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. COM Interoperability in .NET

2. JNBridge Releases Faster Version of JNBridgePro Java/.NET interoperability tool with Java-to-.NET Callbacks

3. Question about C++ .NET interoperability

4. System.Boolean Interoperability with COM

5. JNBridgePro 1.2 Java-.NET interoperability tool released in beta version

6. .NET Language Interoperability Problem

7. C# <--> COM interoperability

8. JNBridgePro 1.1 Java-.NET interoperability tool released in SE and EE versions

9. Problems with COM interoperability.

10. COM Interoperability error

11. COM interoperability between J++ and VC

12. Looking for alpha testers: Java and .NET interoperability tool

 

 
Powered by phpBB® Forum Software