Beginners problem - ViewModel does not seem to get loaded after deployment

Feb 29, 2012 at 11:07 AM

Hello,

I am currently developing a small WPF calendar application for event planning. The app is very simple, I only got my MainPage (+ViewModel) and a YearCalendarViewModel / View. The YearCalendarView is a control nested in the MainPage. I made use of the ViewModelLocator pattern as proposed in the Simple MVVM Toolkit. The data for the events come frome a WCF service that is hosted on our local server. The data the WCF service puts out is absolutely valid, no matter from which machine I retrieve it.

Yesterday I tried to deploy the program (first via Windows Installer, then via ClickOnce), but I found out soon that for some reason the ViewModel for the YearCalendarViewModel does not get loaded. I see my view with all the controls, but without the data from the ViewModel it is bound to. Having a look with Snoop, WPF tells me that it couldnt find the source to bind to. 

This only takes place when I have deployed my application. When I debug it in Visual Studio or start the EXE directly from the debug/release folder, it starts up perfectly and displays all the data just as it should.

 

Any idea what could trigger this behavior? :/ 

If any more information is needed, please advise.

Thanks!

Feb 29, 2012 at 11:40 AM
How are you connecinf to your database? If using integrated security, check if the app pool for your service has sufficient permissions.
Feb 29, 2012 at 1:19 PM

Hi Tony, thanks for your reply.

The WCF service connects to the SQL database per standard security. I added my WCF service per WebDeploy to the IIS server. Just to test it, I quickly assembled a test console program, I can access the service from all machines in the office. 

 

Furthermore, I added a simple MessageBox.Show("Test") on the very top of the initializer of the view model. The message box never shows up, so I guess the viewmodel is never loaded. All connections to the WCF service get called by the ServiceAgent of the YearCalendarViewModel. 

This one is really frustrating me, even more because my first steps into MVVM with your toolkit (and the actually working applications I've created .. ) were very pleasant! :) (with the simplemvvmtoolkit I was finally able to understand the pattern a bit better and produce some working code ..).

 

Feb 29, 2012 at 2:57 PM
Edited Feb 29, 2012 at 3:01 PM

OK, so you're using a connection string with a user name and password?  Probably not the best practice, but it should work. ;-)

Looks like a data binding problem.  Strange it only happens when you've deployed it.  I assume the installer must be doing something strange.  Are you able to run the app locally while connecting to your remote WCF service?

Feb 29, 2012 at 3:48 PM

Exactly, a simple user id and password. 

On my development machine I can start the app from my debug folder without any problems. It connects to the WCF service and displays the mock data I filled my database with. Adding new data works as well. 

With installation the program shows only the view, without loading the viewmodel. When I start my complied app on another PC without installation, it kindly reminds me that I'll have to add System.Windows.Interactivity.dll to the GAC before I can continue, and the app crashes. 

Is there any possibility to "debug" the readily compiled exe? 

I am sorry for my beginners questions and my soso knowledge of the English langauge ^^°

Feb 29, 2012 at 5:06 PM
Your installer is missing the assemblies for the Blend 4.0 SDK for WPF. Check #4 on the prerequisites page:
Feb 29, 2012 at 5:49 PM

I now added System.Windows.Interactivity and Microsoft.Expression.Interactions to the installer and to the GAC. 

Nevertheless, my problem persists :/

Feb 29, 2012 at 9:28 PM

I fixed it .. and I have to admit that im quite embarassed, not at least because it had absolutely nothing to do with the Simple MVVM Toolkit. 

Long story put short, in the end it comes to down to a faulty string of a local xml file .. 

Thanks for your godlike patience and thank you again for this great toolkit!