ASP.NET compilation performs common errors and summary of solutions

  • 2020-05-16 06:45:04
  • OfStack

1. The value Request.Form has been detected as potentially dangerous
The reason:
(1) the properties of validateRequest are not set correctly in the page of data submission or in webconfig
(2) there are two in HTML < form > cause
Solution:
Option 1: add this sentence to the header of the.aspx file: < %@ Page validateRequest="false" % >
Option 2: modify the web.config file:
< configuration >
< system.web >
< pages validateRequest="false" / >
< /system.web >
< /configuration >
Because validateRequest defaults to true. Just set it to false.

2. "invalid read attempts when no data is available" solution

The reason:
The returned sqldatareader has no records, but no record processing. It returns a null value
Add judgment: if (reader.read ()) {TextName.Text =
reader [r]. "FieldName ToString (); }

3. The data is empty. This method or property cannot be called on a null value.

The reason:
If the object is null, then the method that calls the object, such as ToString(), must be wrong
Data controls such as grideview often appear
Solution: therefore, it is recommended to deal with NULL

4. The FieldCount attempt was invalid when the reader was closed

The reason:
After using SqlDataReader to bind data, connection objects are Close() processed
similar
public SqlDataReader GetSomething ()
{
conn. open ();
SqlDataReader reader =
sqlcmd. ExcecutReader (CommandBehavior. CloseConnection));
conn. close (); / / occur error here
return reader;
}
This method is called at bind time to specify the data source. If you use this method, you need to close Re in the calling function
ader so that conn can be turned off automatically.
If you are using SqlDataAdapter and DataSet, remove the call to explicitly close conn. Or in finally
Call it in.

5. Failed to map the path

Reason: it may be caused by incorrect path configuration in webconfig, which is a prominent problem in the configuration of FCKEditor
< add key="FCKeditor:BasePath" value="~/admin/fckeditor/"/ >
< add key="FCKeditor:UserFilesPath" value="/UserFiles/" / >

6.Unreachable code detected

The reason:
Generally speaking, throw or return are used in exception handling or return value, which may be placed in the front, causing the subsequent code to be executed.
Solution:
Place the statement for which the associated exception is thrown (throw) or the statement for return on the last line of agent execution.

7. Index out of range. Must be non-negative and smaller than the set size

The reason:
(1). DATAKEYFIELD is not set as the corresponding only 1 field in the database (1 is usually the primary key).
(2). DataGrid1. Columns > e.Item.Cells
Solution:
(1). Set the datakeyfield
(2). Add judgment statement datagrid1.item.count (datagrid can be other similar server controls)

8. Error: part 1 of the path "C:\" was not found.

Description:
During the execution of the current Web request, an unhandled exception occurred. Check the stack trace information for more information about this error and the source of the error in the code.
Exception details: System.IO.DirectoryNotFoundException: part 1 of the path "C:\" was not found.
Solution:
You can access the C disk by adding the Users group read permissions, but for server security reasons, you should remove the UserS group permissions. Successive problems are shown in different wrong ways, such as the following problems, and then 11 will be solved.
9. The data source does not support data paging on the server side
Solutions:
Instead of using DataReader, use DataSet: or use custom paging instead of the paging capabilities provided by vs.net
OleDbDataAdapter da = new OleDbDataAdapter(sql, connection);
DataSet ds2 = new DataSet();
da. Fill (ds2, "News");
GridView1. DataSource = ds2;
GridView1. DataBind ();

10. Object name '**** 'is invalid
Reason: there is no **** table in the database currently in use, or the current database connection account does not have access to the object
Solution: solution for cause 1: check to see if the program miswrites the name of the table you are calling or if the SQL database contains the name of the table you are calling. Solution: change all object owners in your database to dbo.
The solution (which comes from the network and has been tested to be effective) is as follows:
Use the account you own to connect to the query analyzer and run the following sql statement:
You can use sp_changedbowner to change the owner of the database.
Method 1: right click on the table - "design table", click on the last "condition constraint" in the row of small ICONS above, click on the "table" page, and change the owner inside. (if there is no small icon of constraint, you can click the right button to see an option of "check constraint".)
Method 2: directly execute with script, log into the database with system account or hyperuser, and then execute the following statement:
sp_configure 'allow updates','1' go reconfigure with override go update sysobjects set uid=1 where uid < > 1 go sp_configure 'allow updates','0' go reconfigure with override /* batch substitution
declare tb cursor local for select 'sp_changeobjectowner ''['+replace(user_name(uid),']',']]')+'].[' +replace(name,']',']]')+']'',''dbo''' from sysobjects where xtype in('U','V','P','TR','FN','IF','TF') and status > =0 open tb declare @s nvarchar(4000) fetch tb into @s while @@fetch_status=0 begin exec(@s) fetch tb into @s end close tb deallocate tb go
*/
11. Error establishing connection to server. When connecting to SQL Server 2005, SQL is set to the default
This may fail if Server does not allow remote connections. (provider: named pipe provider,
error: 40 - unable to open connection to SQL Server)
solution: a fixed IP address or server address is required on the host

12. SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM.
This problem ' 'is mostly due to the fact that when you update the database, the' 'datetime field value is null.' 'is inserted into 0001, January 01, by default
Day ' 'caused datetime type overflow

13. Appear -- to indicate "property", and here should be "method".
The reason:
1. The format of VB and c# are different.
2. It may be the syntax error of binding data in design.
2. Remember the proper syntax for binding data (there are several ways: < % Container. DataItem(" field name ")% > < %
#Eval(" field name ")% > < %Bind(" field name ")% > Etc.)

14. Assembly "DAL, Version=1.0.0.0, Culture=neutral,"
Load type "DAL.SqlHelper" in "PublicKeyToken=null".
Reason: it failed to recompile to dll after modifying other layers
Solution: compile 1 down (Rebuild)

15. Too many parameters for a procedure or function,
solution: the number of arguments used to invoke the stored procedure and the defined stored procedure or the arguments passed in the SQL statement that was executed
Number not 1 to (this is an SQL error)
Solution: carefully check whether the parameter variables set in the stored procedure correspond to the actual input parameter values of 11

Unable to start debugging, binding handle invalid
Reason: system Terminal Services is not turned on

17.Unable to debugging on the web server.Debug failed because integrated windows authentication is not enable
Solutions:
Open the vs2005 - > Tools (Tools) - > Option (Option) - > Debugging (debugging) - > Edit and continue (Edit and Continue)- > All the box
18. Filename or class name not found in Automation operation: 'RegExp'
Solution :regsvr32 vbscript.dll

19. System.NullReferenceException: the object reference is not set to an instance of the object.
The reason:
(1) the set variable is null or has no value. This problem usually occurs when passing parameters, and also occurs when using data controls such as datagrid or gridview or datalist.
(2) the control name does not correspond to the one in codebehind
(3) the object is not initialized with new
(4) the control referenced in the program does not exist
Solutions:
(1) using try.. catch... finally catches errors, or outputs the value of the variable directly with response.write ()
(2) check whether there are any uninitialized variables in the code

20. Mistake 1718. File was rejected by digital signature policy (when installing vs2005sp1)
(1). Click start, click run, type control admintools, and then click ok.
(2). Double-click "local security policy".
(3). Click "software restriction policy". (note: if software restrictions are not listed, right click software restrictions policy, and then click new policy. )
(4). Under "object type", double-click "force".
(5). Click all users except the local administrator, and then click ok.
(6). Restart the computer.
Microsoft notes:
http: / / support. microsoft. com/kb / 925336


Related articles: