Tuesday, September 25, 2012

Lightswitch error ‘Exception has been thrown by the target of an invocation’

Problem

This error message popped up after the Lightswitch 2011 application was deployed on a new server and when the application was started for the first time. The default screen comes up, but without data in the screen, then the messagebox with the error:

An error occurred while running the screen.
Error details: Exception has been thrown by the target of an invocation.

image

After clicking ‘Close Screen’ a second messagebox pops up with the message:

Invalid operation. Dispatcher has been stopped.

image

The problem in this case is not as much correcting the error, but finding out what the error actually is. To do so we need to turn diagnostics on

DIAGNOSE

To diagnose this kind of error in Lightswitch, diagnostics needs to be enabled. See the MSDN article How to: Enable Diagnostics

Since this problem did not occur on my development computer, but after deployment on the new Windows Server, we can turn the diagnostics on in the server without redeploying the solution. Either way do not forget to switch diagnostics off on the server once the cause of the error has been found.

To enable diagnostics on the server

The diagnostics feature will generate a Trace.axd file in the directory where the app is deployed.

  • Use IIS Manager and connect remotely or log on to the server and start IIS Manager on the server.
  • In the Connections treeview, under <your server>/sites/Default Web site/<your app>
  • In the features view, click on Application Settings
    image
  • In the Application settings pane, change Microsoft.LightSwitch.Trace.Enabled to true,
  • Set …trace.Lavel to Error
  • Set …trace.LocalOnly to false. If you leave this to true then you can only browse on the server to localhost to look at the diagnostics, in my case security settings on the server browser did not allow me to do this. So when set to false I can browse the trace file from the client PC.
  • This is the Applications settings panel after applying the changesimage
  • On the client PC browse to the app to invoke the error once more.
    http://myserver/myapp
  • Then browse to the same URL with the trace file name appended http://myserver/myapp/Trace.axd
    image
  • The last line of the trace log most probably contains the error information (in my case it did). Click on the view details link to open.
    image
  • The error shows that there is a SQLconnection problem.

Solution

finally the solution was that the SQLserver could not be connected from the new app server unless the full domain name was used. I fixed the connection string in visual studio accordingly and all worked fine.

Lightswitch deployment error: MSDEPLOYAGENTSERVICE could not be contacted

Problem

For the first time deployment of a Lightswitch application on a windows 2008 server, I received the following error message in the Visual Studio Error message panel:

Web deployment task failed.(Remote agent (URL http://bebrqsql01/MSDEPLOYAGENTSERVICE) could not be contacted. Make sure the remote agent service is installed and started on the target computer.)

Remote agent (URL http://bebrqsql01/MSDEPLOYAGENTSERVICE) could not be contacted. Make sure the remote agent service is installed and started on the target computer.

The server is a windows 2008 R2 server with IIS services and with the Lightswitch 2011 prerequisites installed as described in Configure a server to host LightSwitch (Visual Studio 2010).

 

Solution

Log on to the target server, check if the Web Deployment Agent service is started, set it to start automatically . After first time Installation server feature IIS Web server role, this service will not have been started. Start the service

image

Another possible cause can be that the username specified in the Publish Output tab of the Lightswitch Publish Application Wizard, does not belong to the local administrators of the Application server. Solve this by adding the user, or the group that he is in, to the local Administrators group on the application server.

Sunday, September 23, 2012

How to update query parameters on Xtrareport

Question

When an Xtrareport report in a Lightswitch project is based upon a query with parameters and new parameters have been added to the query after the report was designed, how do you update the report parameters?

Explanation

In Visual studio in logical view, modify the query to add new parameters.

Save the query and rebuild the project.

Switch to file view

go to Server folder

open the report in design modus

Select the Lightswitch datasource

In the properties panel, Click on the link Update QueryParameters

image

The parameters are now added to the Query Parameter Collection. You can verify this by clicking on the Ellipsis button next to the (Collection) text to open the dialog box with the parameters from the query.

image

Tuesday, September 18, 2012

Out-of-browser Lightswitch app keeps on showing the update to new version page and refuses to start

Problem

At one site I have a Lightswitch out-of-browser app that has been upgraded quite a lot. On one of the pc’s the app detects the latest version and shows the upgrade message to the new version in the browser, but after upgrading and restarting the app it keeps showing the upgrade page requesting the user to make the same upgrade again. At first I thought that the user had not used this app for a while and that the app was being upgraded one version at a time. But the upgrade page was showing the latest version number.

Uninstalling the app via the add / remove feature in the control panel, did not help. The app was reinstalled after browsing to the URL of the app on the server, but even then the upgrade page kept showing up.

Solution

The solution was to remove the app from the Silverlight Application Storage.

In the Windows Start menu go to All Programs / Microsoft Silverlight / Microsoft Silverlight. The configuration window opens.

image

Select the Application Storage tab.

image

Select the URL of your application and click on the Delete… button. A confirmation window opens. Click on Yes to confirm.

image

The app is now deleted from the Application Storage.

Click on the OK button to close the Silverlight Configuration window.

Start the app again. It will show the upgrade window once more and after installation, the latest version should start (in my case anyway).

First time installation of SSDT for VS2012– sep 2012 update

Prerequisites: PC with Visual Studio 2010 with SP1.

Download SSDT setup from MSDN SQL Server Data Tools

After download has finished run SSDTSetup.exe

image

This takes a long while, , VS2010 starts (did I start this accidentally while doing other work or was it the installer?) Minimizing the installer window works, but maximizing again does not work; although it still seems to be active.

Result: An important prerequisite is the installation of SQL 2012 Standard or higher and not mentioned by the site. SQL Express is not sufficient.

since none of my customers are using SQL 2012 I did not install it either. To be continued.

Interesting article on fuzzy string searching

an interesting article about Fuzzy String Searching in sqlservercentral. Thanks to Thomas Keller.