Posts Tagged ‘exception’
Linq Exception(NullReferenceException): Object reference not set to an instance of an object
Posted by: admin in Linq, Linq Exceptions, Linq To Object on September 24th, 2010
With NullReferenceException:
-
Dim obj As DemographicProperties = Me
-
-
Dim m As IEnumerable(Of DemographicProperty) = From c In obj _
-
Where (c.MapClass.MapClassID = MapClassID) _
-
Order By c.Name Ascending _
-
Select c
If you are getting NullReferenceException, it means the MapClassID is null(nothing in vb.net)
Solve:
-
Dim obj As DemographicProperties = Me
-
-
Dim m As IEnumerable(Of DemographicProperty) = From c In obj _
-
Where ((Not c.MapClass Is Nothing) AndAlso (c.MapClass.MapClassID = MapClassID)) _
-
Order By c.Name Ascending _
-
Select c
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)
Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information
Posted by: admin in Reflection on July 20th, 2010
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;
- Plugin Interface project (Class Library)
- Test Plugin project (Class Library)
- Consumer project (Class Library) – read and execute the plugins
- 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
.
Error 1001. Exception occurred while initializing the installation. System.IO.FileNotFoundException
Posted by: admin in .NET, Deployment, Exception on June 22nd, 2010
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]\”
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
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.
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
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
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.