Asp.net debugging solution highlights

Source: Internet
Author: User

1. Detected request. Form values that are potentially dangerous

Cause:

(1) The validaterequest attribute is not correctly set on the data submission page or webconfig.

(2) Two characters are written in HTML, causing

Solution:

Solution 1: add this sentence to the. aspx file header:

Solution 2: Modify the Web. config file:

<Configuration>
<System. Web>
<Pages validaterequest = "false"/>
</System. Web>
</Configuration>
Because the default value of validaterequest is true. Set it to false.

2. "An invalid read attempt is made when no data exists" SOLUTION

Cause:

The returned sqldatareader does not have a data record, but does not perform record judgment. Null Value returned

Add judgment: If (reader. Read () {textname. Text =

Reader ["fieldname"]. tostring ();}

3. The data is empty. This method or attribute cannot be called for null values.

Cause:

If the object is null, the method of calling the object, for example, tostring (), must have an error. Generally, the value of the database field is null.

Data controls such as grideview often appear

Solution: Therefore, it is recommended to perform null processing.

4. The fieldcount attempt is invalid when the reader is disabled.

Cause:

After sqldatareader is used to bind data, the connection object is closed ().

Similar

Public sqldatareader getsomething ()
{
Conn. open ();
Sqldatareader reader =
Sqlcmd. excecutreader (commandbehavior. closeconnection ));
Conn. Close (); // occur error here
Return reader;
}
This method is called during binding to specify the data source. If you use this method, you need to disable re in the call function.

In this way, the conn can be automatically disabled.

If sqldataadapter and dataset are used, remove the explicit call to disable Conn. Or in finally

.

5. The path cannot be mapped.

Cause: the path configuration in webconfig is incorrect.

<Add key = "FCKeditor: basepath" value = "~ /Admin/FCKeditor/"/>

<Add key = "FCKeditor: userfilespath" value = "/userfiles/"/>

6. Unreachable code Detected

Cause:

Generally, throw or return is used for exception handling or return values. It may be that the position is put in front, resulting in subsequent code execution.

Solution:

Put the throw or return statement to the last row of the agent.

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

Cause:

(1). datakeyfield is not set to the unique field corresponding to the database (generally the primary key)

(2). Maid> E. Item. Cells

Solution:

(1). Set datakeyfield

(2) Add the judgment statement maid. Count (DataGrid can be another similar Server Control)

8. The data is empty. This method or attribute cannot be called for null values.

9. The data source does not support data paging on the server.

Solution:

Do not use datareader, instead use dataset: or use custom paging mode. Do not use the paging function provided by vs.net.

Oledbdataadapter da = new oledbdataadapter (SQL, connection );
Dataset ds2 = new dataset ();
Da. Fill (ds2, "news ");
Gridview1.datasource = DS2;
Gridview1.databind ();
10. The object name '*****' is invalid.

Cause: The table ***** is not found in the currently used database.

Solution: Check whether the name of the called table is incorrectly written in the program or whether the SQL database contains the table you called.

11. An error occurred while establishing a connection with the server. When connecting to SQL Server 2005

If the server does not allow remote connection, this may fail. (Provider: named pipeline provider,

Error: 40-unable to open the connection to SQL Server)

Solution: fixed IP addresses or server addresses are required on the host.

12. sqldatetime overflow. It must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 pm

.

This problem occurs. ''most of the reason is that when you update the database, ''datetime field value is blank'' is inserted on January 1, January 01, 0001 by default.

