I have an app that works fine when being debugged locally. But it has a strange issue when deployed as a Cloud Service to Azure. I have two Silverlight grid controls on the page which display a red x and give the error, "Unable to load data. Please check your network connection and try loading again."
Several other queries are running on this page and correctly pull data from other tables in the database. The queries that run correctly are tied to label or text box controls.
The queries that fail, return an HTTP Status code 500 (Internal error). If I try and pass the query to a constructor as an IVisualCollection
, and I wrap the call in a Try
block, the Inner Exception is "Object reference not set to an instance of an object." So, a Null Reference Exception. Checking for null before the constructor call and popping up a message box if the query was null as a means of debugging yielded nothing.
Try
'Check for nulls
If (Me.qQuoteByFirm Is Nothing) Then
Me.ShowMessageBox("qQuoteByFirm", "Error", MessageBoxOption.Ok)
End If
If (Me.qQuoteByFirm.Screen Is Nothing) Then
Me.ShowMessageBox("Screen", "Error", MessageBoxOption.Ok)
End If
If (New ModalWindowHelper(Me.qQuoteByFirm, "mwAddQuote", "Quote") Is Nothing) Then
Me.ShowMessageBox("Modal", "Error", MessageBoxOption.Ok)
End If
'Create helper
Me.HelperAddQuote = New ModalWindowHelper(Me.qQuoteByFirm, "mwAddQuote", "Quote")
Catch ex As Exception
Dim err As String = ""
For Each item In ex.Data
err = err & item.ToString()
Next
err = err & ex.InnerException.ToString() & vbCrLf & _
ex.Message.ToString() & vbCrLf & _
ex.StackTrace
Me.ShowMessageBox(err, "Error", MessageBoxOption.Ok)
End Try
Public Sub New(ByVal visualCollection As IVisualCollection, _
ByVal dialogName As String, _
Optional entityName As String = "")
_collection = visualCollection
_dialogName = dialogName
_entityName = If(entityName <> "", entityName, _collection.Details.GetModel.ElementType.Name)
_screen = _collection.Screen
End Sub
The actual construction of the queries does not seem to matter. I've tried several variations along with requesting the entire table. Same result. However, this only occurs on two specific tables. Grid controls displaying other tables on other screens work properly.
Here's the weird part. If I comment out the call to the constructor, I can gain access to the gird control and add data to it even through the red box remains. If I refresh the grid control, the data disappears as if it wasn't saved or isn't there. But inspecting the table in SQL Azure Management Portal shows that the data was properly populated in the table.
The app and the database are clearly connected and able to communicate fine. So why when reading from these two tables (but not writing to) are my grid controls throwing exceptions? Why does this only happen when deployed? What other techniques can I use to get more information?