Reputation: 2099
I was given an wpf application written in Visual Studio 2013 and I need to run it..
When I build it, it runs perfectly but reaches the point where it calls the database. Unfortunately the database connection string is hardcoded. If I change it in the code the application rebuilds itself and then when I run before it even gets to the database it gives the following runtime error.
Private Shared Sub RunInDebugMode()
Dim bootstrapper As UnityBootstrapper = New Bootstrapper()
bootstrapper.Run()
End Sub
An unhandled exception of type 'Microsoft.Practices.Prism.Modularity.ModuleInitializeException' occurred in Microsoft.Practices.Prism.dll
Additional information: An exception occurred while initializing module 'Main'.
The exception message was: Activation error occurred while trying to get instance of type ModuleInit, key ""
Check the InnerException property of the exception for more information. If the exception occurred
while creating an object in a DI container, you can exception.GetRootException() to help locate the
root cause of the problem.
on bootstrapper.Run()
How can I make changes to the code if I can't rebuild it. It works on the client's machine. Works on my machine until I rebuild.
If I am in debug mode and skip over the line bootstrapper.Run()
the screen doesn't render so it doesn't help. Is there a way I can replace that one pesky line of code and not use it. It's seems to be part of Unity but it's so core to the code I can't figure out how to bypass it so I can just run the app.
Here is the project references to Unity
Take note I originally got the error
Error 35 The project currently contains references to more than one version of Microsoft.Practices.Unity, a direct reference to version 1.2.0.0 and an indirect reference (through 'Microsoft.Practices.Prism.UnityExtensions.UnityBootstrapper.Container') to version 2.1.505.0. Change the direct reference to use version 2.1.505.0 (or higher) of Microsoft.Practices.Unity. C:\MyProject\Shell\Bootstrapper.vb 24 33
I then changed the reference to 2.1.505.0 hence my original runtime error.Meaning Prism is not backward compatible. I've also tried v4 of Microsoft.Practices.Unity.dll, but I get the same error as v2.
I have not intention of deploying this site. I just need to change the hardcoded connection string and build it and run it to test how it works. However Prism monopolizes too much to exclude it and refuse to work whatever I try.
My main project only contains the following:
Is there a way I can bypass prism and skip my main project and just call the xaml files directly in the class library project instead by creating a new project?
Upvotes: 0
Views: 1165
Reputation:
This is a Prism application, and you cannot bypass the Bootstrapper.Run as it is core to the application. Obviously you have inherited an application you are unfamiliar with, so it will be even more difficult to help you find the issue. The exception you listed leads me to believe you have an issue with loading the modules of the application. Look in the bootstrapper class and look at the CreateModuleCatalog and see what kind of catalog it is using. If it is done with a configuration file (.xaml or .config) then there might be an issue finding the assemblies the catalog is looking for. Make sure the module assemblies are being copied to the correct location. You can also try rebuilding the solution, not just the setup project. If the module assemblies have a post build process to copy assemblies to a directory, then rebuilding the solution will copy modules properly and the app will run as expected.
Really hard to say without more information.
Upvotes: 2