can i call C# dll in C++ program ?-Collection of common programming errors

Well if you are using a native C++ program then I want to question why you want to use things from System.Windows. Esentially System.Windows is a subset of what is exposed through the Win32 API. Whats more, if you want to use System.Windows then you should just create a managed application to start off with. It will be a lot less fiddly and the potential problems are not worth the effort that you would put into the interop work.Whats more, if you are using System.Windows from a native application then the constant managed/unmanaged transitions will make the application run a lot slower than if you made it purely native or managed.If you want a framework for GUI applications in a native application then look either at MFC or QT.

If you are trying to get access to a third party library written in a .net language though then you have an option which is actually a lot neater than the above post. You can create a native wrapper class. If you create a DLL to host this wrapper so you don’t have to build your main project with /clr then it will make things easier on you. You can then use gcroot to hold the managed class reference and things will go from there.

@Lim Bio LiongBe careful with that, CLR hosting is a bit confusing but it probably doesn’t work as you think it does.The first thing to remember is the .Net framework version of the CLR will load into a pure native process the first time managed code is called even without an explicit hosting environment. Executables with a managed header actually load the CLR up right away to stop the hit of the CLR loading in at runtime. What CLR hosting actually is, is a way to control and get notifications from the CLR while it is running. So it gives you a chance to hook into it to get information or control behaviour, that is all.

If you create a native application and a mixed mode dll and use LoadLibrary/GetProcAddress to call a managed function from the DLL, you will notice that it will load the CLR in as soon as the managed code is executed.