> Seemed like it had to do with that I declared the functions as
>
[quoted text clipped - 3 lines]
> in
> C# even though it is in C++
a C# ref or out parameter must be declared in C++/CLI as a reference
parameter.
>> The C# app:
>>
[quoted text clipped - 5 lines]
>> ref int[] devices_ids,
>> Int32 encoder_id);
Don't do this. To use C++/CLI functions from C#, add a reference to the
generated DLL.
>> [DllImport(g_wrapper_dll_path)]
>> static extern string GetLastError(
[quoted text clipped - 24 lines]
>> return Impl::Initialize(
>> (DVP1412DLL*) class_ptr, //ERROR 2 BELOW
Should be class_ptr->ToPointer(), but see below...
>> devices_ids,
>> encoder_id);
>> }
The compiler shouldn't even allow what you're doing... you have managed
types as parameters, and those are limited to member methods of managed
types. Create a ref class and make these functions static methods within
that class. Or, make them instance methods, so you don't have to pass
around class_ptr.
You're also missing a level of indirection all over the place here. You
want Impl::Initialize to fill in the pointer, right?
Then:
int Initialize( System::IntPtr% class_ptr, array<int>^ devices_ids, int
encoder_id)
{
DVP1412DLL objectPointer;
int retval = Impl::Initialize(&objectPointer, devices_ids, encoder_id);
class_ptr = gcnew System::IntPtr(objectPointer);
return retval;
}
>> Error 2 error C2440: 'type cast' : cannot convert from 'System::IntPtr'
>> to
[quoted text clipped - 23 lines]
>> >
>> > Mattias