Calling C# code from C++, but ExecuteInDefaultAppDomain() is too limited

There are several ways for a C++ application to invoke functions in a C# DLL. Using C++/CLI as an intermediate DLL http://blogs.microsoft.co.il/sasha/2008/02/16/net-to-c-bridge/ Reverse P/Invoke http://tigerang.blogspot.ca/2008/09/reverse-pinvoke.html http://blogs.msdn.com/b/junfeng/archive/2008/01/28/reverse-p-invoke-and-exception.aspx Using COM http://msdn.microsoft.com/en-us/library/zsfww439.aspx Using CLR Hosting (ICLRRuntimeHost::ExecuteInDefaultAppDomain()) http://msdn.microsoft.com/en-us/library/dd380850%28v=vs.110%29.aspx http://msdn.microsoft.com/en-us/library/ms164411%28v=vs.110%29.aspx https://stackoverflow.com/a/4283104/184528 Interprocess communication (IPC) How to remote invoke another process method from C# application http://www.codeproject.com/Tips/420582/Inter-Process-Communication-between-Csharp-and-Cpl Edit: Host a HTTP server … Read more

C++/CLI: why should I use it?

Yes, C++/CLI has a very specific target usage, the language (and its compiler, most of all) makes it very easy to write code that needs to interop with unmanaged code. It has built-in support for marshaling between managed and unmanaged types. It used to be called IJW (It Just Works), nowadays called C++ Interop. Other … Read more

How to call a C# library from Native C++ (using C++\CLI and IJW)

You can do this fairly easily. Create an .h/.cpp combo Enable /clr on the newly create .cpp file. (CPP -> Right click -> Properties) Set the search path for “additional #using directories” to point towards your C# dll. Native.h void NativeWrapMethod(); Native.cpp #using <mscorlib.dll> #using <MyNet.dll> using namespace MyNetNameSpace; void NativeWrapMethod() { MyNetNameSpace::MyManagedClass::Method(); // static … Read more

Why C# is not allowing non-member functions like C++

See this blog posting: http://blogs.msdn.com/ericlippert/archive/2009/06/22/why-doesn-t-c-implement-top-level-methods.aspx (…) I am asked “why doesn’t C# implement feature X?” all the time. The answer is always the same: because no one ever designed, specified, implemented, tested, documented and shipped that feature. All six of those things are necessary to make a feature happen. All of them cost huge amounts … Read more

How can I make my managed NuGet package support C++/CLI projects?

As Patrick O’Hara wrote, NuGet will not make changes to a C++/CLI project for you. See GitHub Issue NuGet/Home#1121 – Cannot install managed packages into a CLI project. However, using the NuGet command line utility, NuGet.exe, you can have NuGet download and unpack the desired package(s). For a complete example, here were steps that I … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)