0

I am Window application developer. I have a C++ library and want to write C# API for this C++ library. I guess I can write COM library by wrapper around this C++ library. But I am not sure if COM library is a language independence. I also heard that .NET framework provide a language independence environment by re-compiling my library to an intermediate code. But I am not quite sure how to do it in .NET.

Since I am quite new in this area, please advice me any resource or technology that I can take a look. Thank you!

5
  • 1
    Voted to close - Questions on SO should be geared towards finding a specific solution to a specific problem. Your question is not a good match for that format. Commented Mar 3, 2012 at 3:25
  • i suppose i attempted to answer the question already...but it seems like his question is how to consume the C++ library from C#? Commented Mar 3, 2012 at 3:27
  • @NadirMuzaffar - That question doesn't have a specific answer without a predefined context. The question in general shows lack of research if nothing else. Commented Mar 3, 2012 at 3:29
  • @Unagi, Without the reason why you want to do that it is hard to give you useful info - so voting to close. Search for PInvoke and see if it what you actually asking for bing.com/search?q=c%23+pinvoke. Commented Mar 3, 2012 at 3:31
  • Hi, just curious, why did you guys want to vote to close? I am just asking if anyone happens to know any specific technology that will allow me to use C++ library from C#. I know COM might be a potential candidate. But I am seeking for alternative solution before I start coding. I don't mind closing my question if this causes any confusion. Thanks. Commented Mar 3, 2012 at 11:04

1 Answer 1

1

COM is exactly for language independence. It's main intent is seperation of interface from implementation. You will very likely have to write a COM interface to wrap the C++ library which can then be consumed by C#.

But COM is also a fairly complex as a concept to understand and then properly use. Depending on the size of the library, it might even be faster to rewrite the C++ library as a C# library, then to learn COM and then expose the C++ library through it.

Sign up to request clarification or add additional context in comments.

1 Comment

I just felt that COM can be slow since this library is a real-time News feed. Your previous answer is useful since I can now find a potential solution from the MSDN site: msdn.microsoft.com/en-us/magazine/cc164123.aspx. Thanks again.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.