Asp. NET Common errors Daquan

Source: Internet
Author: User
Tags sql error stack trace try catch

1. A potentially dangerous request.form value is detected

Reason:

(1) ValidateRequest properties are not properly set in the page or webconfig where the data is submitted

(2) The HTML contains two <form> caused

Solve:

Scenario One: Add this sentence to the header of the. aspx file: <%@ page validaterequest= "false"%>

Scenario Two: Modify the Nfig file:

<configuration>

<system.web>

<pages validaterequest= "false"/>

</system.web>

</configuration>

Because the validaterequest default value is true. Just set it to false.

2. "Invalid read attempt without any data" workaround

Reason:

The returned SqlDataReader had no data records, but did not make a record of judgment processing. Returns a null value

Plus judgment: if (Reader.read ()) {Textname.text =

reader["FieldName"]. ToString (); }

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

Reason:

If the object is null, then the method that invokes the object, such as ToString (), must be wrong generally the value of the database field is empty

Data controls such as Grideview are often present

Resolution: Therefore, null processing is recommended

4. The fieldcount attempt is not valid when the reader is closed

Reason:

After using SqlDataReader to bind the data, the connection object is treated as close ()

Similar

Public SqlDataReader getsomething ()

{

Conn.Open ();

SqlDataReader reader =

sqlcmd. Excecutreader (commandbehavior.closeconnection));

Conn.close ();//occur error here

return reader;

}

This method is called at the time of binding to specify the data source. If you use this method, you need to close the re in the calling function

Ader This conn can be turned off automatically.

If you are using SqlDataAdapter and datasets, remove the call to explicitly close Conn. Or at finally

Called in the.

5. Failed to map the path

Cause: May be caused by incorrect path configuration in Webconfig, this problem is more prominent in FCKeditor configuration.

<add key= "Fckeditor:basepath" value= "~/admin/fckeditor/"/>

<add key= "Fckeditor:userfilespath" value= "/userfiles/"/>

6.Unreachable Code Detected

Reason:

A throw or return is typically used in the exception handler or return value, possibly in front of the location, resulting in subsequent code execution.

Solve:

Put the associated exception-throw-processing statement (throw) or return statement to the last line of the agent execution.

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

Reason:

(1). DataKeyField set to the corresponding unique field in the database (typically the primary key)

(2). Datagrid1.columns > E.item.cells

Solve:

(1). Set DataKeyField

(2). Add a Judgment statement unt (the DataGrid can be other similar server controls)

9 Data sources do not support server-side data paging.

Workaround:

Do not use DataReader to use a dataset: or use a custom paging format without the paging functionality provided

OleDbDataAdapter da = new OleDbDataAdapter (sql, connection);

DataSet ds2 = new DataSet ();

Da. Fill (DS2, "News");

Gridview1.datasource = DS2;

Gridview1.databind ();

10. Invalid object name ' * * * * *

Cause: The database currently in use does not have a * * * * This table

FIX: See if the name of the called table is incorrectly written in the program or if there is a table in the SQL database that you have called

11. An error occurred while establishing a connection to the server. When you connect to SQL Server 2005, the default settings are SQL

This failure may be caused by Server not allowing 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

Between.

This problem occurs mostly because you update the database when the ' datetime field value is empty ' default insert January 01 01

Date ' causes a datetime type overflow

13. A-------appears indicating "Properties", which should be "method" here

Reason:

1.VB and C # methods, properties are formatted differently.

2. The syntax for binding data in design may be incorrectly resolved: 1. Remember that attributes are used with the [] method ()

