Blog Home  Home Feed your aggregator (RSS 2.0)  
What did you learn today? - Thursday, February 02, 2006
Phil Denoncourt's Technology Rants
 
 Thursday, February 02, 2006
Finalization by phildenoncourt

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.

Thursday, February 02, 2006 7:44:11 PM (GMT Standard Time, UTC+00:00)  #    Comments [0]    | 
 Wednesday, February 01, 2006

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

 

Wednesday, February 01, 2006 3:42:23 PM (GMT Standard Time, UTC+00:00)  #    Comments [0]   Certifications  | 
 Tuesday, January 31, 2006

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

Tuesday, January 31, 2006 8:41:36 PM (GMT Standard Time, UTC+00:00)  #    Comments [0]   Certifications  | 

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

Tuesday, January 31, 2006 2:53:11 PM (GMT Standard Time, UTC+00:00)  #    Comments [0]   Certifications  | 
 Monday, January 30, 2006

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

Monday, January 30, 2006 3:43:44 PM (GMT Standard Time, UTC+00:00)  #    Comments [0]   Certifications  | 
 Friday, January 27, 2006

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

In all of the prep guides to these exams, Section I is identical.

Here are the goals I looked at:

Manage data in a .NET Framework application by using .NET Framework 2.0 system types. (Refer System namespace)

  • Value types
  • Reference types
  • Attributes
  • Generic types
  • Exception classes
  • Boxing and UnBoxing
  • TypeForwardedToAttributes class

Nothing too special here.  Everybody should know about generics by now.  The TypeForwardedToAttribute is new.  Here some info I found on that:
   http://www.heege.net/blog/PermaLink,guid,8d076332-4fb0-44b5-a829-4c4d653de2d6.aspx
   http://notgartner.com/posts/2955.aspx

Manage a group of associated data in a .NET Framework application by using collections. (Refer System.Collections namespace)

  • ArrayList class
  • Collection interfaces
  • Iterators
  • Hashtable class
  • CollectionBase class and ReadOnlyCollectionBase class
  • DictionaryBase class and DictionaryEntry class
  • Comparer class
  • Queue class
  • SortedList class
  • BitArray class
  • Stack class

Again, nothing too new here.  The only thing to be aware of is the yield return statement in C#.  It seems that a similiar construct is not available in VB.  Some good discussion can be see here:
http://robgarrett.com/Blogs/software/archive/2005/09/13/1588.aspx

Improve type safety and application performance in a .NET Framework application by using generic collections. (Refer System.Collections.Generic namespace)

  • Collection.Generic interfaces
  • Generic Dictionary
  • Generic Comparer class and Generic EqualityComparer class
  • Generic KeyValuePair structure
  • Generic List class, Generic List.Enumerator structure, and Generic SortedList class
  • Generic Queue class and Generic Queue.Enumerator structure
  • Generic SortedDictionary class
  • Generic LinkedList
  • Generic Stack class and Generic Stack.Enumerator structure

Just the generic implementations of the collection classes.  Know that generics are faster because they prevent a lot of boxing/unboxing operations.

Implement .NET Framework interfaces to cause components to comply with standard contracts. (Refer System namespace)

  • IComparable interface
  • IDisposable interface
  • IConvertible interface
  • ICloneable interface
  • INullableValue interface
  • IEquatable interface
  • IFormattable interface

Some neat stuff here.  A lot of it existed in 1.1, I just never had a chance to use it.
IConvertible
            Specifies means to convert an object to a native value type.  Convert.ToInt32… Throw InvalidCastException if no meaningful conversion.

INullableValue

            Removed in RTM

            http://blogs.msdn.com/somasegar/archive/2005/08/11/450640.aspx

IEquatable<T>

            Implements the CompareTo<T> method so that different object types can be compared.

IFormattable

            ToString implementation.  Difference between overriding ToString and implementing IFormattable is that the currentCulture is provided when implementing IFormattable.

 

That's it for now.  Next post-> Configuration Manager and Debugging.

 

Friday, January 27, 2006 3:05:03 PM (GMT Standard Time, UTC+00:00)  #    Comments [0]   Certifications  | 
 Thursday, January 26, 2006

I haven't been blogging lately, because life has been pretty busy with the holidays, new baby and trying a few spare-time projects in VS2005. 

If you are a MCAD or MCSD in .NET, you can take the upgrade exams to upgrade your certifications to the new MCPD.  They are currently in beta, and it looks like they've opened the beta to anyone.  See the training section at http://msdn.microsoft.com/flash/currentissue.htm

I'm scheduled to take all the upgrade exams between mid-Feb and mid March.  I've found that studying for exams forces me to examine areas that I otherwise don't take a serious look at.  Like tracing, code access security, reflection and some of the more arcane areas of web services.  And, if I schedule exams ambitiously (really close together), I'm more likely to spend the time that I should preparing. 

My practice has been to go through the preparation exam guide with a fine tooth comb, play with the areas that you haven't touched and prepare "cheat sheets" (Study guide).  As I finish a study guide, I'll publish them here.  Hopefully you will find them useful.

Thursday, January 26, 2006 8:06:05 PM (GMT Standard Time, UTC+00:00)  #    Comments [0]   Certifications  | 
 Thursday, November 17, 2005
Virtual PC Performance by phildenoncourt
I've been using Virtual PC for over a year now for a variety of different purposes: running beta software, running Linux, testing installs and creating a machine to use for telecommuting. Just last night I helped a coworker on a problem with Windows Server 2003. Instead of having to keep a dual boot machine, I was able to walk through and test various scenarios using my virtual PC image.

Over the past three months or so, the performance has just sucked. To the point where it took two hours to download updates from WindowsUpdate. It didn't used to be that slow, in fact it was almost as fast as my host PC, so I starting checking things out, trying to find the problem.

Turns out the problem was Windows XP Service Pack 2. With Service Pack 2, there was a change that caused virtual machines to run very very very slowly. The recommended solution was to install service pack 1 for Virtual PC. That helped, but things were still pretty slow. The other part of the solution is to uninstall the virtual machine additions and then reinstall them on all your client images. This reduces the amount of thrashing for virtual XP Sp2 machines. This was all information that was contained in the readme file for Service Pack 1. Sometimes it pays to read the Readme files.


SP1 includes the following additional software updates.
  • Updated version of Virtual Machine Additions. You should update the version of Virtual Machine Additions on all virtual machines where Virtual Machine Additions is installed. For more information, see "Installing Virtual Machine Additions" in Virtual PC Help.
  • Thursday, November 17, 2005 9:08:47 PM (GMT Standard Time, UTC+00:00)  #    Comments [0]   Virtual PC  | 
     Tuesday, November 01, 2005
    This is crazy. The Digital Rights technology used by various media companies is going too far by stealthly putting software on people's machines. This post is a great read, detailing some interesting techniques for discovering the presence of rootkits on your system.
    Tuesday, November 01, 2005 4:55:44 PM (GMT Standard Time, UTC+00:00)  #    Comments [0]    | 
    Copyright © 2009 Phil Denoncourt III. All rights reserved.
    DasBlog 'Portal' theme by Johnny Hughes.
    Pick a theme: