Hashing is used to create a unique, compact value for a plaintext message. "Message" is a very broad term here; in terms of assemblies, the message is the assembly itself. The message is used as an input to the hash algorithm (in the case of strong naming, the SHA1 algorithm is used).
File.dll---->SHA1 Hash Algoritm---->Hash Value(SDFSDFJG2345ASDHFAS23)
Hashing is a one-way street: you can't decrypt the hash value once it has been computed. However, hashing is very useful for comparing values. If two assemblies produce the same hash value, you can assume that the assemblies are the same. Conversely, if hashing an assembly produces a value that doesn't match a previously-calculated hash, you know that something in the assembly has been changed.
Knowing the hash value for an assembly lets you check that no one has tampered with the assembly. But how do you prevent someone from tampering with the hash value? That's where digital signing comes in. While the mathematics of digital signatures are complex, the concept is fairly simple. A digital signature depends on a pair of related numbers, the public key and the private key. When data is encrypted with the public key, it can only be decrypted with the private key (and vice versa)
Strong Naming for Assembly IdentityThe combination of hashing and digital signing allows .NET to protect your assemblies from tampering. Here's how it works. First, a hash value is created from the assembly. Then, the hash value is encrypted with your private key and placed, along with your public key, in the assembly itself.
My.dll--->SHA1--->Assembly Hash--->Public Key--->My.dll+Digital Signature.
The CLR validates assemblies at runtime by comparing two sets of hash values. First, the public key is used to decrypt the encoded version of the hash. Second, a new hash is computed from the current contents of the assembly. If the two hashes match, all is well.
My.dll--->SHA1--->New Hash
My.dll+Digital Signature--->Public Key--->Original Hash
What happens if an assembly has been tampered with after it was signed? In this case, the new hash value calculated at runtime won't match the stored hash value that was encrypted with your private key. Under those circumstances, the CLR will refuse to load the assembly.
Note that the strong name guarantees the integrity of the assembly, not necessarily its safety! There's nothing to prevent someone from creating a malicious assembly and signing it with a strong name. You can use a strong name to verify that an assembly came from a particular source, and that it wasn't tampered with after it was signed. It's up to you to decide, based on whatever information you choose, whether to trust code from that source.
What's in a (Strong) Name?In addition to a hash derived from the assembly's contents, the strong name includes three other pieces of information:
The simple text name of the assembly
The version number of the assembly
The culture code (if any) of the assembly
All of this information works together to supply a unique identity for each assembly. The CLR uses this information when deciding whether a particular assembly is the one called for by a reference from another assembly. When you set a reference from one assembly to another, the calling assembly stores a representation of the called assembly's public key. At runtime, the CLR can use this to check that the referenced assembly comes from the correct vendor.
O'Reilly Network: The Secrets of Strong Naming [Apr. 28, 2003]
Prologue: Comctl32.dll, version 6. Comctl32.dll, or the Common Controls, have been around for a very long time. This library provided basic common controls while User32.dll provided user controls. In version 6 of the Common Controls, all of the controls were put in Comctl32.dll so that all the controls could support theming. Comctl32.dll, version 6, is not redistributable, however, unlike previous versions of Comctl32.dll. In order to use the new Windows XP Visual Styles, you must be using an operating system that contains Comctl32.dll, such as Windows XP.
For supported controls, the control style is associated with a particular theme resource that is drawn in the client area of the control. For controls deriving from ButtonBase, GroupBox, and Label, these controls must use the FlatStyle.System enumeration member in their FlatStyle property so that they allow the operating system to draw the controls.
In order to tell Windows to use theming for your controls, you need to tell Windows to bind to Comctl32.dll, version 6. By default, Windows binds to Comctl32.dll, version 5. Similar to the binding policies of .NET, however, we can tell executables at runtime to bind to other assemblies, or Win32 libraries in this case.
So, add a new XML file to your project and call it
.exe.manifest, where is the name of the output file your project generates, which is your project name by default. Set the Compile Type to "None", since we'll only including this in your project for simplicity.
If you used the "AssemblyInfo.cs" code above, your newly created .exe.manifest should look like:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity
version="1.0.0.0"
processorArchitecture="X86"
name="Theme Test" type="win32" />
<description>Windows XP Styles.</description>
<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
processorArchitecture="X86"
publicKeyToken="6595b64144ccf1df"
language="*" />
</dependentAssembly>
</dependency>
</assembly>
You should replace the first "version" and "name" attributes with appropriate values for your project, which are the AssemblyVersion and AssemblyTitle attributes respectively. The "description" element should also match your AssemblyDescription attribute.
Next, open a command prompt and change directories to your project output directory, which should be "bin\Debug" with your project directory as the root. Assuming that you have "sn.exe" in your PATH (part of the .NET Framework SDK), type the following:
sn.exe -k ..\..\KeyFile.snk
This should put a public key file named KeyFile.snk - which we referred to earlier in our AssemblyInfo.cs file - in your project directory. This public key is necessary to sign your assembly with a strong name, which is required in many situations and is recommend for every assembly.
Adding the Manifest and the Final Touches
1. You should now be in the same directory as your project output file. In my example, my application is simply "WindowsApplication1.exe", which I'll refer to later.
2. Now, back in Visual Studio .NET, click on the File->Open... menu, browse to your application such as "WindowsAppication1.exe", and click open. You should now see your resources in a tree view.
3. Right-click on the root node ("WindowsApplication.exe") and select "Add Resource...".
4. Click "Import...", browse for "WindowsApplication.exe.manifest" in your project directory, and click "Open".
5. In the "Resource Type" text box, type RT_MANIFEST and click "OK".
6. Save all files and go back to your resource view you were previously in. You should now see a folder named "RT_MANIFEST".
7. Click on the newly added RT_MANIFEST resource, probably named 101. Change its ID to 1 in the property grid and save your application again.
After closing the resource view in which your application was open, go back to the command prompt and type the following:
sn -R WindowsApplication1.exe ..\..\KeyFile.snk
The tool should print some version info and then display:
Assembly 'WindowsApplication1.exe' successfully re-signed
Run your application and see Windows XP Visual Styles at work in your .NET application!
Summary
Windows XP Visual Styles can be a very good addition to your applications and control libraries and they don't take a lot of work. Supporting this new visual style will give your application a common look-and-feel with Windows, which is always a definite plus in commercial applications. Many companies strive to keep up with Windows standards and now you can do it without a lot of work.
Just remember to set the FlatStyle property of any applicable control to FlatStyle.System and to embed the manifest resource like the boilerplate above in your executable after compiling. After having done all that, you need only finish signing your assembly, otherwise it won't pass validation if you specified an AssemblyKeyFile. If you need to test your application or have an authority sign it, you can turn off validation for that assembly by typing the following:
sn.exe -Vr WindowsApplication1.exe
Resource:
Windows XP Visual Styles for Windows Forms
MSDN
.NET Ideas
MyIE2 is the most powerful and fully customized browser. It can open multiple web pages in just one window, and come with tons of other nice features.
MyIE2 Online
Using Jump Statements in C#
The goto, break, and continue statements are known as jump statements. You use them to transfer control from one point in the program to another, at any time. In this section, you will learn how to use jump statements in C# programs.
The goto Statement
The goto statement is the most primitive C# jump statement. It transfers control to a labeled statement. The label must exist and must be in the scope of the goto statement. More than one goto statement can transfer control to the same label.
if (number % 2 == 0)
goto Even;
Console.WriteLine("odd");
goto End;
Even:
Console.WriteLine("even");
End:;
The goto statement can transfer control out of a block, but it can never transfer control into a block. The purpose of this restriction is to avoid the possibility of jumping past an initialization. The same rule exists in C++ and other languages as well.
The goto statement and the targeted label statement can be very far apart in the code. This distance can easily obscure the control-flow logic and is the reason that most programming guidelines recommend that you do not use goto statements.
Note: The only situations in which goto statements are recommended are in switch statements or to transfer control to the outside of a nested loop.
The break and continue Statements
A break statement exits the nearest enclosing switch, while, do, for, or foreach statement. A continue statement starts a new iteration of the nearest enclosing while, do, for, or foreach statement.
The following code writes out the values zero through nine.
int i = 0;
while (true)
{
Console.WriteLine(i);
i++;
if (i <
10)
continue;
else
break;
}
The break and continue statements are not very different from a goto statement, whose use can easily obscure control-flow logic. For example, you can rewrite the while statement in the preceding example without using break or continue as follows:
int i = 0;
while (i < 10)
{
Console.WriteLine(i);
i++;
}
Preferably, you can rewrite the previous code by using a for statement, as follows:
for (int i = 0; i < 10; i++) {Console.WriteLine(i);
}
Msn/Window Messenger Polygamy allows you to run more than one copy of MSN messenger, as well as many accounts simultaneously. To use the program, install it, and then run it from the Programs menu - each time you run it, a new copy of MSN will be launched.
Window/Msn Messenger Polygamy
Change registry by using regedit. If you have XP you can do this also by using powertoys (tweakxp)
HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Command Processor
Right click on CompletionChar
DWORD change that to 9
restart and you are done. Pressing tab in the command line can complete the next match of the command that you are typing.
It appears you can get a list of the world's favourite sites by going to Google and searching for www.
Srinivasa Sivakumar has listed more than 500 sample chapters (in HTML/PDF format) on his
resource site, from various books related to .NET. A great resource!
Microsoft's Command-Line Compiler
You do not need to buy Visual Studio .NET in order to program in C#. On the Windows platform, you can do everything with a text editor and the C# command-line tools that are provided in the Platform SDK(130MB)
Mono
Mono is an effort to make an Open Source implementation of the .NET Development Framework and includes a free C# compiler
DotGNU Portable.NET
A British-based Open Source implementation of the .NET Development Framework targeting Linux, includes C# compiler
SharpDevelop
SharpDevelop is an Open Source development environment for .NET written by Mike Kruger.
Kraig Brockschmidt, former employee of Microsoft has wrote this book... it is still in draft.. worth a read :)... Its not about MS 's products or not abt the fight with linux/opensource etc.. Its abt the spiritual transformation which the author went thru during his 8 yrs at MS. very different.
-
You will be able to drag a SQL Server table and drop it into a page, which will give you a data binded datagrid, mostly through property manipulation, the grid will be sortable, editable and updatable
-
One goal of ASP.NET 2.0 is to reduce the amount of code needed by 70-75%, Scott thinks Whidbey will get very close to that mark
-
Another goal is to simplify administration, ASP.NET 2.0 will offer a rich configuration API along with rich admin tools, in the bottom you will still have good old XML config files
-
We will get Intellisense in config files and in code embedded in web forms (as opposed to code-behind classes)
-
We will get some 40 new controls, including things like a rich treeview and security controls (authentication). Controls will work with both two-tier and three-tier data models.
-
We will have building blocks APIs services, like for example: membership services, role management and a personalization system
-
This APIs will use a provider model, so that you can create, for example, your own credentials provider and replace the one that's used out of the box by the authentication block (SQL Server tables, it seems)
-
The template columns design-time editor will get a major update, including two-way databinding and custom controls that can be dragged and dropped into the column (for example, drop-downs)
-
ASP.NET 2.0 will be 64-bit enabled
-
In particular, IIS 6.0 will allow two use the ASP.NET authentication information to control access to classic ASP pages and even other resources like images or JSP pages
-
An administrator could be notified by e-mail every time a certain exception raises
-
Nothing to do with ASP.NET 2.0: in a few weeks a utility to convert classic ASP pages to ASP.NET will be available at
www.asp.net
-
Enterprise Services will allow you to start/stop a transaction at any fixed point in your code, you will not be constrained to object boundaries
-
There will be a data access layer designer which will allow you to choose tables, views, add properties and then access all this elements in a strongly-typed way
-
Alternatively, you will be able to use Object Spaces, which is an object-relational mapping tool that will be released as part of Whidbey
-
Yukon and Whidbey have the same release timeframe
-
To create Yukon user-defined types you will be able to use any CLR value class (C# struct)
-
The Cache object will be enhanced so that you can, for example, make a dataset valid as long as the underlaying source (a table, usually) doesn't change.
Microsoft .NET ObjectSpaces are a set of classes and interfaces that enable you to treat data as an object (or objects), independent of the underlying data store used by an application. ObjectSpaces builds on and contains a set of new data access APIs within the Microsoft .NET Framework to provide access to relational data sources such as Microsoft SQL Server®, OLE DB data sources, etc.
You can use the ObjectSpaces to perform the following data related tasks/steps:
-- Get data as objects from a data source using a particular query criteria
-- Navigate one-to-many or one-to-one relationships using the objects returned
-- Modify the values/properties of the objects
-- Resolve changes back to the data source