Click here to Skip to main content
15,887,683 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am developing a WPF program in C#. I need to host external apps inside my application. I would also develop these external apps. These apps would only consists of one window. I would prefer hosting an exe file, but loading the xaml file with the code behind would also work. It should almost be like Windows. Hosting external exe files. But I will also develop these external programs. If that is not possible, loading the xaml files from these external apps would also work. I have tried this, using the Xamlreader, but I can't seem to load the cs file (code behind)

How can I achieve either one of these solutions?

Thanks in advance
Posted
Comments
Sergey Alexandrovich Kryukov 24-Oct-13 15:11pm    
Really, really, really bad idea. I would recommend to rethink your "I need to". Often, it's easier to create the code fully replacing the "external app" than "integrate" something which wasn't designed for that.
However, you can easily do it if your external application is console-only

<scratch>Is that the case? And are those "external apps" yours? do you have all the source code?
Oh, I see. "But I will also develop these external programs" completely resolve that problem. No way should you make them several application. Would make no sense, ever.

—SA
Henry Jooste 24-Oct-13 15:14pm    
Yes, the external apps are mine. I have access to the source code, but they are not console-only. I did some research and thought that I could maybe use Microsoft's Prism. Do you think it would work?
Sergey Alexandrovich Kryukov 24-Oct-13 15:16pm    
Sorry, I missed it. Then making then separate application make no sense at all, never.
I'll tell you exactly what to do, especially if you depict some functional requirements.
—SA
Henry Jooste 24-Oct-13 15:20pm    
I want to use external apps, because I could update these apps without changing the "main" program
Henry Jooste 24-Oct-13 15:30pm    
Its almost like an operating system. I have the main program (like the operating system). I don't wont to update this program each time I change the built-in apps. Therefore, creating the apps separate and hosting them in the "main" program would be much easier, since I would be able to update these apps without updating the "main" program. After doing some research, Im considering Microsoft's Prism. Do you think this could work? Thank you very much for all your help.

How I see, you need a pluginn architecture. Well, MEF and MAF are options for WPF too, bou you could consider also prism (http://compositewpf.codeplex.com[^])
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 25-Oct-13 0:28am    
Ah, I almost forget to mention MEF (I know only this one, from those you listed). My 5. However, it does not look flexible and convenient enough to me. I really like my own extremely light-weight and flexible, low-ceremony approach a lot more...
—SA
So, if you develop "external applications" by yourself, I think, this is settled: no external applications, ever. Not a chance.

You need to develop external units as class-library assemblies which should implement some plug-in interface(s). Your host application should load all (candidate) assemblies, check up if they really implement the interface(s) and use it. If the plug-in suggests running of some processing scenario which take any noticeable time, it should be executed in a separate thread. This is all very easy if you don't have to unload the plug-ins during runtime. If you need to load then, unload and load again, repetitively, it would more then double the difficulty of development, so better avoid this requirement.

You can find all what's involved in my past answers:
Gathering types from assemblies by it's string representation[^],
C# Reflection InvokeMember on existing instance[^],
Dynamically Load User Controls[^],
code generating using CodeDom[^],
AppDomain refuses to load an assembly[^],
AppDomain refuses to load an assembly[^].

—SA
 
Share this answer
 
Comments
Henry Jooste 25-Oct-13 0:22am    
I would definitely check out those links. Thank you very much for all your help. I really appreciate it.
Sergey Alexandrovich Kryukov 25-Oct-13 0:25am    
You are very welcome.
Good luck, call again.
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900