Copied from : http://www.proprofs.com/forums/index.php?showtopic=11932 Microsoft 70-536 Objectives Objectives as updated on Microsoft's Web site: March 29, 2007 Developing applications that use system types and collections Manage data in a .NET Framework application by using the .NET Framework 2.0 system types (Refer System namespace) Manage a group of associated data in a .NET Framework application by using collections. (Refer System.Collections namespace) Improve type safety and application performance in a .NET Framework application by using generic collections. (Refer System.Collections.Generic namespace) Manage data in a .NET Framework application by using specialized collections. (Refer System.Collections.Specialized namespace) Implement .NET Framework interfaces to cause components to comply with standard contracts. (Refer System namespace) Control interactions between .NET Framework application components by using events and delegates. (Refer System namespace) Implementing service processes, threading, and application domains in a .NET Framework application Implement, install, and control a service. (Refer System.ServiceProcess namespace) Develop multithreaded .NET Framework applications. (Refer System.Threading namespace) - Thread class
- ThreadPool class
- ThreadStart delegate and ParameterizedThreadStart delegate
- Timeout class, Timer class, TimerCallback delegate, WaitCallback delegate, WaitHandle class, and WaitOrTimerCallback delegate
- ThreadState enumeration and ThreadPriority enumeration
- ReaderWriterLock class
- AutoResetEvent class and ManualResetEvent class
- IAsyncResult interface (Refer System namespace)
- EventWaitHandle class, RegisteredWaitHandle class, SendOrPostCallback delegate, and IOCompletionCallback delegate
- Interlocked class
- ExecutionContext class, HostExecutionContext class, HostExecutionContext Manager class, and ContextCallback delegate
- LockCookie structure, Monitor class, Mutex class, and Semaphore class
Create a unit of isolation for common language runtime in a .NET Framework application by using application domains. (Refer System namespace) Embedding configuration, diagnostic, management, and installation features into a .NET Framework application Embed configuration management functionality into a .NET Framework application. (Refer System.Configuration namespace) Create a custom Microsoft Windows Installer for the .NET Framework components by using the System.Configuration.Install namespace, and configure the .NET Framework applications by using configuration files, environment variables, and the .NET Framework Configuration tool (Mscorcfg.msc). Manage an event log by using the System.Diagnostics namespace. Manage system processes and monitor the performance of a .NET Framework application by using the diagnostics functionality of the .NET Framework 2.0. (Refer System.Diagnostics namespace) Debug and trace a .NET Framework application by using the System.Diagnostics namespace. Embed management information and events into a .NET Framework application. (Refer System.Management namespace) Implementing serialization and input/output functionality in a .NET Framework application Serialize or deserialize an object or an object graph by using runtime serialization techniques. (Refer System.Runtime.Serialization namespace) Control the serialization of an object into XML format by using the System.Xml.Serialization namespace. Implement custom serialization formatting by using the Serialization Formatter classes. Access files and folders by using the File System classes. (Refer System.IO namespace) Manage byte streams by using Stream classes. (Refer System.IO namespace) Manage the .NET Framework application data by using Reader and Writer classes. (Refer System.IO namespace) Compress or decompress stream information in a .NET Framework application (refer System.IO.Compression namespace), and improve the security of application data by using isolated storage. (Refer System.IO.IsolatedStorage namespace) Improving the security of the .NET Framework applications by using the .NET Framework 2.0 security features Implement code access security to improve the security of a .NET Framework application. (Refer System.Security namespace) Implement access control by using the System.Security.AccessControl classes. Implement a custom authentication scheme by using the System.Security.Authentication classes. (Refer System.Security.Authentication namespace) Encrypt, decrypt, and hash data by using the System.Security.Cryptography classes. (Refer System.Security.Cryptography namespace) Control permissions for resources by using the System.Security.Permission classes. (Refer System.Security.Permission namespace) Control code privileges by using System.Security.Policy classes. (Refer System.Security.Policy namespace) Access and modify identity information by using the System.Security.Principal classes. (Refer System.Security.Principal namespace) Implementing interoperability, reflection, and mailing functionality in a .NET Framework application Expose COM components to the .NET Framework and the .NET Framework components to COM. (Refer System.Runtime.InteropServices namespace) Call unmanaged DLL functions in a .NET Framework application, and control the marshaling of data in a .NET Framework application. (Refer System.Runtime.InteropServices namespace) Implement reflection functionality in a .NET Framework application (refer System.Reflection namespace), and create metadata, Microsoft intermediate language (MSIL), and a PE file by using the System.Reflection.Emit namespace. Send electronic mail to a Simple Mail Transfer Protocol (SMTP) server for delivery from a .NET Framework application. (Refer System.Net.Mail namespace) Implementing globalization, drawing, and text manipulation functionality in a .NET Framework application Format data based on culture information. (Refer System.Globalization namespace) Enhance the user interface of a .NET Framework application by using the System.Drawing namespace. - Enhance the user interface of a .NET Framework application by using brushes, pens, colors, and fonts.
- Enhance the user interface of a .NET Framework application by using graphics, images, bitmaps, and icons.
- Enhance the user interface of a .NET Framework application by using shapes and sizes.
Enhance the text handling capabilities of a .NET Framework application (refer System.Text namespace), and search, modify, and control text in a .NET Framework application by using regular expressions. (Refer System.Text.RegularExpressions namespace)
Today I’m switching my default search provider in Internet Explorer over to the new Microsoft Search Engine: Bing. It seems fast, perhaps even faster than Google and with the few searches I’ve done it seems to provide the right results. Did some quick looking around, there is a Bing developer page and Bing API as well. Links:
I’m playing around with code generation using Visual Studio 2008 T4 and I needed to pull in some data. Easiest way to create the data is using Excel and then pull it into a dataset. Using the right connection string this becomes very easy. The code below shows how to select the data from a worksheet. public class Excel2007Reader { private static string BuildExcelConnection( string filename ) { return @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + filename + @";Extended Properties=""Excel 12.0;HDR=YES;"""; } public static DataSet Read( string filename, string worksheet, string range, string tableName ) { DataSet result = new DataSet(); string connectionString = BuildExcelConnection( filename ); string select = @"SELECT * FROM [" + worksheet + "$" + range + "]"; using ( OleDbConnection conn = new OleDbConnection( connectionString ) ) { conn.Open(); using ( OleDbCommand cmd = new OleDbCommand( select, conn ) ) { OleDbDataAdapter da = new OleDbDataAdapter( cmd ); da.Fill( result, tableName ); } conn.Close(); } return result; } }
In our Maine Microsoft Certification Study Group we recently had a discussion about using regular expression. Today I found myself writing a RegEx to check for illegal characters in a formula (string). I thought I’d share the solution: private bool FormulaContainsIllegalCharacters( string formula ) { bool result = false; try { Regex r = new Regex( @"(!)|(@)|(#)|(\$)|(%)|(&)" ); result = r.Match( formula ).Success; } catch { } // ignore any regular expressions errors -> return false return result; } In my case I’m not interested in handling exceptions. If a technical error occurs I will accept the input. Notice that I needed to put a “\” before the $ sign, since the $ is a reserved character marking the end of a line. I don’t need to put each character in “( )” brackets, but for personal preference I just find it easer to read.
Whenever I need one I always need search for a good ASII table. So here is one: | 000 | 00 | 0000 | null | [nul] | | Ctrl-@ | | 001 | 01 | 0001 | start of heading | [soh] | | Ctrl-A | | 002 | 02 | 0002 | start of text | [stx] | | Ctrl-B | | 003 | 03 | 0003 | end of text | [etx] | | Ctrl-C | | 004 | 04 | 0004 | end of transmission | [eot] | | Ctrl-D | | 005 | 05 | 0005 | enquiry | [enq] | | Ctrl-E | | 006 | 06 | 0006 | acknowledge | [ack] | | Ctrl-F | | 007 | 07 | 0007 | bell | [bel] | | Ctrl-G | | 008 | 08 | 0008 | backspace | [bs] | | Ctrl-H | | 009 | 09 | 0009 | horizontal tab | [ht] | | Ctrl-I | | 010 | 0A | 000A | new line, line feed | [nl] | | Ctrl-J | | 011 | 0B | 000B | vertical tab | [vt] | | Ctrl-K | | 012 | 0C | 000C | form feed, new page | [ff] | | Ctrl-L | | 013 | 0D | 000D | carriage return | [cr] | | Ctrl-M | | 014 | 0E | 000E | shift out | [so] | | Ctrl-N | | 015 | 0F | 000F | shift in | [si] | | Ctrl-O | | 016 | 10 | 0010 | data link escape | [dle] | | Ctrl-P | | 017 | 11 | 0011 | device control 1 | [dc1] | | Ctrl-Q | | 018 | 12 | 0012 | device control 2 | [dc2] | | Ctrl-R | | 019 | 13 | 0013 | device control 3 | [dc3] | | Ctrl-S | | 020 | 14 | 0014 | device control 4 | [dc4] | | Ctrl-T | | 021 | 15 | 0015 | negative acknowledge | [nak] | | Ctrl-U | | 022 | 16 | 0016 | synchronous idle | [syn] | | Ctrl-V | | 023 | 17 | 0017 | end of trans. block | [etb] | | Ctrl-W | | 024 | 18 | 0018 | cancel | [can] | | Ctrl-X | | 025 | 19 | 0019 | end of medium | [em] | | Ctrl-Y | | 026 | 1A | 001A | substitute | [sub] | | Ctrl-Z | | 027 | 1B | 001B | escape | [esc] | | Ctrl-[ | | 028 | 1C | 001C | file separator | [fs] | | Ctrl-\ | | 029 | 1D | 001D | group separator | [gs] | | Ctrl-] | | 030 | 1E | 001E | record separator | [rs] | | Ctrl-^ | | 031 | 1F | 001F | unit separator | [us] | | Ctrl-_ | | 032 | 20 | 0020 | Space | Space | | | | 033 | 21 | 0021 | Exclamation mark | ! | | | | 034 | 22 | 0022 | quotation mark | " | " | | | 035 | 23 | 0023 | Number sign | # | | | | 036 | 24 | 0024 | Dollar sign | $ | | | | 037 | 25 | 0025 | Percent sign | % | | | | 038 | 26 | 0026 | Ampersand | & | & | | | 039 | 27 | 0027 | Apostrophe | ' | | | | 040 | 28 | 0028 | Left parenthesis | ( | | | | 041 | 29 | 0029 | Right parenthesis | ) | | | | 042 | 2A | 002A | Asterisk | * | | | | 043 | 2B | 002B | Plus sign | + | | | | 044 | 2C | 002C | Comma | , | | | | 045 | 2D | 002D | Hyphen | - | | | | 046 | 2E | 002E | Period (fullstop) | . | | | | 047 | 2F | 002F | Solidus (slash) | / | | | | 048 | 30 | 0030 | 0 | 0 | | | | 049 | 31 | 0031 | 1 | 1 | | | | 050 | 32 | 0032 | 2 | 2 | | | | 051 | 33 | 0033 | 3 | 3 | | | | 052 | 34 | 0034 | 4 | 4 | | | | 053 | 35 | 0035 | 5 | 5 | | | | 054 | 36 | 0036 | 6 | 6 | | | | 055 | 37 | 0037 | 7 | 7 | | | | 056 | 38 | 0038 | 8 | 8 | | | | 057 | 39 | 0039 | 9 | 9 | | | | 058 | 3A | 003A | Colon | : | | | | 059 | 3B | 003B | Semi-colon | ; | | | | 060 | 3C | 003C | less-than sign | < | < | | | 061 | 3D | 003D | Equals sign; | = | | | | 062 | 3E | 003E | greater-than sign | > | > | | | 063 | 3F | 003F | Question mark | ? | | | | 064 | 40 | 0040 | Commercial at | @ | | | | 065 | 41 | 0041 | A | A | | | | 066 | 42 | 0042 | B | B | | | | 067 | 43 | 0043 | C | C | | | | 068 | 44 | 0044 | D | D | | | | 069 | 45 | 0045 | E | E | | | | 070 | 46 | 0046 | F | F | | | | 071 | 47 | 0047 | G | G | | | | 072 | 48 | 0048 | H | H | | | | 073 | 49 | 0049 | I | I | | | | 074 | 4A | 004A | J | J | | | | 075 | 4B | 004B | K | K | | | | 076 | 4C | 004C | L | L | | | | 077 | 4D | 004D | M | M | | | | 078 | 4E | 004E | N | N | | | | 079 | 4F | 004F | O | O | | | | 080 | 50 | 0050 | P | P | | | | 081 | 51 | 0051 | Q | Q | | | | 082 | 52 | 0052 | R | R | | | | 083 | 53 | 0053 | S | S | | | | 084 | 54 | 0054 | T | T | | | | 085 | 55 | 0055 | U | U | | | | 086 | 56 | 0056 | V | V | | | | 087 | 57 | 0057 | W | W | | | | 088 | 58 | 0058 | X | X | | | | 089 | 59 | 0059 | Y | Y | | | | 090 | 5A | 005A | Z | Z | | | | 091 | 5B | 005B | Left square bracket | [ | | | | 092 | 5C | 005C | Reverse solidus (backslash) | \ | | | | 093 | 5D | 005D | Right square bracket | ] | | | | 094 | 5E | 005E | Caret | ^ | | | | 095 | 5F | 005F | Horizontal bar (underscore) | _ | | | | 096 | 60 | 0060 | Acute accent | ` | | | | 097 | 61 | 0061 | a | a | | | | 098 | 62 | 0062 | b | b | | | | 099 | 63 | 0063 | c | c | | | | 100 | 64 | 0064 | d | d | | | | 101 | 65 | 0065 | e | e | | | | 102 | 66 | 0066 | f | f | | | | 103 | 67 | 0067 | g | g | | | | 104 | 68 | 0068 | h | h | | | | 105 | 69 | 0069 | i | i | | | | 106 | 6A | 006A | j | j | | | | 107 | 6B | 006B | k | k | | | | 108 | 6C | 006C | l | l | | | | 109 | 6D | 006D | m | m | | | | 110 | 6E | 006E | n | n | | | | 111 | 6F | 006F | o | o | | | | 112 | 70 | 0070 | p | p | | | | 113 | 71 | 0071 | q | q | | | | 114 | 72 | 0072 | r | r | | | | 115 | 73 | 0073 | s | s | | | | 116 | 74 | 0074 | t | t | | | | 117 | 75 | 0075 | u | u | | | | 118 | 76 | 0076 | v | v | | | | 119 | 77 | 0077 | w | w | | | | 120 | 78 | 0078 | x | x | | | | 121 | 79 | 0079 | y | y | | | | 122 | 7A | 007A | z | z | | | | 123 | 7B | 007B | Left curly brace | { | | | | 124 | 7C | 007C | Vertical bar | | | | | | 125 | 7D | 007D | Right curly brace | } | | | | 126 | 7E | 007E | Tilde | ~ | | | | 127 | 7F | 007F | delete | [del] | | |
Another little extension method. This one allows easy rounding to a specific number of decimals: double d = 0.66782423; string s = d.ToString(3); // s = “0.668” This is done by the following method: public static class DoubleExtension { public static string ToString( this double value, int decimals ) { StringBuilder format = new StringBuilder( "0" ); if ( decimals > 0 ) { format.Append( "." ); } for ( int i = 0; i < decimals; i++ ) { format.Append( "0" ); } return value.ToString( format.ToString() ); } }
The leading event for C#, VB.Net, ASP.NET, DotNetNuke and Delphi developers is now open for registration! For the 18th year running the Software Development Network will organize this 2 day event (on October 19th and 20th, 2009) with sessions about : - .NET (C#, VB.Net, F#, etc.)
- User eXperience (ASP.Net, Silverlight, Expressions, Flash, etc.)
- Information Worker (MOSS, BizTalk, OBA, etc.)
- DotNetNuke (OpenForce Europe ’09 conference)
- Delphi
- Architecture
- Core Systems (C, Cobol, NonStop, IDMS, PL/1, DB2, CICS, TSO, ISPF, etc.)
- Databases
Don’t miss out! Click here to register.
 | Visual Studio 2010 and .NET FX 4 Beta 1 are available for download from the MSDN Subscriber Downloads as of today. Go to: VS2010 Beta 1 Download for MSDN The 5 page factsheet for VS2010 can be found here. |
Today I had to fix a bug in some code involving a program creating multiple files where each file needed to have a unique machine generated filename. I was building my own unique name using the DateTime.Now.Ticks().ToString() as part of the name. Apparently on some machines the Ticks are not going to be unique. So I looked at the Path.GetTempFile() method, but I needed to control the location of the temporary files. Next stop: Path.GetRandomFileName(). Documentation: The GetRandomFileName method returns a cryptographically strong, random string that can be used as either a folder name or a file name. Unlike GetTempFileName, GetRandomFileName does not create a file. When the security of your file system is paramount, this method should be used instead of GetTempFileName. Works great!
The documentation doesn't specifiy it but in the Entity Framework when you call ObjectContext.SaveChanges the update is 'wrapped' in a transaction. NorthwindIBModel model = new NorthwindIBModel(); Guid id = Guid.NewGuid(); model.AddToCustomer(new Customer() { CustomerID = id, ContactName = "Andrew", CompanyName = "Northwind Traders" }); model.AddToCustomer(new Customer() { CustomerID = id, ContactName = "Aikido", CompanyName = "Northwind Traders " });
model.SaveChanges(); // exception duplicate key - transactional -> no changes to the database
I had to find out which platform supports which version of the .NET Framework. The information is a little fragmented, but here is the overview I came up with. Windows 95 The .NET Framework cannot be installed on Windows 95. Windows 98 .NET 1.0, .NET 1.1, .NET 2.0, .NET 3.0 Windows 98 SE .NET 1.0, .NET 1.1, .NET 2.0, .NET 3.0 Windows ME .NET 1.0, .NET 1.1, .NET 2.0, .NET 3.0 Windows NT 4.0 SP6a .NET 1.0, .NET 1.1 Windows XP .NET 1.0, .NET 1.1 Windows XP SP2 .NET 1.0, .NET 1.1, .NET 2.0, .NET 3.0, .NET 3.5 Windows 2000 .NET 1.0, .NET 1.1 Windows 2000 SP4 .NET 1.0, .NET 1.1, .NET 2.0 Windows Vista .NET 2.0, .NET 3.0, .NET 3.5 Windows 2000 Server SP2 .NET 1.0, .NET 1.1 Windows Server 2003 .NET 1.1, .NET 2.0, .NET 3.0 Windows Server 2003 SP1 .NET 1.1, .NET 2.0, .NET 3.0, .NET 3.5 Windows Server 2003 R2 .NET 2.0, .NET 3.0, .NET 3.5 Windows Server 2008 .NET 2.0, .NET 3.0, .NET 3.5 Just to be clear, .NET 3.5 cannot be installed on: - Microsoft Windows 95
- Microsoft Windows 98
- Microsoft Windows Millennium Edition
- Microsoft Windows NT Server
- Windows NT Workstation
- Windows NT Server Enterprise Edition
- Microsoft Windows 2000 Professional
- Windows 2000 Server
- Windows 2000 Advanced Server
- Windows 2000 Datacenter Server
- Windows Server 2003, Enterprise Edition for Itanium-based Systems
- Windows Server 2003, Datacenter Edition for Itanium-based Systems
References: [UPDATE: .NET 3.0 will not run on Windows 2000 or Windows 200o SP4]
I regularly get asked for references on which books are interesting for people starting with C# and .NET. I'm not good at remembering books, but usually squeeze out a reference. Today I ran across a good list of Essential Reading compiled by my DevelopMentor colleague Tony Sneed. I'm shamelessly copying it here since I concur with his list. Essential .Net 2.0 Reading The C# Language .Net in General Windows Forms
Web Apps
Essential .Net 3.0 Reading Presentation Foundation
Workflow
Communication Foundation
CardSpace
My article on combining AIM Call Out with geocoding a phone number to display the location of the person you're trying to call has gone live on the AOL Developer Network. I think it turned into a very cool sample application. Dial a number and see the location of the person you're calling!
The article I wrote about building a Voice over IP .NET application using AIM Call Out and the AOL Open Voice API has just gone live on the AOL Developer Network. Read it here.
A lot is being blogged about the availability of VS 2008 SP1 and TFS SP1. It contains fixes and many new features and sound almost too good to be true, but I checked, it's not an April fool's joke  A little lost in the noise about new features is the fact that .NET Framework 3.5 SP1 will include .NET CLR 2.0 SP2. I've been unable to find anything about this other than this one post by Eric Eilebrecht, but any CLR update is significant.
In the .NET Framework, most of the time, the name of an assembly matches the namespace of the classes in that assembly.
Since WCF is kind of an add-on to the .NET 2.0 Framework this is not quite true for the assembly System.ServiceModel.Web.dll
Below a screenshot of what .NET Reflector shows to be inside this assembly.

As you can see this assembly extends a number of namespaces like System.Runtime.Serialization and System.Collections.ObjectModel.
The Json serialization classes are also in this assembly.
The last couple of weeks I've been working on migrating an ASP.NET application from using a Visual FoxPro database to using SQL Server 2005. My application has it's logic in library DLL and with some layering uses Typed DataSets to connect to the database.
Typical code within the data access layer looks like this:
internal ViewDataSet.RequestViewDataTable GetViewByPrimaryUser( string user ) { using ( ViewDataSetTableAdapters.RequestViewTableAdapter _adapter = new ViewDataSetTableAdapters.RequestViewTableAdapter() ) { ViewDataSet.RequestViewDataTable table; table = _adapter.GetByPrimaryUser( user.Trim() ); return table; } }
The method 'GetByPrimaryUser' is defined on the TableAdapter and using the GUI designer in Visual Studio I manage my typed datasets. All SQL is stored within the Typed DataSets. There is very limited use of stored procedures.
Migrating the .NET code from using a Visual FoxPro database to using SQL Server 2005 has involved the following:
- Change the connection string property on every datatable to use the SQL Server connection string instead of the FoxPro connection string.
- Opening every single query and changing the SQL parameters from question marks '?' to named parameters like '@user'.
- Rechecking the mapping of the columns in the datatable, sometimes these would get messed up. Especially in cases where non-database columns where added to the datatable.
- Rechecking column expressions.
- Some areas of the code accessed the OleDbDataAdapter and OleDbConnection within the typed dataset, this had to be replaced with SqlDataAdapter and SqlConnection.
- FoxPro does not support the .NET light weight transactions, so code to custom manage the transaction could be deleted and a simple 'using( TransactionScope tx = new TransactionScope() )' could be implemented.
- There where several areas where 'adapter.Update(row)' did not work with FoxPro, so the Insert/Update/Delete had to be called manually in the data access layer. With SQL Server there are no problems and this 'fix-it' code could be removed.
After following these steps some of the datatables would generate unexplicable validation errors. Not wanting to waste too much time I just re-created those typed tables and re-added the queries on those tables.
 Since the advent of cheap web hosting, we have had more development in the field of SEM. Thanks to features like internet phone, managing internet network marketing is a lot more feasible now. Marketing strategies like cpc, ppi and pay per click can be managed with much more comfort now. Usually regular advertising agencies miss out on this since they concentrate more on building links through email marketing.
Another gem in .NET 2.0. Parsing a string to get a datetime used to be pretty complex. But now with the DateTime.ParseExact(...) method you can specify the exact format of your string.
string s = "20071231T214559"; DateTime d = DateTime.ParseExact( s, "yyyyMMddTHHmmss", null ); this.textBox2.Text = d.ToString(); // this will print: 31-12-2007 21:45:59
Steve Tibbet has a post describing all the options for specifying the format.
The .NET Framework is huge and I still frequently find new things in .NET 2.0 which I had not seen before. Last week I stumbled across the update in Math.Round(...). In .NET 1.x the .NET Framework would only support the American way of rounding numbers. This means that:
decimal y = 2.5M; decimal x = Math.Round(y, 0); // x = 2
For Dutch people this wrong. We would expect x to be '3'. In .NET 2.0 there is a new overload, allowing you to specify how the Round method should work.
decimal y = 2.5M; decimal x = Math.Round(y, 0, MidpointRounding.AwayFromZero); // x = 3!
|