![]() | |
![]() |
| | Thread Tools | Search this Thread | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
I need to consume an existing service in C++ using C#. Previous clients used VB6 arrays. To paraphrase, I have a method in C++: int __stdcall DoSomething( VARIANT *pvArray ); I have tried calling this method using the following: [...] I have tried a bunch of other stuff; but I have ommitted them for brevity. Everytime I debug the C++, by variant pointer is ALWAYS null. |
#3
| |||
| |||
|
|
"praetor" <praetor (AT) discussions (DOT) microsoft.com> ha scritto nel messaggio news:30787F61-C8F4-4650-957F-A4B6C7478D16 (AT) microsoft (DOT) com... I need to consume an existing service in C++ using C#. Previous clients used VB6 arrays. To paraphrase, I have a method in C++: int __stdcall DoSomething( VARIANT *pvArray ); I have tried calling this method using the following: [...] I have tried a bunch of other stuff; but I have ommitted them for brevity. Everytime I debug the C++, by variant pointer is ALWAYS null. I'm not sure what your VARIANT stores (a SAFEARRAY of VT_UI4 ?). Moreover, is this VARIANT an input only parameter? However, if you can't find the proper marshaling on the C# side, I would suggest you to just write a C++/CLI bridging layer wrapper over your original DoSomething(). e.g. // in C++/CLI int DoSomethingWrapper( array<UInt32>^ data ) { ... create a VARIANT to pass to DoSomething(). VARIANT var; ... fill VARIANT with data stored in 'data' input variable ... // Call your original DoSomething: return DoSomething( &var ); } You can call the DoSomethingWrapper() directly from C#, passing a simple C# array to it. HTH, Giovanni |
#4
| |||
| |||
|
|
I like your suggestion; but if it is not a managed DLL, would I need to do any .NET library initialization? |
|
In answer to your question, It is a Variant SAFEARRAY of VARIANT SAFEARRAY's. The inner array has two elements. One a uint, the other either a String, Date, our Double. With this info, could you come up with a direct signature? |
#5
| |||
| |||
|
|
"praetor" <praetor (AT) discussions (DOT) microsoft.com> ha scritto nel messaggio news 56454AE-8F88-4DD0-B167-96C2DF8DCF59 (AT) microsoft (DOT) com...I like your suggestion; but if it is not a managed DLL, would I need to do any .NET library initialization? I don't understand this question well, i.e: I'm not sure I understand what you mean by "do any .NET library initialization". |
#6
| |||
| |||
|
|
I already have a dll. If I were to write this wrapper method, I would simply add it to the existing binary. It gets released to customers/3rd parties; so I don't want to add the burden of deploying an extra binary. That said, my existing binary is not managed. Could I initialize the .NET library dynamically in a non dotnet C++ dll? If so, how? |
#7
| |||
| |||
|
|
I already have a dll. If I were to write this wrapper method, I would simply add it to the existing binary. It gets released to |
|
customers/3rd parties; so I don't want to add the burden of deploying an extra binary. That said, my existing binary is not managed. Could I initialize the .NET library dynamically in a non dotnet C++ dll? If so, how? |
|
Thanks, James Beverly, MA "Giovanni Dicanio" wrote: "praetor" <praetor (AT) discussions (DOT) microsoft.com> ha scritto nel messaggio news 56454AE-8F88-4DD0-B167-96C2DF8DCF59 (AT) microsoft (DOT) com...I like your suggestion; but if it is not a managed DLL, would I need to do any .NET library initialization? I don't understand this question well, i.e: I'm not sure I understand what you mean by "do any .NET library initialization". |
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
| |