Question

I have a mixed mode assembly, built with the /clr option. I am trying to export a class from it, for consumption by another mixed mode assembly, also built with the /clr option.

My problem is that the signature of the method contains a mixture of managed and unmanaged types. For instance:

static System::String ^Convert( const CString from );

Initially, I tried to use __declspec(dllexport) on the non-ref class implementing this. This failed with error C3395: __declspec(dllexport) cannot be applied to a function with the __clrcall calling convention, presumably, because of the managed type in the signature. My next take was to make the class a ref class instead. Now the assembly builds and Reflector displays the exported method like so:

public static unsafe string Convert(CStringT<wchar_t,ATL::StrTraitATL<wchar_t,ATL::ChTraitsCRT<wchar_t> > > modopt(IsConst) modreq(IsCopyConstructed)* from);

However, in the client assembly, I fail to be able to reference the exported method ...

CString atlString("test");
AtlCStringConverter::Convert( atlString );

... yields the error C2039: 'Convert' : is not a member of 'XXX::AtlCStringConverter'. I've checked for obvious mistakes like mixing different char types that might cause the signature to not be matched.

I realize that neither of these export attempts are really kosher in that a mixture of managed/unmanaged types are exposed side by side in the signature, but since this mixture of managed/unmanaged is fine within a mixed mode assembly, I was wondering if there is no way to export types using this mixture of types in the signature between mixed mode DLLs?

Was it helpful?
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top