Visual studio debugging Summary

Source: Internet
Author: User
Tags sql error try catch management studio sql server management sql server management studio
Visual studio debugging Summary The Last Time VS2003 was completed, and the results were very responsive. Of course, it is a pleasure to help you improve efficiency during program debugging, this time, according to the various problems encountered during the development of a project, I wrote down him and collected some problems and solutions on the website, first, make a record so that you can have a chapter to check later. Second, we will share it with you. sharing Technology and happiness have always been the purposes of our website's electronic journals. I hope everyone will like it :) without saying anything nonsense: We only need something useful for everyone. I hope the following things will help you. thank you :) if you think this article is useful to you, you are welcome to repost it. Please indicate that you are from "Taipa Studio". We will not ask for the patent fee, so rest assured.

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 <form>

Solution:
Solution 1: add this sentence to the. aspx file header: <% @ Page validateRequest = "false" %>
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: it may be because the path configuration in webconfig is incorrect. This problem is prominent in FCKEditor configuration.

<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)

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 ()
2. Remember the correct syntax for binding data (there are several methods: <% Container. DataItem ("field name") %> <%
# Eval ("field name") %> <% Bind ("field name") %>)

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 be created)

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.

 

</Project>

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, hook anonymous Access and allow iis control password

33. There is an invalid SelectedValue because it is not in the project list

Cause:
(1) assign a value to DropDownList1.SelectedValue before the DropDownList is bound.
(2) The dropdownlist contains null values.

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

Solution: Re-compile the project (re-compile multiple projects), close vs, re-open the project, and restart the machine if necessary.


35. User 'C \ aspnet' failed to log on.
Exception details: System. Data. SqlClient. SqlException: User 'coo \ aspnet' Logon Failed.
What's going on?

Because the connection string of your program to SQLServer is windows integrated login, you can change to the database account and password to log on. The connection string is written as follows:

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

The server is the name or IP address of the database server. If it is the same machine, you can use localhost

Uid is the database login account

Pwd is the Database Password

Database is the initial owner name of the database.

Answer:

1. Right-click my computer on the desktop and 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 displayed "Remote Desktop Users" attribute dialog box, click Add. In the displayed "Add User" dialog box, click "advanced", and then click "Search now, double-click ASPNET in the "Search" result (if it is IIS6.0 "networ serverce") and click "OK" twice to add "user"

2. Click Start> All Programs> Microsoft SQL Server> Enterprise Manager and select the database in the console root directory, right-click "user" in the database and select "Create Database User ". In the "new user" dialog box, click the drop-down list box on the right of "Login Name" and select "new" to open the "New Login Dialog Box ". Click the ellipsis on the right of the name. In the displayed dialog box, select "Name of the Local Machine" in "name listed", and then select "Remote Desktop Users" in the Name box below ", click "member", double-click ASPNET (for IIS6.0 "networ serverce"), and click "OK, in the "New Login Dialog Box", select the corresponding database name in the "Database" option set by default, and then select the corresponding database under the "database access" option and click OK, add the default anonymous user of ASP.net to SQL
 

36. User 'nt authority \ network service' Login Failed.
1> SQL server and windows Verification Mode

2>
(The following method is for reference only)
Step 1: Add 'nt AUTHORITY \ NETWORK Service' to the Administrator Group
My computer --> right-click --> Manage --> local users and groups
Select "group" --> double-click "Administrators" --> click "add" --> click "advanced" --> click "find now" --> select a Network Service user from the list below --> click "OK" --> join twice.

Step 2 Add a NetWord Service user to the Enterprise Manager
Open SQL Server Enterprise Manager --> select database instance --> open "security" node --> select "login" --> right-click the list on the right --> select "New login "--> on the "General" tab, click the button next to "name"... "--> select" Administrators "group --> click the" members "button below --> select" Network Service "--> click" add "--> 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 3
Run the asp.net program again and select windows for the database connection string.

3> Add an account or IIS_WPG workgroup to sqlserver

This method comes from http://www.cnblogs.com/677/archive/2006/11/03/549104.aspx

37. Failed to load view status. The Control tree in which the view status is being loaded must match the control tree used to save the view status during the previous request. For example, when a control is added dynamically, the control added during the sending back must match the type and position of the control added during the initial request.