2. Remember the correct syntax for binding data (in the following ways: <%container.dataitem ("field name")%> <%

#Eval ("field name")%> <%bind ("field name")%>, etc.)

14. Failed from the Assembly "DAL, version=1.0.0.0, Culture=neutral,

Publickeytoken=null the "in Load Type" DAL. SqlHelper ".

Cause: Failed to recompile to DLL after modifying other layers

FIX: Compile (Rebuild)

15. Too many parameters are specified for a procedure or function,

Solution: The number of parameters used to invoke the stored procedure with the defined stored procedure or the arguments passed in the SQL statement executed

The number of numbers is inconsistent (this is a SQL error)

Solution: Carefully examine the parameter variables set in the stored procedure, corresponding to the actual input parameter value one by one

16. Unable to start debugging, binding handle is invalid

Cause: The system's Terminal Services did not open

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

Workaround:

Open vs2005-> tools (Tools), Options (option), Debug (Debugging), Edit and Continue (Edit and Continue)-All tick

File name or class name not found in 18.Automation operation: ' RegExp '

Workaround: regsvr32 vbscript.dll

19.system.nullreferenceexception: Object reference not set to an instance of an object.

Reason:

(1) The variable being set is NULL or does not have a value, it usually occurs when passing parameters, and also occurs when using data controls such as the DataGrid or GridView or DataList.

(2) The control name does not correspond to the inside of the codebehind

(3) object not initialized with new

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

Workaround:

(1) Use try: Catch...finally catch error, or output the variable value directly with Response.Write ()

(2) To see if there are uninitialized variables in the code

20. Error 1718. File is rejected by the digital signature policy (when installing VS2005SP1) Workaround:

(1). Click Start, click Run, type Control AdminTools, and then click OK.

(2). Double-click Local Security Policy.

(3). Click Software Restriction Policies. (Note: If software restrictions are not listed, right-click Software restriction Policies, and then click New Policy.) )

(4). Under Object type, double-click force.

(5). Click All users except local administrators, and then click OK.

(6). Restart the computer.

Microsoft notes:

  

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

Workaround: Under DOS run under devenv/resetskippkgs (win+r cmd)

22.Validation of ViewState MAC failed

Workaround: At the top of the page, add enableviewstate= "false" enableViewStateMac = "false" to resolve this problem

23.Automation server can ' t create object ' (Automation server cannot be created)

Workaround: Run: Regsvr32 scrrun.dll.

24. Package Load Failure

