I will be speaking at the next meeting of the New England C# User's Group on New Features of the 2.0 Framework. If you're in the Manchester NH area, stop on by.
Encrypt, decrypt, and hash data by using the System.Security.Cryptography classes. (Refer System.Security.Cryptography namespace)
- DES class and DESCryptoServiceProvider class
- HashAlgorithm class
- DSA class and DSACryptoServiceProvider class
- SHA1 class and SHA1CryptoServiceProvider class
- TripleDES and TripleDESCryptoServiceProvider class
- MD5 class and MD5CryptoServiceProvider class
- RSA class and RSACryptoServiceProvider class
- RandomNumberGenerator class
- CryptoStream class
- CryptoConfig class
- RC2 class and RC2CryptoServiceProvider class
- AssymetricAlgorithm class
- ProtectedData class and ProtectedMemory class
- RijndaelManaged class and RijndaelManagedTransform class
- CspParameters class
- CryptoAPITransform class
- Hash-based Message Authentication Code (HMAC)
Knowing some basics about Cryptography is a big help with this objective. Dino Esposito has an article on DevX going over the basics. It's based on 1.1, but the ideas haven't changed.
For the most part this namespace hasn't changed. ProtectedData/Memory and HMAC are the new classes they want you to know about.
DES class - Abtract class that all (one) DES implementations derive from. DES is a symmetric encryption algorithm. It's an old algorithm that can be cracked in a matter of days.
DESCryptoServiceProvider class - Service provider class for DES encryption. Derives from DES and is the class you'd use when encrypting/decrypting with DES.
HashAlgorithm class - base class that all hash algorithms derive from. MSDN has an example implementation showing that you invoke the ComputeHash method to get the hash.
DSA class - base class that all (one) DSA implentations derive from. Richard Grimes has a blurb about digital signatures on his security workshop page.
DSACryptoServiceProvider class - provides an implementation of the DSA (Digital Signature Algorithm) .
SHA1 class - Abtract class for the SHA1 Hash algorithm. 160 bit hash size.
SHA1CryptoServiceProvider class - Implementation of the SHA1 hash algorithm. There's some concern that this algorithm is weak, so it's probably best to use a different hashing algorithm.
TripleDES class - Abtract class for the TripleDES encryption algorithm. TripleDES is a symmetric algorithm support key sizes of 128 or 192 bits.
TripleDESCryptoServiceProvider class - Implementation of the TripleDES encryption algorithm, which appears to encrypt the text by running DES 3 times.
MD5 class - Abtract class that all MD5 hash algorithms derive from. MD5 produces a 128 bit hash.
MD5CryptoServiceProvider class - Implementation of the MD5 Hash Algorithm. It appears there might be weaknesses with this algorithm as well.
RSA class - Abtract class that all RSA encryption algorithms derive from. RSA is an asymmetric algorithm supporting bit sizes between 384 - 16384 bits in increments of 8 bits.
RSACryptoServiceProvider class - Implementation of the RSA Encryption algorithm. There don't appear to be flaws in the RSA algorithm provided your key is >2k.
RandomNumberGenerator class - Abtract class that all Random Number generators are supposed to derive from. There is only one implementation of a random number generator - RNGCryptoServiceProvider. Christopher Wille has an example that creates random passwords using the RNGCryptoServiceProvider.
CryptoStream class - defines a stream that is used with cryptographic functions. The idea is to prevent storing the data in an intermediate area during cryptographic functions. It also handles buffering which I guess gets complicated with block ciphers.
CryptoConfig class - Documentation says that it is used to get cryptography configuration information. I don't see it doing that. It appears that the main method, CreateFromName, is used to get an instance of a specific CryptoServiceProvider. There is mention of the CryptoConfig being used in this best practices in Mono document.
RC2 class - Abtract class that all RC2 implementations derive from. RC2 is an Symmetric Encryption algorithm.
RC2CryptoServiceProvider class - Implementation of the RC2 Encryption algorithm. Key size is from 40-128 bits in 8 bit increments.
AssymmetricAlgorithm class - base class for all encryption methods that are classified as Assymmetric (meaning public key algorithms) Dr. Peter Bromberg has a simple example of using the RSA classes.
ProtectedData class - This is a new class for the 2.0 framework. It is a frontend to the DPAPI protect and unprotect methods, making it very easy to secure data using DPAPI. Remember that stuff protected by DPAPI can only be unprotected on the same machine.
ProtectedMemory class - Also a new class for the 2.0 framework. It works the same as ProtectedData. The difference is that ProtectedMemory is only valid until the machine reboots. Shawn has an informative post on his blog.
RijndaelManaged class - A managed implementation of the Rijndael encryption algorithm, also known as AES. Rijndael is a symmetric algorithm supporting key sizes of 128,192, and 256 bits.
RijndaelManagedTransform class - the actual class that does the encryption/descryption for the RijndaelManaged class.
CspParameters class - contains parameters that are passed to the CSP (Cryptographic Service Provider). This is used to pass specific parameters back to the Crypto subsystem. An example is specifying which key container to use. Gowri Paramasivm has an example using RSA.
CryptoAPITransform class - Represents a cryptographic algorithm that encrypts or decrypts data.
HMAC (Hash-based Message Authentication Code) - Abstract class that all implementations of HMAC derive from. HMAC is a way of verifying the authenticity and integrity of a message. These are new classes.
Next up -> Permissions
Implement a custom authentication scheme by using the System.Security.Authentication classes. (Refer System.Security.Authentication namespace)
- Authentication algorithms and SSL protocols
Another new namespace. Not much meat there. I think they're trying to get you to look at the AuthenticatedStream class in System.Net.Security. Keith Brown has a good example implementation in his "The .NET Developer's Guide to Windows Security"
The algorithms that are implemented appear to be:
NegotiateStream - "Uses the Negotiate security protocol to authenticate the client." Is there such a thing as the "Negotiate security protocol"? I'm not finding anything on it. Sample uses of this class appear to communicating with a server authenticating via Kerberos.
SslStream - "Provides a stream used for client-server communication that uses the Secure Socket Layer (SSL) security protocol to authenticate the server and optionally the client. " Dominick Baier has a nice simple example.
Next up -> Cryptography
Implement access control by using the System.Security.AccessControl classes.
- DirectorySecurity class, FileSecurity class, FileSystemSecurity class, and RegistrySecurity class
- AccessRule class
- AuthorizationRule class and AuthorizationRuleCollection class
- CommonAce class, CommonAcl class, CompoundAce class, GeneralAce class, and GeneralAcl class
- AuditRule class
- MutexSecurity class, ObjectSecurity class, and SemaphoreSecurity class
This is a completely new namespace. The .NET framework now has direct support for reading and maintaining ACLs (Access Control Lists, or NT Permissions). This was difficult to do previously because you had to use unmanaged calls to the Win32 subsystem.
You should probably have some rudimentary understanding of how the access control works. Wenfeng Yao has a nice post explaining the different terms.
Rich Strahl has a good simple example of how these classes work. Like he says, it's not to hard once you see how it's done. There's also an informative MSDN article (based on the beta) about the Access Control objects.
DirectorySecurity class - This embodies the access and audit information for a specific directory. Create an instance by passing in the path in the constructor.
FileSecurity class - Same thing, but for a specific file.
RegistrySecurity class - Same thing for a registry key.
FileSystemSecurity class - base class for both DirectorySecurity and FileSecurity.
AccessRule class - To borrow a database metaphor, this is the many to many table for security. It combines an Identity and an AccessControlType to represent a specific permission.
AuthorizationRule class - base class of AccessRule and AuditRule.
AuthorizationRuleCollection class - collection of AuthorizationRule instances. Typical collection, no new methods.
CommonAce class - Represents an Access Control Entry(ACE). These objects allow you to deal directly with ACE/ACLs, whereas the Security/Rule classes provide some abtraction and validation. "The CommonAce class represents the eight most common ACE types". But I can't find what the eight most common ACE types are. I looked at the class in reflector, I think they're talking about AccessAllowed, AccessDenied, SystemAudit, SystemAlarm, AccessAllowedCallback, AccessDeniedCallback, SystemAuditCallback, SystemAlarmCallback... But I'm not sure. There are a lot of opportunities for improvement in the documentation for these classes.
CommonAcl class - Represents an Access Control List(ACL). Meaning either SACL or DACL.
CompoundAce class - Represents a Compound ACE. As the only member of the CompoundAceType enum is Impersonation, I'm guessing that a compound ace has something to do with Impersonation. Looking further using reflector, it appears a CompoundAce object is created in the GenericAce.CreateFromBinaryForm when the AceType = AccessAllowedCompound. According to MSDN : "Defined but never used. Included here for completeness. "...
GeneralAce class - Represents a generic ACE. Base class for all ACE classes.
GeneralAcl class - Represents a generic ACL. Base class for all 4 ACL classes.
AuditRule class - This similiar to an AccessRule, but represents Audit information.
MutexSecurity class - Similiar to FileSecurity, but for Named Mutexes. For those of you unfamiliar with Named Mutexes (I was), look at King Ralph's blog entry.
ObjectSecurity class - Base class for all the xxxSecurity objects.
SemaphoreSecurity class - Similiar to MutexSecurity, but for Named Semaphores.
Next post - Authentication
On this week's MSDN flash, they released promo codes (meaning you can register for free) for 4 other beta exams:
The first three are exams you would take for the MCPD certification, unless you were already an MCSD or MCAD. The SQL Server one is part of the MCITP certification as a database developer.
Between now and March 10, I'm scheduled to take 5 exams... There go my weekends.
UPGRADE: MCAD Skills to MCPD Web Developer by Using the Microsoft .NET Framework UPGRADE: MCAD Skills to MCPD Windows Developer by Using the Microsoft .NET Framework UPGRADE: MCSD Microsoft .NET Skills to MCPD Enterprise Application Developer by Using the Microsoft .NET Framework: Part 1
Access files and folders by using the File System classes. (Refer System.IO namespace)
- File class and FileInfo class
- Directory class and DirectoryInfo class
- DriveInfo class and DriveType enumeration
- FileSystemInfo class and FileSystemWatcher class
- Path class
- ErrorEventArgs class and ErrorEventHandler delegate
- RenamedEventArgs class and RenamedEventHandler delegate
File class - Static class used for moving/renaming files. They've added quite a few methods for convience and better exposed the feature set of NTFS. Look at AppendAllText, Decrypt, Encrypt, GetAccessControl, ReadAllBytes, ReadAllLines, ReadAllText, Replace, SetAccessControl, WriteAllBytes, WriteAllLines, WriteAllText
FileInfo class - Each instance of this class represents a file. Members are similiar to the File class. Doesn't have some of the convenience methods like ReadAllText, WriteAllText...
Directory class - Static class used to manipulate file directories. Doesn't appear to have changed except GetAccessControl and SetAccessControl methods have been added.
DirectoryInfo class - Each instance of this class represents a directory. Members are similiar to the File class. Also has GetAccessControl and SetAccessControl methods.
DriveInfo class - New class that allows you to query to see what drives (logical) are attached to a system. Each instance represents a drive. You can get the capacity, volume label, free space, and the type of drive.
DriveType enum - enum that specifies the type of drive represented by the DriveInfo class. CDROM, Fixed, Network, RAM, Removeable (USB or floppy), unknown. There is also a NoRootDirectory member. I don't know what that is for. The enum is not decorated with the FlagsAttribute, so a DriveType can't be Fixed AND NoRootDirectory.
FileSystemInfo class - base class for both FileInfo and DirectoryInfo
FileSystemWatcher class - I hate this component. I used it in an project and kept missing files because the buffer would overflow and the error event wasn't consistently raised. Read the class description and understand the limitations of the component. It doesn't look like it has been changed(meaning new methods and properties).
Path class - Allows you do deal with filename strings in a controlled fashion. If you want to change the extension, call the ChangeExtension method, rather than doing the string parsing yourself. Has some interesting members that I didn't know about, such as GetTempFilename. There is a new method called GetRandomFilename. It returns a random temp filename, but doesn't create it. GetInvalidFileNameChars and GetInvalidPathChars are also new.
ErrorEventArgs - object that is supplied to the error event in the FileSystemWatcher when something goes wrong. GetException returns the exception object for the error. Like I said, I had problems with the FileSystemWatcher. Know it for the test, but don't use it in a real project.
RenamedEventArgs - object that is supplied to the rename event in the FileSystemWatcher. Has OldFullPath and OldName properties. Derived from FileSystemEventArgs
Next up - System.IO.Compression
I don't usually put personal stuff into this blog, but I think today can be an exception. We finalized the adoption of our daughter Sara today! She's officially a Denoncourt! If you haven't heard her story and can put up with a little preaching, you can hear it here.
I wish that more people would consider adoption. It's really a great chance to change the world. One of the things that I hear is that that people have the impression that there is a shortage of children available to be adopted. While it is true that there are not a lot of infants to be adopted, there are a lot of older children waiting for homes. Another consideration is that people think that it costs a lot to adopt a child. The costs of adopting an infant can be towards $50k for domestic, and between 10-30k for international infant. If you're willing to adopt a child through the state, you are eligible for a $10,000 tax credit (that's basically adding $10,000 to your tax return) and you might receive a monthly stipend as well. An excellent resource on the Internet is adoption.com. If you call your state's family protection department, you can find when they hold informational meetings. Adoption is an amazing experience. Ours was an open adoption, which means that the birth parents can still visit Sara and know her as she grows up.. But we are her parents. I think this takes a lot of the tension out of the process and is more healthy for everyone - baby, us, and the birth parents.
I'll get back to the study guide tomorrow.
UPGRADE: MCAD Skills to MCPD Web Developer by Using the Microsoft .NET Framework UPGRADE: MCAD Skills to MCPD Windows Developer by Using the Microsoft .NET Framework UPGRADE: MCSD Microsoft .NET Skills to MCPD Enterprise Application Developer by Using the Microsoft .NET Framework: Part 1
Control the serialization of an object into XML format by using the System.Xml.Serialization namespace.
- Serialize and deserialize objects into XML format by using the XmlSerializer class.
- Control serialization by using serialization attributes.
- Implement XML Serialization interfaces to provide custom formatting for XML serialization.
- Delegates and event handlers provided by the System.Xml.Serialization namespace
So the basics of using the XmlSerializer hasn't changed. Create an XmlSerializer telling it to expect a particular type. Note that the type could be a Generic - typeof(SortedList<int>) . Know that you can supply override to the XML Attributes. See my post here. Know how to control namespaces using XmlSerializerNamespaces class.
Remember the performance problems with XML Serializer? Creating a new dynamic assembly each time the app was restarted for XML Serialization? There is a new tool, SGen.exe that creates the temporary serialization assemblies for you.
Here are the XML Attributes used to control serialization:
XmlRoot – Controls the XML root. ElementName, namespace..
XmlElementAttribute – Serialize the field/property as an element in the XML document.
XmlAttributeAttribute – Aside from being the victim of strict naming conventions, it tells the XML serializer to serialize field/prop as an attribute in the XML document
XmlIgnoreAttribute – Tells the XML Serializer to omit the field/property.
XmlEnumAttribute – Controls the name of an enumeration member (Not the enum name, a member of the enum)
XmlTextAttribute - Tells the XML Serializer that the member contains raw XML text.
XmlTypeAttribute - Controls the XML Schema (XSD) that is generated by the XmlSerializer. Used to specify other namespaces and types when serializing.
XmlIncludeAttribute - Allows the XmlSerializer to recognize a type when it serializes or deserializes an object. Used when deserializing custom types.
XmlChoiceIdentifierAttribute - Tells the XML Serializer that the type should be XSI:Choice. Used in conjuction with an enum field/prop in the class to tell the serializer where to get its info from.
XmlArrayAttribute Class - Specifies that the XmlSerializer must serialize a particular class member as an array of XML elements.
XmlArrayItemAttribute – Specifies the types that are contained in an XmlArray. This is used when you are serializing polymorphic classes .
XmlAnyAttributeAttribute – Any attributes that are not matched up during deserialization is placed in the field decorated with this attribute. Field must be an array of XmlAttribute.
XmlAnyElementAttribute – Any elements that are not matched up during deserialization is placed in the field decorated with this attribute. Field must be an array of XmlElement.
XmlNamespaceDeclarationsAttribute – Decorates a field that returns XmlSerializerNamespaces. That field will be use to get namespace prefixes during serialization.
XmlSchemaProviderAttribute – "When applied to a type, stores the name of a static method of the type that returns an XML schema and a XmlQualifiedName that controls the serialization of the type. " Used by WSDL.exe to return the schema for the class. Target class must implement IXmlSerializable. New to 2.0.
XmlSerializerAssemblyAttribute – Specifies the name of an assembly that the Xml Serializer can use. If specified, the Xml Serializer doesn’t need to create a temporary assembly. New to 2.0
XmlSerializerVersionAttribute – Signifies that the code was generated by the serialization infrastructure and can be reused for increased performance, when this attribute is applied to an assembly. I’m not sure I should use this attribute. I think this is used by code produced by sgen.
To completely control the XML Serialization of an object, you need to implement IXmlSerializable. This is not a new interface. In 1.1, the instructions where as follows: "not intended to be used directly from your code. Basically, you implement the ReadXML and WriteXML methods and you're done.
Here are the delegates and events:
UnknownAttribute event - thrown when the serializer encounters an unknown attribute. By default the Xml serializer ignores unknown attributes.
UnknownElement event - thrown when the serializer encounters an unknown element. By default the Xml serializer ignores unknown elements.
UnknownNode event -thrown when the serializer encounters an unknown node. By default the Xml serializer ignores unknown node.
UnreferencedObject event - section 5 of the SOAP document at w3c. Basically you can reference other object within the same Xml document. This event is thrown when it can't find the referenced object.
XmlSerializationCollectionFixupCallback delegate
XmlSerializationFixupCallback delegate
XmlSerializationReadCallback delegate
XmlSerializationWriteCallback delegate - All four of these delegates: "This delegate supports the .NET Framework infrastructure and is not intended to be used directly from your code."
Next post -> System.IO namespace
UPGRADE: MCAD Skills to MCPD Web Developer by Using the Microsoft .NET Framework UPGRADE: MCAD Skills to MCPD Windows Developer by Using the Microsoft .NET Framework UPGRADE: MCSD Microsoft .NET Skills to MCPD Enterprise Application Developer by Using the Microsoft .NET Framework: Part 1
Serialize or deserialize an object or an object graph by using runtime serialization techniques. (Refer System.Runtime.Serialization namespace)
- Serialization interfaces
- Serilization attributes
- SerializationEntry structure and SerializationInfo class
- ObjectManager class
- Formatter class, FormatterConverter class, and FormatterServices class
- StreamingContext structure
Here's an old article by Jeffery Richter that explains most of the stuff about serialization pertaining to this test. It's 1.1, but you'll find that there isn't a lot that has changed.
Serialization Interfaces (System.Runtime.Serialization)
IDeserializationCallback – Provides a method that is called when deserialization is complete – useful for setting internal state after a deserialization.
IFormatter – Exposes methods for serializing/deserializing an object. Used for controlling the format output of the serialization. BinaryFormatter, SoapFormatter are two examples of objects that implement this interface. Note that IFormatter and IFormattable are two different interfaces that do two different things.
IFormatterConverter – Converts objects to different types. Appears functionally identical to IConvertible. Not sure what the difference is aside from IFormatterConverter is called during serialization.
IObjectReference – Used for objects that are “reference” objects – Singletons for example. You wouldn’t want to deserialize a new instance of a singleton. GetRealObject is called in the Fixup stage and should return a reference to the object.
ISerializable – Tells the framework that the developer has provided their own serialization implementation.
ISerializationSurrogate – Allows one object to serialize another.
http://www.codeproject.com/dotnet/Surrogate_Serialization.asp
ISurrogateSelector – Assists the serializer in deciding which Surrogate to use for a particular type. Used in ISerializationSurrogate SetObjectData method. It’s not clear why I would ever need to implement this interface. SurrogateSelector seems to do a pretty good job.
Serialization Attributes
These four are new to 2.0:
OnDeserializingAttribute – decorates a method that is called before object is actually deserialized.
OnDeserializedAttribute – called after class is deserialized. Seems functionally identical to IDeserializationCallback to me.
OnSerializingAttribute – called before an object is serialized.
OnSerializedAttribute – called after an object is serialized.
**Methods decorated with these 4 attributes are expected to have one parameter that is a StreamingContext object.
OptionalFieldAttribute – marks a field as optional, as far as serialization is concerned. This prevents the serializer from freaking if it is not in the stream. New in 2.0
System.Serializable – marks a object as able to be serialized
System.NonSerialized – tells the serializer to ignore the field when serializing
SerializationInfo class
Stores information needed to serialize/deserialize an object. Mostly a collection of serializationEntry structures. Method is AddValue, not Add.
SerializationEntry structure
Contains the Name, Type, and a reference to an object that should be serialized. Used when enumerating through SerializationInfo object.
ObjectManager class
Keeps track of objects as they are deserialized to prevent reserialization (creating the same object twice in memory).
Formatter class
Provides base functions for serialization formatters. Abstract class. BinaryFormatter and SoapFormatter inherit from Formatter.
FormatterConverter class
Base implementation of IFormatterConverter. Not clear where I would use it.
FormatterServices class
Helper object for serialization. GetObjectData, GetSerializableMembers and PopulateObjectMembers are interesting methods that I didn't know existed.
StreamingContext
Describes the source and destination of a given serialized stream, and provides an additional caller-defined context. Can figure out if the object is being serialized CrossProcess, CrossMachine…
Next up - XML Serialization
UPGRADE: MCAD Skills to MCPD Web Developer by Using the Microsoft .NET Framework UPGRADE: MCAD Skills to MCPD Windows Developer by Using the Microsoft .NET Framework UPGRADE: MCSD Microsoft .NET Skills to MCPD Enterprise Application Developer by Using the Microsoft .NET Framework: Part 1
Debug and trace a .NET Framework application by using the System.Diagnostics namespace.
- Debug class and Debugger class
- Trace class, CorrelationManager class, TraceListener class, TraceSource class, TraceSwitch class, XmlWriterTraceListener class, DelimitedListTraceListener class, and EventlogTraceListener class
- Debugger attributes
Krzysztof Cwaline has a good writeup of these features on MSDN.
Debug class - Pretty much the same as it was before. Debug.Assert, Debug.WriteLine.... However they did add a Debug.Print which appears functionally identical to Debug.WriteLine. Maybe it makes VB 6.0 upgrades easier.
Debugger class - Nothing new here, either. Embodies the debugger – is a process attached, break into a debugger, launch a debugger.
Trace class - There are some new methods here. My impression is that they added some of the stuff from the Enterprise Instrumentation Framework. TraceError, TraceWarning, CorrelationManager, UseGlobalLock are some of the new members.
CorrelationManager - Denny Mitch has a excellent writeup on this class (It's written for the beta release, but the information still applies). The idea is to provide some way to differentiate tracing information when more then one request could be executing at the same time or to get some context when you are calling a method recursively.
TraceListener - Abtract class that serves as the base for all TraceListeners. It appears you can now control the "verbosity" of the trace output with the TraceOutputOptions property. You can also filter what gets send to a listener using the filter property. Denny Mitch has another great post about that feature.
TraceSource - Abtract class that serves as the base for all TraceSources. They've added three new TraceSources in 2.0: ConsoleTraceListener, DelimitedListTraceListener and XmlWriterTraceListener. Again, Denny Mitch has some good stuff on them.
TraceSwitch - An object that limits what events get reported to a trace listener. Another method of filtering. This allows you to control what level of messages the TraceSource is interested in. Tradionally specified in your app's config file.
There is a good MSDN mag article by John Robbins that discusses the details of the new tracing features.
Debugger Attributes - This task was vague to me. I took it to mean: understand all the attributes in the System.Diagnostics namespace. There is a good article on MSDN about these attributes.
DebuggerDisplayAttibute tells which field/property should be shown in the watch window for a class.
DebuggerTypeProxyAttribute tells debugger to use a different class when representing it in the debug window. Recommended practice is that the TypeProxy is an internal class of the intended class. TypeProxy must contain a constructor with the intended class as a parameter.
DebuggerBrowseableAttribute specifies if/how a member is displayed in the debug window : Never (Hidden), Collapsed (Displayed when expanded – default), RootHidden – Display members of the collection, not the collection properties if collection class.
Next post - Runtime Serialization
UPGRADE: MCAD Skills to MCPD Web Developer by Using the Microsoft .NET Framework UPGRADE: MCAD Skills to MCPD Windows Developer by Using the Microsoft .NET Framework UPGRADE: MCSD Microsoft .NET Skills to MCPD Enterprise Application Developer by Using the Microsoft .NET Framework: Part 1
Embed configuration management functionality into a .NET Framework application. (Refer System.Configuration namespace)
- Configuration class and ConfigurationManager class
- ConfigurationSettings class, ConfigurationElement class, ConfigurationElementCollection class, and ConfigurationElementProperty class
- Implement IConfigurationSectionHandler interface
- ConfigurationSection class, ConfigurationSectionCollection class, ConfigurationSectionGroup class, and ConfigurationSectionGroupCollection class
- Implement ISettingsProviderService interface
- Implement IApplicationSettingsProvider interface
- ConfigurationValidationBase class
- Implement IConfigurationSystem interface
This is the framework for reading/writing Configuration information. This has been overhauled in the 2.0 framework. Here's an article that gives an overview. Beware that it is referencing beta builds.
Paulo Reichert has a good blog entry on creating your own configuration file. Reading into the way the Microsoft has grouped these tasks together, I think that's what they want you to know.
Configuration class - A merged view of all configuration information. Meaning it merges all information from various web.config, machine.config and other config files to give you a look at all the config information for your current context.
ConfigurationManager - Static class that provides access to specific areas of config files - AppSettings, ConnectionStrings. Allows access to the standard config file, machine.config. Openning a config file returns a Configuration object.
ConfigurationSettings class - Doesn't look like it has changed much since 1.1. Gets a readonly version of the config file.
ConfigurationElement - Represents an XML element in a config file. Abstract class. If you're writting your own config handler, you're probably going to start with a class based on ConfigurationElement. See Paulo's blog entry mentioned above.
ConfigurationElementCollection - Collection of said ConfigurationElements. Inherit from this when your config file has multiple elements of the same type.
ConfigurationElementProperty - Accessed as a property of the ConfigurationElement. Allows you to set the validator. There isn't much info on this object.
IConfigurationSectionHandler - "Handles the access to certain configuration sources". This was the way that you did custom configuration sections in 1.1. I don't think you should use it in 2.0 given the new objects we have to deal with Configuration files. I could be wrong.
ConfigurationSection - Presents a configuration section in an XML file. Abstract class. Again, see Paulo's blog entry.
ConfigurationSectionCollection - "Represents a collection of related sections within a configuration file." Like ConnectionStrings. You could have multiple instances of the ConnectionStrings in your config file.
ConfigurationSectionGroup - Container for groups of ConfigurationSections. Think System.Web section in the web.config. That is a ConfigurationSectionGroup (implemented in SystemWebSectionGroup)
ConfigurationSectionGroupCollection - Allows you to interate through a collection of ConfigurationSectionGroup objects.
ISettingsProvider - Interface that is used to divorce the physical reading/writing of configuration information from the logical need to read/write. If you want to store config info in a place other than an XML file, you'll need to write a class that implements ISettingsProvider. This doesn't appear to have changed from version 1.1
IApplicationSettingsProvider - "Defines extended capabilities for client-based application settings providers. ". This is an another example of the provider architecture that is throughout the 2.0 framework. This provider deals with getting config information for a specific version of the app, upgrading config info... "The .NET Framework enables side-by-side installation and execution of different versions of the same application. The application settings provider stores the application settings for each version of an application separately to ensure isolation. However, you may want to migrate settings from the previous version of an application to the current one. To provide this migration functionality, use the Upgrade method, implemented in a class derived from SettingsProvider."
ConfigurationValidationBase - Base class for configuration file validations. Specific implementations are objects such as StringValidator, IntegerValidator . These can be applied as attributes to properties in your configuration object. Paulo's blog entry has more information on these.
IConfigurationSystem - "This interface supports the .NET Framework and is not intended to be used directly in your code". Which begs the question, why do I have to know about it for an exam? This appears to be used to load up the config system, but I can't find any examples of its usage on the web. It doesn't appear to be explicitly mentioned in any config file on my system (But I guess that would be a classic chicken or egg problem). Reflector isn't pulling anything up that depends on it. So I guess know that it exists?
The configuration section has substantially changed, so it would be to your benefit both for the exam and your own knowledge to take a fresh look at it.
I was going to look at debugging in this post, but I'll address that in the next post
|
Copyright © 2009 Phil Denoncourt III. All rights reserved.
DasBlog 'Portal' theme by Johnny Hughes.
Pick a theme:
|
|
|