Cause: viewstate is used in Asp.net to save the control status. The server will restore the control status after the next Post to the server. (The status of the control includes values and events .)

Solution:
(1) Change the viewstate of each UserControl to false.

(2) add this:
This. Page. EnableViewState = false;

This method comes from: http://www.cnblogs.com/king_astar/archive/2005/06/01/165763.html

38. "The SQL Server user instance cannot be generated due to an error in the process of starting the user instance. The connection will be closed ."
Cause:
This is Microsoft's bug, and Microsoft has admitted, details are as follows: http://support.microsoft.com /? Id = 896613
The condition for this error is that you have used Remote Desktop Connection and installed SQL2005 + VS2005, which may trigger this problem, microsoft said it will solve this problem in the future XP SP3.

Solution:
Http://forums.microsoft.com/MSDN/Sho. .. ID = 128707 & SiteID = 1
If you cannot understand English, I will tell you the solution:
Delete C: \ Documents and Settings \ [USERNAME] \ Local Settings \ Application Data \ Microsoft SQL Server Data \ SQLEXPRESS directory. [USERNAME] is the Windows user name, such as Administrator.

This problem comes with http://blog.csdn.net/xiong1000/

39. Server Application Unavailable

The web application you are attempting to access on this web server is currently unavailable. Please hit 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 be found in the application event log of the web server. please review this log entry to discover what caused this error to occur.

Solution:

If you are running WinXP/IIS 5.1, in order to give the ASPNET working process the right to access your web project folder, please go to the directory where the website file is located, right-click the level-1 folder, select Security-Add-type "ASPNET" and click OK or Check Names. If the pop-up dialog box prompts "Name not Found", click Locations to change the location to the Name of the Local Computer and click OK, assign this user permission to "Full Control" and click OK.

Error changed:
You are not authorized to view this page

You do not have permission to view this directory or page using the credentials you supplied.

Solution:

In IIS, right-click this virtual Directory-Properties-Directory Security-Edit-and select Integrated Windows authentication.

40. The timeout has reached. The timeout time has reached, but the connection has not been obtained from the pool. This may occur because all pool connections are in use and the maximum pool size is reached.

The possible reasons are as follows: concurrent operations, Connection is not closed after use, or the DataReader Connection exclusive Connection.

Solution:
1. modify several key pages or frequently accessed database access operations. Use DataAdapter and DataSet to obtain database data. Do not use DataReader.
2. Use the data Cache on the page for accessing the database. If the data on the page is not updated frequently (updated several minutes), the Cache object can be used without accessing the database, this greatly reduces the number of connections.
3. modify the code and call Dispose () after Close.
4. We recommend that you modify Database Operations to create your own database operation proxy class, inherit from the System. IDisposable interface, and forcibly release resources. In this way, there will be no insufficient connections.

41 package loading failed

