tags:

views:

32

answers:

1

Howdy all, I have a weird situation. I have a C++ code that overloads the +,-,* operators and exports them in a .DLL file. Now, I want to import those overloaded operators from within VB.NET code. So it should be like this:

 <DllImport("StructDLL.dll")> Public Shared Function 
 Operator +(ByVal a1 As A, ByVal a2 As A) As A
End Function

So what I'm trying to do above it just import the lovely overloaded operator + from the DLL.

Note that the operator is already overloaded from inside the DLL, so should I import it as a Function or as an Operator like this?

 <DllImport("StructDLL.dll")> Public Shared 
  Operator +(ByVal a1 As A, ByVal a2 As A) As A
  End Operator

The overloaded plus operator is supposed to add structs. So the DLL is programmed to work on structs (C++) and I want to import it in VB.NET to work on Structures.

+1  A: 

You cannot make this work. The P/Invoke marshaller doesn't support functions that return structures.

Hans Passant