Library tutorials & articles
High-Performance .NET Application Development & Architecture
- Introduction
- Planning
- Application/Server Security
- IIS Security
- Web.Config or ASP.NET Security
- ADO.NET Security
- Code Security
- General .NET Best Practices
- Directory Structure
- Presentation / Business Layer
- Data Access Layer
- Common ADO.NET Scenarios
- Error Trapping & Handling
- Debugging
- Tracing
- Common .NET Errors
- Performance Testing
- Conclusion
Common .NET Errors
-
CS0019: Operator '&' cannot be applied to operands of type 'type' and 'type'
This happens when you are trying to use the wrong operator for the specific operation.
- CS0029: Cannot implicitly convert type 'object' to 'string'
-
CS0103: The name 'whatever' does not exist in the class or namespace / CS0246: The type or namespace name 'whatever' could not be found (are you missing a using directive or an assembly reference?)
This will usually occur when you have not declared a variable globally and or it's missing altogether. CS0246 error also occurs when you are improperly declaring a object or variable, as well as it not existing in your code.
- CS0117: 'object' does not contain a definition for 'Length'
This error occurs when you are typically trying to present an object as a string. The solution here is to append ".ToString()," that now represents the object as a string.
-
CS0118: 'System.Configuration.ConfigurationSettings.AppSettings' denotes a 'property' where a 'method' was expected
This error occurs when your AppSettings key is accessed with parentheses in VB, instead of brackets in C# or vice-versa.
-
CS0119: 'whatever' denotes a 'class' which is not valid in the given context
One cause of this error is to improperly call an object without the "new" keyword in C# and "As New" in VB
- Object reference not set to an instance of an object
Again this has to do with improperly trying to convert a value. To remedy this properly cast or box the value in question.
This runtime error is more often than not caused by your code trying to reference an object that is not available, and for the most part you've probably closed the object or set it to null or nothing somewhere in your code in all valiant attempts to clean up any unnecessary objects from memory. For example, a connection object you've opened and used, but now somewhere you've closed it and set it to nothing, and somewhere after in the code it's being called again and when it does you'll get this error. Find and delete the line and close and null your object later on. Notwithstanding, this runtime error will also occur in the circumstances shown above in CS0119.
-
CS0161: 'method name': not all code paths return a value
This will happen when you are trying to make a function method behave like a subroutine or vice-versa. Use the proper method keyword to remedy this. Void is for methods that do not return a value, although you could response write the output. Whereas, applying a keyword value like string, int, works alongside a return value at the end of the method.
- CS0201: Only assignment, call, increment, decrement, and new object expressions can be used as a statement
- If you call an object that requires parentheses () after the command, you'll get this error. Ex. database.Open() not database.Open
- Using an assignment operator as opposes to an equality operator
-
CS1001: Identifier expected / BC30183: Keyword is not valid as an identifier.
Both these similar errors occur when you forget to identify a variable without a keyword, or you were inadvertently forcing a keyword to behave as a variable or type.
- BC30451: Name 'whatever' is not declared.
This error is produced by a number of sources.
-
BC30512: Option Strict On disallows implicit conversions from 'type' to 'type'.
Improper type conversions produce this error. Convert the value or method to the proper cast to fix this.
-
BC30554/BC30560: 'object' is ambiguous.
This error occurs when you have more than one similarly named dll in your bin folder when compiling or it matched your control inherits call. Furthermore, more than one dll root namespace or class within are named the same. Your page or control are trying to access one source file where a source file and dll may simultaneously exist.
- BC30574: Option Strict On disallows late binding
This happens when you are referencing a web form control or variable that either doesn't exist or is named different. Also by chance the control in question may be missing the mandatory runat="server" option.
- Not setting the object's proper data type
- An expression that binds data was incorrectly parsed against the object at runtime In Datagrids, for instance, this occurs when omitting the DataBinder.Eval method on a data field
This can happen from any number of reasons in your code. Some common ones are:
- BC30684: 'name' is a type and cannot be used as an expression
This can happen usually when you forget to use the new keyword when instantiating an object or invoking a constructor.
Related articles
Related discussion
-
An Introduction to VB.NET and Database Programming
by yen (12 replies)
-
Compatibility Issue on Firefox to display on Cursor Location
by ansari.wajid (0 replies)
-
VB.NET Type 'SqlDatabaseException' not defined
by Mulish Mehdi (1 replies)
-
Using ADO.NET with SQL Server
by jkoder59 (19 replies)
-
String was not recognized as a valid DateTime.
by buvanasubi (22 replies)
Related podcasts
-
A Practical Look at Silverlight 2 Part 1
Now that Silverlight 2 is at the Olympics and making a big splash, we wanted to explore this fascinating technology more. Microsoft Silverlight 2 is a cross-browser, cross-platform, and cross-device plug-in for delivering the next generation of .NET based media experiences and rich interactive ap...
Related jobs
-
Microsoft .Net Architect
in AMSTERDAM (€50K-€90K per annum) -
.net developer
in Rijswijk (€2K-€4K per annum)
Events coming up
-
Dec
6
Developing AJAX Web Applications with Castle Monorail
London, United Kingdom
Monorail is the model-view-controller engine of the Castle Project, bringing many of the best ideas of Ruby on Rails to the .NET world. In this talk, David De Florinier and Gojko Adzic show how Monorail makes it easy to develop .NET based AJAX applications, and how to use the Castle Project to build Web 2.0 applications effectively. Come to this session if you are a .NET web developer. Everyone is welcome!
Comments
Leave a comment
Sign in or Join us (it's free).