The Package "Visual Web Developer Trident Designer Package" (GUID =

{30AE7E28-6C02-496D-8E43-85F7A90AEFF1 }. Contact the package supplier for help. We recommend that you restart the application because the environment may be damaged. Do you want to disable future loading of this package? You can use "devenv. reswetskippkgs" to re-enable package loading.
 

This prompt will be displayed every time you start vs2005...

So after google, I found that many methods have been tried. Only one solution can be used.

The solution is as follows:

1. Set the system variable VsLogActivity = 1

2. Create the ActivityLog. xml file in the % APPDATA % \ Microsoft \ VisualStudio \ 8.0 \ folder.

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.

Note: this problem only occurs in win2000, and win2003 does not.

42. User "xxx \ ASPNET Login Failed"
Step 1
Add 'nt AUTHORITY. NetWORK Service' to the Administrator group.
My computer --> right-click --> Manage --> local users and groups
Select "group" --> double-click "Administrators" --> click "add" --> click "advanced" --> click "Search now" --> select from the list below. network Service user --> click "OK" twice --> join.

Step 2 Add the. Network Service user in the Enterprise Manager
Open SQL Server Enterprise Manager --> select database instance --> open "security" node --> select "login" --> right-click the list on the right --> select "New login "--> on the "General" tab, click the button next to "name"... "--> select" Administrators "group --> click" members "below --> select. network Service --> click "add" --> 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 3
Run the asp. Net program again, and select windows for the database connection string.

For win2003

43. Unable to create/copy the file if "" already exists
Solution: Re-compile the entire project or restart the computer.

44. cocould not create an environment: OCIEnvCreate returned-1
Solution 1:
It is mainly to grant the read and write permissions of the oracle main directory oracle \ To asp.net, IUSER _... And IWAM _..., and restart the computer.

Solution 2:

Open WEB properties in IIS-home directory-Execute Permission [change to-script and executable file ];

-Change the application pool to-ms1_pointapppool and refresh OK;

Solution 3:
Folder permissions are not required.

The method for setting the ORACLE_HOME variable is as follows:

Control Panel> system> advanced> environment variables> system variables> New System Variables

Enter ORACLE_HOME as the variable name.
Add the actual ORACLE_HOME path to the variable value.

45. Unable to connect because the target machine is actively rejected

After adding the reference, replace all localhost: 2473 with localhost and re-compile.

46. View status can be loaded. The Control tree in which the view status is being loaded must match the control tree used to save the view status during the previous request. For example, when a control is added dynamically, the control added during the sending and receiving process must match the type and position of the control added during the initial request.

Solution: Add EnableViewState = "false" to the Page entry.

46. The call between the following methods or attributes is unclear: "method1" and "method2"

For implicit conversions, the compiler cannot call some form of the overloaded method. You can use the following methods to correct the error:

Specify the parameters of this method without implicit conversion.

Remove all overloading of this method.

Before calling a method, forcibly convert it to the correct type.

47. Register as allowDefinition = 'machinetoapplication' outside the application level'

Solution: Right-click the virtual directory corresponding to the website, select properties, and click Create after the application name.
[Sub-directories do not inherit the parent attributes, so you must set the Directory attribute of the aspx file correctly]

48. Unrecognized configuration section "connectionStrings"
Cause:

The asp.net application developed with vs2005 needs to use. net framework 2.0, while the default. net environment in iis is 1.1. In this case, an unrecognized node will occur.

Solution:

Upgrade the. net environment 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 have occurred because all pooled connections were in use and max pool size was reached.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System. invalidOperationException: Timeout expired. the timeout period elapsed prior to obtaining a connection from the pool. this may have occurred because all pooled connections were in use and max pool size was reached.

The main reasons may be:

1. When a connection pool is used, a large number of sqlconnections are used and the gate is forgotten, causing serious SQL usage. You can check the Stored Procedure exec sp_who.
2. Connection Pool connections are limited

Solution:
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 handle database connection exceptions. When the database cannot be connected, an exception is thrown and an error message is displayed, as shown in the catch code block. In this program, you can close the database connection through the finally block regardless of whether an exception occurs, thus saving computer resources.
3. Include the SqlConnection object in the using block, so that the program will automatically call the Dispose () method to release the system resources occupied by the SqlConnection object. You do not need to use the Close () method of the SqlConnection object.
3. Specify the min pool size to indicate the minimum number of connections allowed by the connection pool (0 by default ). The following code specifies that the max pool size of the SqlConnection object is 10, and the min pool size is 5.
SqlConnection mySqlConnection = new SqlConnection ("server = localhost; database = Northwind;

Integrated security = SSPI; "+" max pool size = 10; min pool size = 5 "); 50.The specified conversion is invalid.Temp. AdminPassWord = sdr. GetString (sdr. GetOrdinal ("AdminPassWord "));
// Temp. adminPassWord = Convert. toString (sdr ["AdminPassWord"]); when the value of the data table field is null (except for incorrect data types), the first item is abnormal and the second item should be used.
51. DropDownList cannot select two options at the same time. Use the following statement to solve the problem: first clear the selection item this. Ddl_Sex.ClearSelection ();
This. Ddl_Sex.Items.FindByValue (User_StuInfo.StuSex). Selected = true; 52. Error 1 there is a syntax error near 'external. You may need to set the compatibility level of the current database to a higher value to enable this function. Information about the storage process sp_dbcmptlevel

To open SQL Server Management Studio, follow these steps:

1. Right-click the database you want to use and click Properties.
2. Select-Option-Compatibility Level: SQL Server 2005 (90 ).
Or execute EXEC dbo. sp. dbcmptlevel @ dbname = n'database _ name', @ new_cmptlevel = 90
3. Select-file-owner: Enter the Database User
Or run alter authorization on database: database_name TO [domainname \ username].
4. Click OK.

 

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.