System::Object to Variant in mixed C++

Hi All!

I have a managed class-wrapper in C++ which calls a C# application and setups event delegates. Problem is in that I get System::Object objects from C# application, but erapper still needs to pass this objects to upper, unmanaged class as variant objects.

Here the short example:



bool CMClass::GetCurrentRowFieldValue(const CString& a_rsFieldName, _variant_t& a_rvtValue)
{
   try
   {
      System::Object* oValue;
      oValue = new System::Object();

      a_rvtValue.Clear();

      // Call the C# object.
      VARIANT_BOOL vbGet =  m_spManager->GetCurrentRowFieldValue(
            (PCTSTR)a_rsFieldName,
            &oValue);
      
      // ....

      // Here I have to convert oValue from Object to variant type and
      // assign result to a_rvtValue...

   }
   catch (const _com_error& a_rErr)
   {
      //...
   }
   return true;
}


 



Answer this question

System::Object to Variant in mixed C++