'''Causes datetime type Overflow

13. ------- indicates "attribute". Here it should be "method"

Cause:

1. the attribute formats of VB and C # are different.

2. It may be caused by an error in the syntax of Binding data to design: 1. Remember to use the [] Method for attributes ()

3. Remember the correct syntax for binding data (in the following ways)

14. Failed to import from assembly "Dal, version = 1.0.0.0, culture = neutral,

Publickeytoken = NULL "loads data type" Dal. sqlhelper ".

Cause: failed to recompile to DLL after modifying other layers

Solution: Compile (rebuild)

15. Too many parameters are specified for a process or function.

Solution: number of parameters used to call the stored procedure and the defined stored procedure or the parameters passed in the executed SQL statement

Inconsistent numbers (this is an SQL error)

Solution: carefully check the parameter variables set in the stored procedure, and check whether they correspond to the actual input parameter values one by one.

16. debugging cannot be started, and the binding handle is invalid.

Cause: the system's terminal services is not enabled

17. Unable to debugging on the Web server. debug failed because integrated Windows authentication is not enable

Solution:

Open vs2005-> Tools-> Option-> debug-> edit and continue-> tick all

18. The file name or class name cannot be found in the automation operation: 'regexp'

Solution: regsvr32 VBScript. dll

19. system. nullreferenceexception: object reference is not set to the instance of the object.

Cause:

(1) If the set variable is null or the value is not obtained, this problem usually occurs when the parameter is passed, or when data controls such as DataGrid, gridview, or datalist are used.

(2) The Control name does not correspond to that in codebehind.

(3) The new initialization object is not used.

(4) The control referenced in the program does not exist.

Solution:

(1) Use try... catch... finally to catch errors, or directly use response. Write () to output the value of the variable.

(2) check whether there are uninitialized variables in the code

20. Error 1718. File is denied by the digital signature policy (when vs2005sp1 is installed)

Solution:

(1) Click Start, click Run, type control admintools, and click OK ".

(2) double-click "Local Security Policy ".

(3) Click "Software Restriction policy ". (Note: If the software restrictions are not listed, right-click "Software Restriction Policy" and 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

21. vs2005 cannot switch from source file mode to view mode

Solution: Run devenv/resetskippkgs (WIN + R cmd) in DOS)

22. Validation of viewstate Mac failed

Solution: Add enableviewstate = "false" enableviewstatemac = "false" to the top page of the page to solve this problem.

23. Automation server can't create object "(The Automation server cannot create a pair)

Solution: Run regsvr32 scrrun. dll.

24. Package loading failed

The package "Visual Web Developer Trident designer package" (guid =

{30ae7e28-6c02-496d-8e43-85f7a90aeff1 }.

Solution:

1. Set the system variable vslogactivity = 1

2. Create the activitylog. xml file in the % appdata % \ Microsoft \ visualstudio \ 8.0 \ folder.

Error

Microsoft Visual Studio

Loadlibrary failed for package [Visual Web Developer Trident designer package]

{30ae7e2b-6c02-496d-8e43-85f7a90aeff1}

-------------------------------------------------

8007007e

C: \ Program Files \ Microsoft Visual Studio 8 \ common7 \ packages \ tridsn. dll

3. Copy the gdiplus. dll file from winnt \ microsoft. Net \ framework \ v2.0.xxx to the Program Files \ Visual Studio 8 \ common7 \ packages folder.

4. Run devenv/resetskippkgs on the command line.

25. Error spawning 'cmd.exe '.

Solution: Copy cmd.exe to the VC/bin directory under the vs installation directory to solve the problem.

26. Try to read or write the protected memory

Solution: hardware problems and general memory problems

27. Unable to find the list signature certificate in the certificate store

Solution: use NotePad to open the. csproj file of the project and delete a file similar

28. The target "resolvekeysource" does not exist in the project ".

Cause: this problem is rare. After querying the relevant foreign materials, it is generally said that the deployment is not a standard solution, and the following things need to be restored in the command prompt provided by

Solution:

(1) Save the following code as an XML file named testbuild. xml

<Project defaulttargets = "build" xmlns = "http://schemas.microsoft.com/developer/msbuild/2003">

<Propertygroup>

<Targetconnectionstring> Data Source =. \ sql2005 % 3 Buser id = sqluser % 3 bpooling = false % 3 bpassword = x </targetconnectionstring>

</Propertygroup>

<Itemgroup>

<Databaseproject include = "database1 \ database1.dbproj"/>

<Databaseproject include = "database2 \ database2.dbproj"/>

</Itemgroup>

<Target name = "buildalldatabaseprojects">

<Msbuild

Properties = "targetconnectionstring = $ (targetconnectionstring )"

Projects = "@ (databaseproject )"

Targets = "build; deploy">

</Msbuild>

</Target>

(2) Run msbuild/T: buildalldatabaseprojects testbuild. XML in the command prompt.

29. The null value cannot be inserted into the column '**'

Cause: This is a database table design error. The attribute that cannot be null is set in the fields of the involved table, but the input value is null. Therefore, an error is returned.

Solution: Check whether the passed value is null, or modify the attribute of the column corresponding to the table in the database.

30. Failed to load type "namespace. Class "...

Cause:

(1) The project is not compiled after modification.

(2) The original namespace in the project may have been modified.

(3) The ascx or other pages required by the project do not exist or are not included in the project

Solution:

(1) After the modification is completed, re-generate or compile the entire project or solution.

(2) manually modify the changed namespace. Pay attention to the Case sensitivity of the name and re-compile it.

(3) include relevant files in the project

31. The read-only file "*****. *****" cannot be accessed.

Solution:

Add the "Everyone/write" permission to the file corresponding to the virtual directory.

32. Request failed due to HTTP status 401: Access Denied

Solution: on the IIS Information Server, check the password for anonymous access and permission for IIS control.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.