Posts Tagged ‘exception’

Linq Exception(NullReferenceException): Object reference not set to an instance of an object

With NullReferenceException:

  1.  Dim obj As DemographicProperties = Me
  2.  
  3.         Dim m As IEnumerable(Of DemographicProperty) = From c In obj _
  4.                                                        Where (c.MapClass.MapClassID = MapClassID)  _
  5.                                                        Order By c.Name Ascending _
  6.                                                        Select c

If you are getting NullReferenceException, it means the MapClassID is null(nothing in vb.net)

Solve:

  1.  Dim obj As DemographicProperties = Me
  2.  
  3.         Dim m As IEnumerable(Of DemographicProperty) = From c In obj _
  4.                                                        Where ((Not c.MapClass Is Nothing) AndAlso (c.MapClass.MapClassID = MapClassID)) _
  5.                                                        Order By c.Name Ascending _
  6.                                                        Select c

, , ,

No Comments


Operand type clash: nvarchar(max) is incompatible with image

This error usually occurs when you are adding / updating a record on the database table with image/binary columns, and the value of that image column is null and you did not specify the data type of the parameter.

To resolve this issue you need to explicitly specify the datatype of that image/binary column because the default data type of the Sql parameter is varchar(string)

, , ,

No Comments


Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information


I’m currently developing an application that has a plugin style or loading of DLL dynamically. So this is how I did I have created 4 projects;

  1. Plugin Interface project (Class Library)
  2. Test Plugin project (Class Library)
  3. Consumer project (Class Library) – read and execute the plugins
  4. Windows Apps that uses/references the Consumer project

When I run the #4 project I get this error “Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information“, as I’m just a beginner and can’t find a solution out of my head so I did research on the web and seen lots of solutions and recommendations but none of them works.

Then I tried to have the project referenced from #1 project and you know what it works :) .

, , , ,

No Comments


Error 1001. Exception occurred while initializing the installation. System.IO.FileNotFoundException


This error occurs when the CustomActionData has a supplied value,

Example:

The value of the CustomActionData is /TARGETDIR=[TARGETDIR], what you need to do is to update it to /TARGETDIR=”[TARGETDIR]\”

, ,

No Comments


Specified cast is not valid in WriteXml using Dataset

This exception appears when using WriteXml of datatable or dataset. This is also caused by when you create a datatable manually and you set the “defaultvalue” to one or more datacolumn. Remove the “defaultvalue” and it will be fine.

For more information on setting defaultvalue click here

, , ,

No Comments


A Generic error occured in GDI+

Source Control:
If this exception occurred in DataGrid Control, check if the displayed data is large. This might be the caused of the exception.

, ,

No Comments


Create Custom Exception

To create a custom exception what you need to do is create a class that inherits from ApplicationException then implement the constructor of the class, see below on how to do it..

Public class MyException
Inherit ApplicationException

Public Sub New()
Mybase.New(“Your exception message here”)
End Sub

End Class

,

No Comments


Exception: Thread was being aborted

Try using flush method instead of end method of object.

Read Forum

, ,

No Comments


Conversion from type ‘DataRowView’ to type ‘Integer’ is not valid.

Conversion from type ‘DataRowView’ to type ‘Integer’ is not valid this will occur during binding the combo box by setting the datasource and you have a code to execute inside the combobox_SelectedIndexChanged Event that retrieves the selected value of the combo box.  The below script will give you  an exception error at the time of setting the datasource of the combobox

Private Sub ComboBox_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles cboDemographics.SelectedIndexChanged

Messagebox.show(cboDemographics.SelectedValue)

End Sub

to correct this you have to check the selectedValue

Private Sub ComboBox_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles cboDemographics.SelectedIndexChanged

If TypeOf cboDemographics.SelectedValue Is DataRowView Then
Exit Sub
End If
Messagebox.show(cboDemographics.SelectedValue)

End Sub

, ,

4 Comments


Not a legal OleAut date

Problem:
This exception will occur when reading/importing excel file using VB.NET and ADO.NET.

Solution:

Check the content of a column that are date type, make sure they don’t have an invalid values such as:

1/2009,  1–2009 and etc.

, , , ,

No Comments



SetPageWidth