CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Sep 2004
    Posts
    561

    [RESOLVED] Calling C# function w/out param doesn't work

    I have a C# function
    Code:
    SomeFunction(out MyObject obj)
    When I call this function from Managed C++

    Code:
    MyObject ^mObj = nullptr;
    SomeFunction(mObj);

    After "SomeFunction" is called mObj is still equal to null.
    I have verified in the debugger that SomeFunction retrieves the object properly so it shouldn't be null.
    How come and how do I fix this?

    Thanks!

  2. #2
    Join Date
    Sep 2004
    Posts
    561

    Re: Calling C# function w/out param doesn't work

    I found the problem... actually my example above wasn't entirely accurate.

    "SomeFunction" takes an interface as a parameter, not an object.

    This code works below:
    Code:
    IMyObject ^myIntfObject = nullptr;
    SomeFunction(myIntfObject);
    MyObject ^myObj = (MyObject^)myIntfObject;

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured