CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Nov 2006
    Posts
    103

    Using C++ code in a C# project.

    I have a curve fitting algorithm in templated C++ and I want to use it in my C# project.

    I need to figure out what I need to do to use this code without translating it into C#.

    I'm told I could make a component out of it, but I don't know how.
    I was told something about 'unsafe' code... don't know how...
    Help?

  2. #2
    Join Date
    Aug 2005
    Location
    Seattle, Wa
    Posts
    179

    Re: Using C++ code in a C# project.

    Create a DLL project in C++ that contains your method(s).

    Use DLLImport to call your methods from your C# code.

    Example here:
    http://www.codeguru.com/csharp/cshar...cle.php/c4217/

  3. #3
    Join Date
    Nov 2006
    Posts
    103

    Re: Using C++ code in a C# project.

    Ok thats a good starting point.
    I need to pass an array of floats to the dll and I'm really not sure what C# is passing and what C++ is receiving...

  4. #4
    Join Date
    Sep 2004
    Posts
    1,361

    Re: Using C++ code in a C# project.

    If the algorithm really complicated? If not, why not just re-write it in C#?

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