I'm injecting a DLL into a pure C++ application. I'm basically replacing an old text editor with a much nicer version that supports syntax highlighting, intellisense, etc,.
My solution(Visual Studio), is setup like this.
ManagedLibrary (Houses a Form with the new text editor.) .LIB
Injector: .EXE
DLL: .DLL
The intended flow is this..
ManagedLibrary->DLL->TargetApp
The problem is, I can't seem to figure out how to call my managed library inside my DLL without making my DLL use \clr, and import all the .NET stuff, etc,.
So, how do I best go about doing this. I basically need to call the code necessary to launch a new instance of my Form inside my DLL, but without making my DLL a managed project. ?
What I want to do, is simply launch my managed Form from the DLL, without wreaking havok on my project.
Any ideas?
Win7
Visual Studio C++ 2010 Express
(I had to jump through serious hoops to make this much work, WPF\MFC is not supported in Express, and the new editor is a C# lib, and requires WPF, I ended up making a C# class library, creating a C# WPF UserControl, hosting my editor on that, hosting that on a C# Windows.Forms UserControl, and importing that into C++, which now resides on my C++ Windows Form. I only mention this in case it would make a difference somehow.)
------------
This is still unsolved, I've followed the advice below, created a C# .DLL with static exports, however, any attempt to actually use it, still the prompts the same "dllmain.cpp(4): fatal error C1190: managed targeted code requires a '/clr' option" errors that brought me here.
So, how do I go about properly using this, simply referencing the DLL prompts the CLR complaints, etc,. If I can't reference, how can I use it? I've tried creating a managed C++ .lib, telling it "#pragma unmanaged", and double wrapping, ie,..
C#:
public static void LaunchEditor()
{
TextEditor t = new TextEditor();
t.Show();
}
C++ .Lib (#pragma unmanaged)
void Launch()
{
NameSpace::LaunchEditor();
}
This didn't work either, so I don't get it..