Blog Home  Home Feed your aggregator (RSS 2.0)  
What did you learn today? - Tuesday, January 31, 2006
Phil Denoncourt's Technology Rants
 
 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]    | 
     Thursday, October 27, 2005
    Last night I posted a webcontrol that I wrote to my website that makes life more difficult for spammers. It's a substitute for hyperlink control in ASP.NET named the obscure hyperlink control

    One of the ways that spammers get email addresses is that they have programs that spider the web, looking for email addresses embedded in webpages. They target forum based sites because people are more likely to leave their email addresses there. This has caused people to start leaving their email addresses in cryptic formats (for example: me {at} mydomain.com). I find these techniques annoying as an end user trying to contact someone, but I also have to believe that spammers have caught on and look for variants with the word "at" in them. The obscure hyperlink control can be used for any hyperlink, mailto or http. Besides thwarting spammers, another use of the control would be to link to an objectionable site without contributing to its search engine rank.

    What the obscure hyperlink control does is scrambles (note - I'm not saying encrypt) the hyperlink when the page is being created on the webserver using a random technique. An scrambled example of my email address is 'mcstiostucoe@ipolamit:hldnnorascae.o'. You can see a functioning example here. A matching javascript function is added to the webpage that unscrambles the hyperlink when the user clicks on it. When you view the source of the webpage, the link is removed, and an onClick handler is added to the hyperlink. Nowhere will you see the text of the hyperlink. It is present in the onClick handler, but it is not very legible. The Url is not stored in Viewstate, so it can't be taken from there, either.

    Here are pros & cons of this control:
    Pros:
    • Easy to use (works exactly the same as the existing hyperlink control)
    • The hyperlink information is not in the href attribute, but in the onClick (an area that spammers don't always pay atttention to)
    • The diversity of scrambling algorithms makes it difficult for spammers to target a specific implementation
    • Doesn't require a lot of server resources
    Cons:
    • Doesn't completely prevent spammers from getting email addresses. A determined spammer could reverse engineer the control. This is just adds a roadblock for spammers.
    • Requires that the user's browser supports javascript and that it is enabled.
    • Limited number of scrambling algorithms. Right now there are 5. If this fills a need, I intend to add more, but it will still be a finite number.
    Thursday, October 27, 2005 4:02:31 PM (GMT Standard Time, UTC+00:00)  #    Comments [0]   Development | DotNet | ASP.NET  | 

    I've just finished uploading the presentations I did at the New Jersey Code Camp to their site .  The demo files can be downloaded at my website under the file tab.  Sorry for the delay!

    Wednesday, October 26, 2005 11:12:46 PM (GMT Standard Time, UTC+00:00)  #    Comments [0]   Speaking Engagements  | 
     Wednesday, October 26, 2005
    Microsoft has released details for the next generation of .NET Certifications. (Information here). I've been certified by Microsoft for 10 years now (my MCP ID is in the 36000 range) and I currently hold the MCP, MCP+SB, MCSD, MCDBA, MCSA, MCSE, MCAD, and MCSD.NET certifications. I was fortunate enough to work for a Microsoft Partner for a few years who paid the testing fee for as many tests as I wanted to take. These certifications haven't gotten me jobs by themselves or increased my billing rate. But they do help employers/clients overlook that I didn't get a 4 year degree in Computer Science (I just have a two year degree) and have made clients feel more comfortable with my skillset.

    It looks like that I just have to take an upgrade exam to bring my certs current. 4 tests for all the developer stuff. However, I also have the DBA certifications. There is an upgrade exam for the DBA Cert, but if I want to become a
    MCITP: Database Developer, or MCITP: Business Intelligence Developer , I have to start from scratch for a total of 5 exams.

    One of my pet peeves is developers who think certifications are worthless. For the most part, the rant sounds something like this: "I know everything I need to know to do my job, I'm a .NET god, why do I need to prove it to other people?". Well, you don't know what you don't know. Take one of the practice tests. Every developer I know who has taken one is humbled by the results. For the most part, developers use only a fraction of the .NET framework. Until I started preparing for the exams, I had never used EnterpriseServices, Reflection, or Code Access Security. You can write a lot of good applications without ever touching any of these areas. But, by knowing these areas, you can write more complete applications, and troubleshoot all those weird problems that crop up every now and then.

    It's been known for some time that Microsoft is going to offer a
    Microsoft Certified Architect program. I'm on the fence with this one. It strikes me as Country Clubish. You begin the program by having someone who is an architect recommend you. To gain acceptance, you are grilled by a "board" of other Architects about your solutions and experience. I would like to see it be a little more capability based. The costs are unclear, but I can't see that it would be cheap, and I'm not sure what advantage this credential gives me compared to some other guy who doesn't have it.
    Wednesday, October 26, 2005 4:54:05 PM (GMT Standard Time, UTC+00:00)  #    Comments [0]    | 
    Downtime by phildenoncourt
    Apparently, the servers that host my site are based in Boca Raton, Florida and have been without power for the past two days. They're working off of generators right now. This is a tremendously minor inconvenience compared to what the people who live there must be going through. My prayers go out to all the people affected. Donate as you can.
    Wednesday, October 26, 2005 2:27:21 PM (GMT Standard Time, UTC+00:00)  #    Comments [0]    | 
    Copyright © 2008 Phil Denoncourt III. All rights reserved.
    DasBlog 'Portal' theme by Johnny Hughes.
    Pick a theme: