The problem is just that you have to have the compiler (and linker) with your application, because, in case of unmanaged C++, you cannot guarantee there is a compiler in the system, forget about the problem of finding this compiler and its invocation. I don't think you really want to deal with that, unless you want to use some compiler with its source code, so you could embed it in your application.
With .NET, the story is very different, as C# and VB.NET compilers are always bound with the redistributable .NET Framework and are always available (but not C++!). Then the problem is solved via CodeDOM (and Application Domains, which is mode difficult part of the problem). If you are interested, I can give you some links.
[EDIT — after OP's clarification]
Thank you for clarification. Please see my past answers:
code generating using CodeDom[
^],
Create WPF Application that uses Reloadable Plugins...[
^].
Some more advanced issues are explained in my past answers:
Create WPF Application that uses Reloadable Plugins...[
^],
AppDomain refuses to load an assembly[
^],
Dynamically Load User Controls[
^],
C# Reflection InvokeMember on existing instance[
^],
Gathering types from assemblies by it's string representation[
^].
—SA