Archives

Archives / 2005 / May
  • [tip] Using IE when it's not your default browser

    Firefox has been my default browser for nearly a year, but there are a few sites that I have to use that use IE specific HTML. A usual offender is corporate intranets, since they've got a captive audiance.

    One solution is the Firefox IE View plugin, which added an "Always view in IE" feature in v0.87 (April 05). It pretty much works (be sure to use this release or later), but it's a little bit clunky. It starts to browse to the page, detects the domain is in the IE list, and pops up the page in IE.

    A slightly quicker solution for commonly used pages is cheesy, but it works. I create a shortcut to iexplore.exe with the url as a command line argument, like so:

    "C:\Program Files\Internet Explorer\iexplore.exe" "http://intranet.megacorp.com/timetracking/index.htm"

    Make sure to include the quotation marks and the full path, like the example above.

    I name the shortcut something short and descriptive - say "TT" for a time tracking system - and drop a copy of it into a folder that's in the environment path, like c:\windows\

    Then I can bring up the page in IE with a few keystrokes: Windows-R, TT, Enter

    powered by IMHO 1.2

    Read more...

  • Monoppix 1.0.6 Release

    Monoppix is a bootable Linux CD that runs .NET applications on the Mono framework. It makes it easy to see your .NET code running on Linux without installing a thing.

    Read more...

  • Avalon and Indigo Beta SDK Now Available

    From the main download page for the Betas, you will find a link to the updated SDK (iso format). Looks like Friday's announcement kinda jumped the gun, but it's all available now.

    Oh and for those who were asking, yes, this build is 100% compatible with Whidbey Beta 2.

    [via HACKED.BRAIN-BLOG]

    This is the official release of WinFX SDK Beta 1 RC - it runs on .NET Framework 2.0 beta 2 on Windows XP and Windows Server 2003. It's not clear if this is a different binary from the version that snuck out on Friday - people have reported some problems with that one.

    Read more...

  • .Math Expression Compiler

    Welcome to .Math, the OpenSource expression compiler for the .NET platform written entirely in C#. Offering speed through compilation of expressions, the library allows for variable handling, an entire function library and the ability to add your own functions.

    Read more...

  • Issue with Firefox v1.0.3 upgrade - blank screens

    The Firefox extension model is one of my favorite features, but extensions seem to be the most frequent cause of upgrade problems. I went a step further than Don - I renamed the profile folder, then browsed through the user.js file in my old profile after a successful install and copied some of the settings (like the Session Saver history) into the new profile.

    Read more...

  • [link] Rewriting the URL using IHttpHandlerFactory

    Don Good told me about Jeff Putz's cool article on Rewriting the URL using IHttpHandlerFactory. I don't know how I missed that one. It's a great technique that gets around all the grimy hacks you need if you're doing this the standard way, using HttpContext.Current.RewritePath(someFile). This one instead maps a custom handler for ASPX files to your class which implements IHttpHandlerFactory. Then in the code logic, you just load the code from the physical ASPX file instead of redirecting to it and screwing with your context:

    using System;
    using System.IO;
    using System.Web;
    using System.Web.UI;

    public class MyPageFactory : IHttpHandlerFactory
    {
       
    public IHttpHandler GetHandler(HttpContext context, string requestType, 
          
    string url, string pathTranslated)
       {
          context.Items["fileName"] = Path.GetFileNameWithoutExtension(url).ToLower();
          
    return PageParser.GetCompiledPageInstance(url, 
             context.Server.MapPath("~/Content.aspx"), context);
       }

       
    public void ReleaseHandler(IHttpHandler handler)
       {
       }
    }

    Read the article - it's short and well written. Don showed me a prototype that was using this, and it worked perfectly. Great idea!

    Read more...

  • An overview of the Enterprise Library

    Background

    We've been looking for some standard components in my group at work. The main issues were logging, data access, and centralized configuration. We'd kicked the tires on the Enterprise Library a bit, but our reaction was the standard "Gee, it looks complicated. Probably more trouble than it's worth." Then within one week, we got a barrage of EntLib information: a presentation by Scott Mitchell at the local San Diego .NET user group, presentations by Tom Hollander and Blake Dong (Avenade) at the Microsoft San Diego Architect Council, and an onsite Q & A with Tom Hollander. It all made sense: this is exactly what we were looking for, and it might be worth a second look if you'd decided to pass on it, too.

    Enterprise Library is for enterprise development

    Steve Smith summed that up pretty well here. A lot of people have complained that it's too complex, and it probably is overkill for smaller or standalone applications. The source code (included) has over 1300 files. The previous application blocks were geared towards simplifying and standardizing small discrete application aspects (e.g. data access block was basically a helper class, hence the name SqlHelper), and were pretty simple to use. The Enterprise Library has traded some of that simplicity for the benefits of a configuration driven plugin system that makes the .NET Framework feel like a business development framework.

    It's a tradeoff: You put up with a few things:

    • A nominal learning curve (assisted by the quickstart code samples) 
    • A minor performance penalty (designed to be under 5% in most cases, and your application may actually run faster if you take advantage of things like caching and async logging).

    In exchange you get a few things that matter to bigger development shops:

    • Simplified configuration
    • Application consistency
    • Futureproofing through plugin architecture
    • A head start on many of the components of robust applications ("streamlining of common use cases" is the official term)

    The Enterprise Library is a collection of seven blocks, six of which are optional. All of them require the Configuration block, which controls how they all work and work together. You can replace any of them with a plugin that implements the correct interfaces and is associated in the config file. Here's a quick runthrough on the highlights of each of the blocks. The config tool is big enough that I gave it its own list.

    The Seven Blocks and the Config Tool

    Configuration

    • XML driven application configuration, similar to .NET configuration, but adds a lot of features targeted at enterprise development
    • Read / Write - Can update config file settings from code
    • Security built in - supports encryption. Supporting encryption at this level helps with the chicken and egg issues of wanting to secure your configuration information, but needing to configure the security somewhere.
    • Extensibility / flexibility - Provider model controlled in configuration allows you to customize EntLib with plugins, simplifying and reducing the risk of customizing EntLib to work the way your company works.
    • Configuration Tool is included to simplify setup and maintenance. Config is XML and can be manually edited, but Config Tool makes this a lot easier.
    • Updates trigger events in client applications. Configuration updates are different form web.config, which just kills the app domain. Entlib Config changes notify the application via an event. Application decides if it wants to reload configuration.
    • Due to caching of configuration, you should always retrieve config values from block rather than holding onto them separately - can get out of sync.
    • Can set in code or in machine.config if file based config doesn't fit your requirements

    Configuration Tool

    • Don't have to use Config Tool if you prefer hacking the XML
    • Design classes map EntLib runtime classes to display, add wizards, etc.
    • Design time classes depend on runtime classes, but never the reverse (don't need to deploy the design classes or Config Tool).
    • Provider Model - Uses intermediate DLL's so there is no binary dependency between a class and the providers that feed it. Mapping of plugins is done in metaconfiguration.
    • Design class pattern allows you to add support your own custom blocks or extensions to existing blocks to the Config Tool

    Crypto

    • Symmetric encryption only (asymmetric key management is more difficult, processing is generally slower)
    • Hashing and salting supported
    • Very simple to use - only 4 methods (CreateHash, CompareHash, EncryptSymmetric, DecryptSymmetric).
    • DPAPI support. DPAPI, the Data Protection API, provides operating system level support for symmetric encryption of secure information. DPAPI key can be associated with machine or user.
    • Abstracts encryption specifics from usage - developer doesn't specify key or algorithm. One reason this is good - crypto is hard, and it's good to let a developer use it without guessing on crypto algorithm usage.

    Database Access

    • Abstracts database technology (SQL Server, Oracle, etc. - can use providers to support other data sources)
      • May simplify database portability, but since databases support different technologies, this is not simple and isn't really the goal here.
      • Real goal is to simplify developer portability - makes it easier for developers to move between applications and teams using different databases. Since I work at a company that runs just about all of the major database technologies (SQL Server, Oracle, DB2, Sybase, Informix, probably several I'm forgetting), this sounds nice.
    • Helps ensure effective connection management
    • Uses factory pattern. This is a change from the previous Data Access Application Block, and it trades simplicity for flexibility. One major benefit of this type of pattern is that it integrates smoothly with the Config block, so the connection string and other specifics of data access configuration are transparent to each specific usage
    • This is a Data Access Layer, not a Business Logic / Object Relational Mapper kind of thing. It doesn't generate any classes and doesn't know anything about the tables it's talking to. This is a conceptual issue I've had to explain several times, so I figured it's worth spelling out. You build your Business Logic Layer (BLL) on top of this layer, and it handles communications with your data sources.

    Security

    • Handles Authentication, Authorization, Roles, and Profiles
    • Can use Facades to call into legacy security systems

    Logging

    • Configuration driven, so logging is routed at runtime
    • Distribution strategy
    • MSMQ supported as a sink and / or a distribution strategy
    • MSMQ distributor processor - separate Windows service which processes logging messages in MSMQ, can run on another computer
    • Logging by default requires WMI and Event Log permissions. Can recompile with a compiler define that removes instrumentation; next version will alow disabling the EIF in configuration
    • Contextual trace - see Mitch's great explanation of contextual logging in the EIF. Context flows through the call stack, making the information much more valuable.
    • V2 may allow one log entry to have a collection of categories which adds a lot more flexibility

    Exception Handling

    • Facilitates consistent exception handling through an application or enterprise
    • Prevents exposing sensitive data (such as database connection specifics returned in an exception message)
    • Configuration driven exception policies allow changing exception handling policy for different user defined exception categories at runtime via configuration changes
    • Available actions: Swallow, Bubble, Rethrow

    Cache

    • Support for "Backing Store" in either database or isolated storage (file) - allows for occasionally connected use
    • Differs from ASP.NET cache in that it doesn't require web DLL's, is designed for thread safety in all application types, and supports backing store
    • Doesn't support distributed Read / Write (webfarm, for instance)

    Some other random tidbits

    • There have been 100,000 downloads of the EntLib since January.
    • Some overlap with ASP.NET (profile, cache), but simplifies library code. Can use Facade providers in ASP.NET to leverage base functionality if desired.
    • Main patterns - Factory, Provider, Strategy
    • History - Avenade Connected Architecture (ACA.NET) - Avenade was formed by Microsoft and Accenture. They were developing their own system for use in their projects which paralleled work in progress by the Microsoft Patterns and Practices Group, so they merged these together. Enterprise Library is pretty much a version 3.0 product due to its roots as the ACA.NET. Avenade continues to extend the ACA.
    • Can copy Updater Block design DLL's to EntLib bin, and Updater Block will show up in Config Tool
    • Heavily cached, so slow start but <5% performance penalty

    Extending EntLib (see Blake Dong's PPT)

    • Gray box - write custom providers
    • Don't inherit from internal abstract classes if possible, stick with interfaces so upgrades don't cause you trouble
    • Minimize coupling between brovider and blocks
    • Use Enum to wrap categories (log categories, for instance) - allows strong typing, compile time typo check
    • Since some of the logic has been moved into configuration file, can be a little tougher to debug. For instance, a log category of "DEGUB" wouldn't cause a config or compile time error, but log entry would never be written since no "DEGUB" category exists.
    • Can use Facade Pattern (wrapper) to future proof
      • Company.Name.Caching wrapps Caching block, for instance
      • Can add Logging, AOP type stuff to wrappers
      • Upgrade t new version of EntLib by updating the version number reference to the wrapper instead of EntLib config files everywhere
    • ACA includes a pretty cool Attribute based Aspece Oriented Programming (AOP) system. Post-build step drives codegen which configures EntLib services.

    References

    Microsoft San Diego Architect Council
    EntLib Overview- Tom Hollander, Microsoft - PPT - http://www.socalmsft.com/Council200505/EntLib%20Overview%20-%20Socal.ppt
    Adopting Entlib - Blake Dong, Avenade - PPT - http://www.socalmsft.com/Council200505/SoCal%20Architect%20Forum%20-%20EntLib%20v3.ppt 
    Extending EntLib- Tom Hollander, Microsoft - PPT - http://www.socalmsft.com/Council200505/Extending%20EntLib%20-%20Socal.ppt

    San Diego .NET User Group
    Examining the Microsoft Enterprise Library - Scott Mitchell - Zip - http://datawebcontrols.com/classes/EntLib.zip

    Resources

    http://workspaces.gotdotnet.com/entlib
    Webcasts - www.pnplive.com
    Tom Hollander's blog
    Hirshambaz's blog
    Scott Densmore's blog
    Some other Tom Hollander

    Installation tips / tricks

    Install build 1473 and Memory Leak patch from the GotDotNet site.

    Post-Installation step
    Immediately after installing Enterprise Library, you MUST install the instrumentation and performance counters.

    start\All Programs\Microsoft p&p\Enterprise Library\Install Services

    This will execute installutil on each of the assemblies and register the performance counters.  I would hope that in the next version of the installer, this option will be automatically executed after the solution is compiled. (via http://blog.hishambaz.com/archive/2005/02/02/240.aspx)

    Read more...

  • [VPC] Using Virtual PC for developer portability

    I've been using VPC quite a bit lately. At work, we've got a few applications which can take days to get set up for development - one app is ASP.NET mixed with VB DCOM on DB2, another is even more confusing. Both take a few days to configure, and that's if you follow the directions and ask the guys who built it. That kills developer portability - a 30 minute bug fix becomes a 30 hour bug fix if the developer hasn't gone through the installation initiatiation on that system yet.

    So when our groups officially merged recently and cross-training was looking unavoidable, I worked with the leads on each of these systems to configure a VPC development image. The nice thing with this is that the system is correctly configured by someone that knows what they're doing. The image is fully patched and includes Visual Studio, configured websites, appropriate database client tools, virus scanning software, and source control client software.

    Now, moving a new developer onto a project is as simple as installing VPC (about 5 minutes), copying the image (DVD / network share / USB2 external hard drive), and starting it up. Of course, the developer needs to check out the latest code from source control, but they just need to pull down the deltas since the image was built.

    I know this is old news and elementary VPC usage for some developers. At Microsoft, for instance, QA tests on VPC's so they can give an image in the error state to the developer to debug. However, it's saved our group so much time lately that I wanted to share our success story. More VPC goodies and links to follow.

    Read more...

  • Free Opera Browser v7.54 License

    It's nice to test drive the top alternative browsers, especially if you're involved in web development and want to see how your sites are displayed. I've never used Opera before because I'm terminally cheap and very happy with Firefox.

    Well, here's a free offer from a German magazine for a license of Opera 7.54:

    Enter code OJD000MN to get Opera Browser v7.54 for free. An email with the license key will be sent. Final v8.0 is out but the license only works on v7.54 or v8.0 beta. Thanks inevitableDUDE.

    Download links:

    [via Slickdeals.net]

    Read more...

  • [OT] Teaching a child to read

    I'm teaching my 4 year old, Rosemary how to read. I thought I'd share a few of my experiences in case it's helpful to others.

    On a friend's recommendation, I'm using Teach Your Child to Read in 100 Easy Lessons. It's phonics based, and it's pretty foolproof. It uses a special orthography to simplify the complexities of pronouncing english words - each symbol makes one sound:

    It looks weird, but it abstracts the illogical nature of the english language a bit at the beginning, then removes the crutches once they're used to the idea of reading. It's working really well for Rosemary - I tried teaching her with refrigerator magnet letters before, but it just didn't make enough sense for her. The systematic lessons are geared for young children and have been working very well.

    I've read some people's strong opinions that this method will ensure my child's illiteracy, and potentially induce a magnetic pole flip. All I can say is it's working well for us, so I'm not to interested in the Ph.D. educator bickering.

    I've been surprised that the concepts aren't the hard part - the hardest part of reading is paying attention. We actually repeat that before and during every lesson: "the hardest part of reading is paying attention." Children are wired for rapid learning, but it's hard to sit still for 20 minutes.

    Bribery helps. I've used a mixture of bribery (a little bit of candy or sugarless gum), goals (trip to Chuckie Cheese every 10 lessons), and artificial scarcity ala GMail. The artificial scarcity has been probably the most effective, which cracks me up - the bribery and goals weren't doing the trick, and Rosemary was losing interest. So I started hiding a few of my dry cleaning tickets around the house, and I told her the reading lesson people had a new rule that she could only have a reading lesson if we sent in three tickets. All of a sudden, she was scouring the house for tickets every day, searching for tickets. It's turned into a bit of a game - I hide them in her dollhouse or next to her cereal bowl when I leave for work in the morning.

    This has been challenging, educational, and fun for both of us. Rosemary is very proud and excited to read the little stories at the end of each lesson, and watching her sound out her first sentence felt like watching her take her first steps.

    And I've become conscious that the hardest part of learning - for me as well as my four year old - is paying attention.

    Read more...

  • [OT] Let's crank this blog back up

    Hmmm... no posts for more than a month. A reorg at work got me a small promotion and a ton more work. Bunch of other non-computer related stuff.

    Enough of the bloguilt - let's crank this sucker back up. Got 275 notes on blog post topics and several code samples that are just about complete, so here goes...

    Read more...