Starting a PRISM WPF application from another application

Topics: Prism v4 - WPF 4
Jun 3, 2013 at 3:01 PM
I have a PRISM WPF application which loads multiple modules when it is starting.
This application starts when started alone by itself.

Now I need to start this application from another .NET 3.5 Windows Forms Application.
When I do this using Process.Start, I get an error saying that one of the modules did not load.

Should I modify the code below somehow?
ProcessStartInfo pInfo = new ProcessStartInfo();
pInfo.FileName = @"C:\Program Files (x86)\App\App.exe";
Process p = Process.Start(pInfo);
p.WaitForInputIdle(5000);
if(p.Responding)
{
// Write code
}
Jun 3, 2013 at 6:30 PM
Hi,

I tried to reproduce your error, but for me is working fine in .NET 3.5 of Windows Forms Application using the HelloWorld Quickstart as my Prism application. Therefore, it would be useful if you can provide us more information about how you are loading your modules (e.g. if you are using Module Catalog, or have a strong reference to the modules, etc.).

Regards,

Federico Martinez
http://blogs.southworks.net/fmartinez
Jun 3, 2013 at 9:15 PM
Thanks for trying out my scenario.

App.exe which is the Shell loads 10 modules using the Module Catalog. There is a splash screen which is visible till all the modules are loaded.
Once all modules are loaded the splash screen disappears and the start screen is visible.
Jun 3, 2013 at 11:18 PM
Hi!

Any special in the not-loaded module?
All the other modules are loaded?

I guess it is not a problem with your launching code.
Jun 4, 2013 at 9:06 AM
It is a "language module" which is responsible for languages in the App which is not loading.

When all modules are loaded the installer language is set by the "language module" with the help of a command which is subscribed to by every module.
Developer
Jun 4, 2013 at 9:20 PM
Hi,

It could be useful if you could provide us with more information about the error you are receiving, for example the stack trace, inner exceptions, messages, etc, that could help us find the cause behind the error.

Also, it could also be useful to know if you are using MEF or Unity as the container in your application.

What's more, does your main application and the Prism application reside in different folders? If so, the cause of the exception could be that the Prism application may no be able to locate some module files; or the modules can be found but they might not be able to load some assemblies they require.

Thanks,

Damian Cherubini
http://blogs.southworks.net/dcherubini
Jun 5, 2013 at 10:11 AM
The problem was solved when I set the working directory:
pInfo.WorkingDirectory = @"C:\Program Files (x86)\App\";

Thanks for the interest.

More info:
  • I am using MEF
  • Yes, the calling App was in a different location than the PRISM App
Mar 20, 2014 at 3:53 PM
Hi,

I struck with the similar problem friends. Please help me.
I have a Wpf prism application. I made it as a Class library so that I am able to generate a dll for this Prism application.
Now I want to use this DLL in another Windows Application, and launch that application from windows form.

As we know that the launching process of Prism App is different.

How can i launch Prism App (Shell or Home Screen) from Windows form...?

Thanks,
Srini.
Mar 20, 2014 at 5:08 PM
Hi Srini,

I don't completely understand the scenario you are describing. What would be the reason that you need a Prism App gets executed into a Windows Form application.
Are you planning to perform an scheduler for running the Prism App, or would you run the Prism app as an Application's Plugin for example?

It could be useful to know how the Windows Form application would run and why it would be necessary to embedded the Prism App.

Regards.

Gabriel Ostrowsky.
https://blogs.southworks.net/gostrowsky
Mar 21, 2014 at 7:56 AM
Edited Mar 21, 2014 at 7:59 AM
Hi Gabriel,

Thanks for your reply.

Basically the scenario is, We already have a one old Windows Application at our client location. Now we need to put one button on the existing winforms and then from there i need to laucnh my PRISM APP.

In my project's initial stage, I thought its just like a separate executable. So that I developed my application in that way.


But recently i came to know that, if it is a seaprate executable, I need to do lot of work to move to QC environment .
(Because of my work Environment's standards and policies)

If i made it as a DLL it will easy to maintain in the QC Environment. So that the management decided that it should be as a DLL.

If my Prism APP is an executable i can launch this executable by using PROCESS concept from my Win Form. i have already done with this.

But Now, my Prism application is a DLL. So how can i launch my Prism App on button click event of WIN FORM now...?

I hope you can understand the scenario. Please be patient with me. -:)

Thanks,
Srini
Mar 26, 2014 at 8:22 PM
Hello Srini,


It seems to be a known issue on this scenario of loading a Prism App from Windows Form. You may find useful the following discussion site for troubleshooting the known issue:

Then, after changing the RegionManager's IsInDesignMode() method from the Prism Library, you would need to call the Bootstrapper's Run() method from your ButtonClick event handler. The Bootstrapper would create the Prism Shell instance and load the Container and every Module of the App. Therefore, you would just need to show the Shell from the Bootstrapper's InitializeShell() as follows:
protected override void InitializeShell()
{
     base.InitializeShell();
     ((Window)this.Shell).Show();
}
I hope this helped,
Regards.

Gabriel Ostrowsky
http://blogs.southworks.net/gostrowsky