"1" Reuse Project form solution:
1. Copy the FmMain.cs and FmMain.Designer.cs and Fmmain. resx three files to the program directory;
2. Add an existing item to VS, select FmMain.cs, do not select another file, complete the operation and reopen the window.
"2" Cannot read and write Registry solutions
The program reads and writes to the registry by using code to modify the enabled value under the following registry path to 0:
Hkey_local_machine\system\currentcontrolset\control\lsa\fipsalgorithmpolicy
The implementation code is as follows:
Public voidSetfipsalgorithmpolicyvalue () {stringKeyName =@"Hkey_local_machine\system\currentcontrolset\control\lsa\fipsalgorithmpolicy"; if(Convert.toboolean (Registry.getvalue (KeyName,"Enabled",NULL)) {registry.setvalue (keyName,"Enabled",0, Registryvaluekind.dword); }}
"3" WinForm set the form control double buffering code:
using System.Windows.Forms; class listviewex:listview{ public Listviewex () { true); UpdateStyles (); }}
"4" MSDN Recommended Lock object: custom class recommended for private read-only static objects
In general, it is a good idea to avoid locking public types or locking object instances that are not under application control. For example, if the instance can be publicly accessible, lock (this) may be problematic because uncontrolled code may also lock the object. This can result in a deadlock, where two or more threads wait to release the same object. For the same reason, locking public data types (compared to objects) can also cause problems. and lock (this) is only valid for the current object, if the synchronization effect is not achieved between multiple objects. The custom class recommends the use of private read-only static objects, such as: private static readonly Object obj = new Object (); Why should it be set to read-only? This is because if you change the value of obj in the lock code segment, Other threads can execute lock-locked code snippets.
"5" C # matches the regular expression for each parameter of the A tag:
string " (? is) <a[^>]* (style=[\ "')? (? <style>[^\ "']*?) [\"‘] [^>]* (href=[\ "])? (? <url>[^\ "']*?) [\"‘] [^>]*> (? <text>[\\w\\w]*?) </a>";
Changes in demand, the above regular expressions also need to be modified appropriately
[^ "] is not any character that represents double quotes, * indicates repetition 0 to multiple times
So ([^ "]*) is a string that matches a non-double-quote character
Q: What does it mean to see the regular front (? i) (? s) (? m) (? is) (? im) (?)
A: Called inline matching mode, usually using an inline matching pattern instead of using the enumeration value regexoptions the specified global match pattern, which is more concise to write.
(? i) indicates the expression on the right side of the position opens ignoring case mode
(? s) indicates that the expression on the right side of the position turns on single-line mode.
Change the meaning of the period character (.) so that it matches each character (not all characters except \ n).
Note: (? s) is typically used when matching text that has line breaks
(? m) indicates that the expression on the right side of the location opens the specified multiline mode.
Change the meaning of ^ and $ so that they match the beginning and end of any line, respectively,
Instead of just the beginning and end of the entire string.
Note: (? m) The multiline mode is used only if the matching of "^" and "$" in a regular expression involves multiple lines.
The above matching pattern can be used in combination, such as (? is), (? im).
Alternatively, you can use (? i:exp) or (? i) exp (?-i) to specify a valid range for the match.
"6" Special parameter description for SQL Server database connection string
Multipleactiveresultsets and mars_connection are synonymous, specifying whether this database connection re-uses connections from the same user already established within the database. When True, a database connection is queried to see if a connection has been established for this user on the server, and if established, the connection is reused directly. The default value is False. Setting Multipleactiveresultsets to true can improve efficiency.
Persist Security Info = True indicates an integrated safety mechanism, or false to indicate that no integrated security mechanism is used and that the default value is False.
"7" Fix Error: System.ArgumentException: Another sqlparametercollection contains SqlParameter scenarios
Error Details :
System.ArgumentException: SqlParameter is already included in another sqlparametercollection.
Specific reasons :
Declares an array of SqlParameter, and within the loop, each execution ExecuteNonQuery by the IDBCOMMAND.PARAMETERS.ADD (IDbDataParameter) inside the method Add the SqlParameter array to the idataparametercollection of the IDbCommand. The framework mechanism restricts two idataparametercollection from pointing to the same object. Although the ExecuteNonQuery method internally declares a IDbCommand temporary object, in theory, This IDbCommand object containing the idataparametercollection is freed from memory at the end of the ExecuteNonQuery method. But it may actually be that the garbage collection mechanism does not immediately reclaim the IDbCommand temporary objects, and the parameter set of object bindings also exists, just as a DropDownList adds item. So the next time the operation is executed, it causes two idataparametercollection to point to the same object, and the problem occurs.
Solution One :
The object is regenerated each time it is manipulated, but it is undesirable to generate a large number of garbage variables.
Solution Two :
Empties the Parameters collection of command commands after the use is complete.
The calling code is as follows:
SqlDataReader reader = cmd. ExecuteReader (commandbehavior.closeconnection); cmd. Parameters.clear ();
"8" JS page jump and JS open new Window method
The first type:<script language= "javascript" type= "Text/javascript" >window.location.href= "Http://www.xlfun.com/login.php?backurl=" +window.location.href; </script>The second type:<script language= "JavaScript" >Alert (Returns); Window.history.back (-1); </script>The third type:<script language= "JavaScript" >Window.navigate ("Xlfun.php"); </script>The fourth type:<script language= "JavaScript" >self.location= ' xlfun.htm '; </script>The fifth type:<script language= "JavaScript" >Alert ("Illegal access! "); Top.location=xlfun.html; </script>
1. Jump directly into the original form
window.location.href= "The page you are going to jump to";
2. Open the page in a new form with:
window.open (' the page you are going to jump to ');
Window.history.back (-1); Back to previous page
3. Some usage
<input name=" Pclog "type=" button "value="/go "onclick=" location.href= ' connection address ' "> link: <a href=" Javascript:history.go ( -1) "> Return to previous page </a> <a href= "<%=request.servervariables (" Http_referer ")%>" > Return to previous </a> direct jump: <script>window.location.href= ' connection address '; </script> Open a new window: <a href= "/javascript:" onclick= "window.open (' http://www.dolalre.com.cn ', ' ', ' height=500,width=611, Scrollbars=yes,status =yes ') ">123</a> <script> window.open ( ' xlfun.html ', ' newwindow ', ' Height=100,width=400,top=0,left=0,toolbar=no,menubar=no,scrollbars=no,resizable=no, Location=no, Status=no ' ) </script>
After the script runs, Page.html will open in the new form NewWindow, with a width of 100, a height of 400, 0 pixels from the top of the screen, 0 pixels left on the screen, no toolbars, no menu bars, no scroll bars, no resizing, no address bar, no status bar.
"9" Fix error: Potentially dangerous Request.Form value detected from client (content= <p> test </p>)
. NETFramework 4.0 Validaterequest= "False" does not work and needs to revert to 2.0 of the behavior of the ASP. NET request validation feature to be modified in the following settings in the system.web node of the Web. config file The value of Requestvalidationmode is "2.0":
It is important to note that it is necessary to configure validaterequest= "false" in both the page and the configuration file to take effect. Even if it is. NETFramework 4.0 or. NETFramework 4.5, you can also use the 2.0 authentication method.
But doing so increases the security risk of the site and requires careful use.
The "10" C # Memory release is compared in several ways:
Development issue Highlights