none
C++ call C# works with dot net 4 but not with dot net 3.5 RRS feed

  • Question

  • Encountered a strange behavior. With the following code.
    DropTarget.cpp
            logit(_T("pre DropTarget::OnDrop m_EmailContent->FillByFileDrop"));
            this->m_EmailContent->FillByFileDrop(fileName.AllocSysString(), &result);
            logit(_T("pre DropTarget::OnDrop m_Parent->OnEmailDropped(result)"));
    EmailContent.cs
            public int FillByFileDrop(string fileName)
            {
                //MessageBox.Show("FillByFileDrop");
                logit("FillByFileDrop");

    when targeting dotnet 4 the following is logged (The FillByFileDrop indicates that the C# code is executed)
    pre DropTarget::OnDrop m_EmailContent->FillByFileDrop
    FillByFileDrop
    pre DropTarget::OnDrop m_Parent->OnEmailDropped(result)

    when targeting dotnet 3.5 the following is logged, (FillByFileDrop is skipped even though it is the same code)
    pre DropTarget::OnDrop m_EmailContent->FillByFileDrop
    pre DropTarget::OnDrop m_Parent->OnEmailDropped(result)
    Saturday, May 14, 2011 8:41 AM

All replies

  • What style you used to call C# code from C++? is it a C++/CLI project? does the logit method invoke any C# methods?
    Eric Yang [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Thursday, May 19, 2011 2:48 AM
  • Have identify the cause to be a lotus COM that was called later in the execution sequence. For some reason, the runtime decides no to run the entire function. logit("FillByFileDrop"); runs when the lotus COM is commented out.

     

    In any case,we have switch to OLE.

     

    Thanks,

     

     

    Wednesday, May 25, 2011 5:46 AM