I am writing a simple application in WinRT and would like the C ++ bit to do some processing. I want to be able to pass a null value if the function ignores the parameter, since an empty string means something, as well as a value.
My C # code:
UnsafeNativeMethods.TestString(null);
My C ++ code:
void UnsafeNativeMethods::TestString(String^ test) { }
I keep getting a NullReferenceException in System.StubHelpers.HStringMarshaler.ConvertToNativeReference .
Is there a way to pass null to this method?
CHANGE AGAIN
That's all I have:
public ref class UnsafeNativeMethods sealed { public: static void TestString(Platform::String^ test); };
I just created a new application for Windows Phone 8, and this is the complete exception:
System.ArgumentNullException: Value cannot be null. at System.StubHelpers.HStringMarshaler.ConvertToNativeReference(String managed, HSTRING_HEADER* hstringHeader) at WindowsPhoneRuntimeComponent1.UnsafeNativeMethods.TestString(String test) at PhoneApp2.MainPage..ctor()
In any case, there is no fancy code, only the code above and a completely new project (C # WP8 application and Runtime WP component project)
source share