The package "Visual Web Developer Trident Designer" was not loaded correctly (GUID =

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

Workaround:

1. Set the system variable Vslogactivity=1

2. Create a file under the%appdata%\microsoft\visualstudio\8.0\ folder Activitylog.xml

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 files from winnt\microsoft.net\framework\v2.0.xxx gdiplus.dll to program files\visual Studio 8\common7\packages folder

4. Run the command at the command line: devenv/resetskippkgs

25.Error spawning ' cmd.exe '.

Solution: Copy the Cmd.exe to the Vc/bin directory in the VS installation directory to solve the problem.

26. Attempt to read or write protected memory

FIX: Hardware problem, general memory problem

27. Unable to find the manifest signing certificate in the certificate store

Workaround: Use Notepad to open the. csproj file for the project, delete similar

28. The target "ResolveKeySource" does not exist in this project.

Reason: This problem is very rare, after querying the relevant information abroad, roughly speaking is because the deployment is not a standard solution, need to run the following in the VS self-contained command prompt recovery

Workaround:

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

<project defaulttargets= "Build" xmlns= "" >

<PropertyGroup>

<targetconnectionstring>data Source=.\sql2005%3buser id=sqluser%3bpooling=false%3bpassword=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 in command prompt: Msbuild/t:buildalldatabaseprojects testbuild.xml

</Project>

29. Cannot insert value NULL into column ' * * '

Cause: This is a database table design error, the fields in the table involved are set to a property that cannot be empty, but the passed-in value is NULL, so an error

Workaround: See if the value passed in is null, or modify the properties of the column corresponding to the table in the database

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

Reason:

(1) The project has not been compiled after modification

(2) The namespace of the project may have been modified

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

Workaround:

(1) After the modification is complete, rebuild or compile the entire project or solution

(2) Manually modify the changed namespace, note the case of the name, and then recompile

(3) Include the relevant documents in the project

31. Cannot access read-only file "****.***"

Solution:

Add the "everyone/write" permission to the file that corresponds to the virtual directory

32. Request failed due to HTTP status 401: Access Denied Workaround: Leave anonymous access and allow IIS control password on IIS information Server

33. There is an invalid selectedvalue because it is not in the list of items

Reason:

(1) Assigning a value to Dropdownlist1.selectedvalue before DropDownList is tied

(2) Null value appears in DropDownList

34. Unable to create/image copy of the file if "" already exists.

Solution: Recompile the project (multiple projects are all recompiled), turn off vs, reopen, and restart the machine if necessary.

35. User ' c\aspnet ' Login failed login failed.

Exception Details: System.Data.SqlClient.SqlException: User ' coo\aspnet ' login failed.

What the hell is going on here?

Because your program connects SQL Server's connection string with Windows Integrated login, you can change it to log in with your database account password. The notation for the connection string is:

Server=localhost;uid=sa;pwd=xxxx;database=master;

Server is the machine name or IP of the database server, if the same machine can use localhost

UID is the database login account

PWD is a database password

Database is the initial owner name

Answer:

1. Right click on desktop My Computer, select "Manage", double click "Group" under "Local Users and Groups" in the Computer Management dialog box in the right window, double-click the Remote Desktop Users group in the Open Remote Desktop Users Properties dialog box Click Add, click Advanced in the Add Users dialog box that opens, click the Find Now button, double-click the ASPNET (if IIS6.0 "Networ serverce") in the search results, and then tap two times to make sure to complete adding "user"

2. Click Start-All Programs-Microsoft SQL Server-Enterprise Manager to select the appropriate database in the console root that opens, right-click Users in the database, and select New Database User ("users"). In the New User dialog box, click the drop-down list box to the right of login name, select New, and open the New Login dialog box. Click the ellipsis button to the right of the name, select the name of this computer in the dialog box that opens, choose Remote Desktop Users in the Name box below, then click the Members button and double-click the ASPNET (if IIS6.0 networ Serverce "), then click OK, in the" New Login dialog "in the default settings of the" database "option to select the appropriate database name, and then under the" Database access "option tick the appropriate database Click OK, complete the default anonymous user to add to the SQL

36. User ' NT Authority\Network SERVICE ' login failed.

1> SQL Server and Windows Authentication mode

2>

(The following methods are for reference only)

First step: Add ' NT authority\network SERVICE ' to the Administrator group

My Computer--right--manage local Users and groups

Select "Group"-double-click on the administrators--> by clicking "Add"-click "Advanced"-click "Find Now"-Select Network Service user in the list below-two times click OK --Join.

The second step is to add the Netword service user to the Enterprise Manager

Open SQL Server Enterprise Manager--Select a DB instance--Open the Security node--Select Login-Right-click in the list on the right-> choose New Login-click Name on the General tab Next to the button "..."-Select the "Administrators" group--> click the Members button below--select "Network Service"-click "Add" button-click "OK" to return to "new login dialog box-Ensure that the authentication type is Windows authentication and allow access-click OK-Close Enterprise Manager

Step Three

Rerun the program, and select Windows Authentication for the database connection string.

3> add an Account or IIS_WPG workgroup in SQL Server

This method is derived from the

37. Failed to load view state. The control tree in which the view state is being loaded must match the control tree that was used to save the view state during the previous request. For example, when you add a control dynamically, the control that you add during a postback must match the type and location of the control that you added during the initial request.

Cause: The role of ViewState is to save the state of the control in the next post to the server, which is the state of the recovery control. (The state of the control includes: values and events.) )

Workaround:

(1) The ViewState of each UserControl is changed to False

(2) Add this:

This. Page.enableviewstate = false;

This method is derived from: _astar/archive/2005/06/01/l

38. "The user instance of SQL Server could not be built because of an error while initiating the process of the user instance. The connection will be closed. ”

Cause of the problem:

This is Microsoft's bug, and Microsoft has admitted that the details are as follows:

The condition of this error is that you have used a Remote Desktop connection and installed sql2005+vs2005, which is likely to trigger the problem, and Microsoft says it will solve the problem in future XP SP3.

Solve:

... Id=128707&siteid=1

If you can't read English, then I'll tell you my solution:

Delete C:\Documents and Settings\[username]\local Settings\Application Data\Microsoft\Microsoft SQL Server data\ SQLExpress directory, [USERNAME] is a Windows user name, such as Administrator

This problem comes from

39.Server Application Unavailable

The Web application attempting to access on this Web server is currently unavailable. Click the "Refresh" button in your Web browser to retry your request.

Administrator Note:an error message detailing the cause of this specific request failure can is found in the application Event log of the Web server. Please review this log entry to discover what caused this error to occur.

Solve:

If you run Winxp/iis 5.1, in order to give the ASPNET worker process access to your Web project folder, go to the directory where the Web site file is located, right-level folder, select security-add-type "ASPNET", click OK or click Check Names, If the pop-up dialog prompts "name not Found" then you should click Locations to change location to the native computer name, click OK, assign this user right to "full Control" click OK.

The error becomes:

You is not a authorized to the view this page

You don't have a permission to view this directory or page using the credentials you supplied.

Solve:

In IIS, right-click this virtual directory-properties-directory security-edit-check integrated Windows authentication.

40. The timeout period has expired. The timeout period has expired, but the connection has not been obtained from the pool. This can happen because all pooled connections are in use and the maximum pool size is reached.

Possible causes are as follows: concurrent operation, connection not closed after use, or because the DataReader connection is an exclusive connection.

Workaround:

1 Modify several key pages or access more frequent database access operations, use DataAdapter and datasets to obtain database data, and do not use DataReader.

2 The data cache is used on pages that access the database, and if the page's data is not updated frequently (a few minutes later), using the Cache object allows you to use the cached content without accessing the database, which can significantly reduce the number of connections.

3 Modify the code to add the Dispose () call to the place where the connection object is used, followed by close ().

4 It is recommended to make large changes to the database operations, set up their own database operations agent class, inherit the System.IDisposable interface, forcing the release of resources, so there will be no insufficient number of connection problems

41 Package failed to load

The package "Visual Web Developer Trident Designer" was not loaded correctly (GUID =

{30ae7e28-6c02-496d-8e43-85f7a90aeff1}. Please contact the package vendor for assistance. It is recommended that you restart the application because of possible environmental damage. Do you want to prevent future loading of this package? You can use "devenv. reswetskippkgs" To re-enable package loading.

Every time you turn on the VS2005 will have this hint, annoying ...

So in Google a bit, found a lot of methods have tried, only one solution to a try on the line

Here's how to fix it:

1. Set the system variable Vslogactivity=1

2. Create a file under the%appdata%\microsoft\visualstudio\8.0\ folder Activitylog.xml

3. Copy files from winnt\microsoft.net\framework\v2.0.xxx gdiplus.dll to program files\visual Studio 8\common7\packages folder

4. Run the command at the command line: devenv/resetskippkgs

Note: This problem will not occur if the problem is found only in Win2000. Win2003.

42. User "Xxx\aspnet Login failed"

The first step

Add ' NT authority.network SERVICE ' to the Administrator group

My Computer--right--manage local Users and groups

Select Groups-double-click administrators-->, clicking Add-click Advanced-click Find Now-select in the list below. Network service users-two times click OK-Join.

The second step is added in Enterprise Manager. Network Service Users

Open SQL Server Enterprise Manager--Select a DB instance--Open the Security node--select "Sign In"-Right-click on the list and select "New Login"-click on "Name" on the General tab Next to the button "..."-Select the "Administrators" group--click the "Members" button below--select. Network Service-click the Add button-click OK, return to the new Login dialog box, ensure that the authentication type is Windows authentication and allow access-click OK-Close Enterprise Manager "

Step Three

Re-run ASP. NET program, select Windows Authentication for the database connection string.

Above for Win2003, if Win2000 plus ASP.

43. Unable to create/image copy of the file if "" already exists

WORKAROUND: Recompile the entire project or restart the computer

44.Could not create an environment:ocienvcreate returned-1

Solution One:

The primary is to grant or iuser_ the read and write permissions of the Oracle home directory oracle\. and IWAM_.., restart the computer.

Solution Two:

Open Web Properties in IIS--Home directory--Execute permissions "instead of-scripts and executables";

-Application Pool "changed to-mssharepointapppool", refresh OK;

Solution Three:

Folder permissions can be used without a tube.

Here's how to set the Oracle_home variable

Control Panel >> Systems >> Advanced >> Environment Variables >> System variables >> new System variables

Variable name write Oracle_home

The value of the variable adds the actual Oracle_home path, which in the registry has

45. Unable to connect due to active rejection of the target machine

After adding the reference, replace all localhost:2473 with localhost, recompile

46. Ability to load view state. The control tree in which the view state is being loaded must match the control tree that was used to save the view state during the previous request. For example, when you add a control dynamically, the control that you add during a postback must match the type and location of the control that was added during the initial request

FIX: Add enableviewstate= "false" to page item

46. The call between the following methods or properties is ambiguous: "Method1" and "Method2"

Because of the implicit conversion, the compiler cannot invoke some form of the overloaded method. You can correct the error in the following ways:

Specifies the parameters of this method in a manner that does not occur implicitly.

Removes all overloads of this method.

Cast to the correct type before calling the method.

47. Use registration as allowdefinition= ' MachineToApplication ' outside the application level

Resolution: Right-click on the virtual directory of the site, select Properties, and then click on the application name to create, the name is optional

[subdirectories do not inherit attributes from ancestors, so the directory property where the aspx file resides is set correctly]

48. Unrecognized configuration section "ConnectionStrings"

Reason:

Applications developed with VS2005 need to make the Framework 2.0, while the default environment in IIS is 1.1. An unrecognized node problem occurs.

Workaround:

Environment upgrade to 2.0, start-"run-" cmd-"

C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis.exe-i

49.Timeout expired. The timeout period elapsed prior to obtaining a connection from the pool. This may has occurred because all pooled connections were in use and Max pool size is reached.

Description:an unhandled exception occurred during the execution of the current Web request. Review the stack trace for more information about the error and where it is originated in the code.

Exception Details:System.InvalidOperationException:Timeout expired. The timeout period elapsed prior to obtaining a connection from the pool. This may has occurred because all pooled connections were in use and Max pool size is reached.

The main reasons may include:

1. Using the connection pool, a large number of SqlConnection used to forget to close the gate, resulting in a serious SQL occupation, you can use the EXEC sp_who this stored procedure to view

2. Connection Pool connection number is limited

Workaround:

1. Release the connection pool and call the close () method of the Connection object to close the database connection

2. Use try catch finally to treat database connections with exception. An exception is thrown when the database cannot be connected, and an error message is displayed, as shown in the catch code block. In this program, you can save computer resources by closing the database connection with the finally chunk, regardless of whether an exception occurs

3. Include the SqlConnection object in the using chunk so that the program automatically calls the Dispose () method to release the system resources that the SqlConnection object consumes, eliminating the need to use the close () method of the SqlConnection object

3. Specify min pool size to indicate the minimum number of connections allowed for the connection pool (default is 0). The following code specifies that the max pool size of the SqlConnection object is 10,min pool size of 5.

SqlConnection mysqlconnection = new SqlConnection ("Server=localhost;database=northwind;")

Asp. NET Common errors Daquan

Related Article

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.