none
Returning collection of datasets.from managed C++ to C# RRS feed

  • Question

  • Hi All

    I was developing C++/Cli library to use C++ third party library  in my C# application.I wrote a method to retrive the collection of datasets from

    CLI library to C#.

     

    The method exposed from CLI library is    void Query(List<Dictionary<int ,String^>^>^  %data);

    here i am using reference type in List. is it good to use reference types than value types in List?

    since it is a reference type the memory will be handled by gc. Does it affects my list when i am reading

    it in C# application. When GC will free the memory in this case?

     

    Thanks& Regards

    Sukumar

    • Moved by Leo Liu - MSFT Tuesday, July 12, 2011 8:07 AM Moved for better support. (From:Visual C# General)
    Saturday, July 9, 2011 9:26 AM

Answers

  •  

    Hi Sukumar,

     

    It is OK to use reference types in a generic list. Actually, we usually use List<T> to contain some reference types.

    In your case, we need to Marshal a managed memory to the generic list, then pass it to unmanaged code. It is OK, just remember to Free the allocated memory so that it would be reclaimed.

     

    Have a nice day.


    Paul Zhou [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.

    • Marked as answer by Paul Zhou Monday, July 18, 2011 9:45 AM
    Tuesday, July 12, 2011 9:48 AM

All replies

  • Hi SukumarNellore,

    I am moving your thread into the Common Language Runtime Forum for specialized support.
    Thanks.

    Have a nice day,
    Leo Liu [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.

    Tuesday, July 12, 2011 8:06 AM
  •  

    Hi Sukumar,

     

    It is OK to use reference types in a generic list. Actually, we usually use List<T> to contain some reference types.

    In your case, we need to Marshal a managed memory to the generic list, then pass it to unmanaged code. It is OK, just remember to Free the allocated memory so that it would be reclaimed.

     

    Have a nice day.


    Paul Zhou [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.

    • Marked as answer by Paul Zhou Monday, July 18, 2011 9:45 AM
    Tuesday, July 12, 2011 9:48 AM