Deserialized The Ramblings of a Web Architect

22Jul/112

Use PostSharp to easily allow MiniProfiler to profile your ASP.NET application

Posted by Bryan Migliorisi

Scott Hanselman has written a great post detailing how to include the MiniProfiler in your ASP.NET application.  I tried the profiler out and it works great.  Its lightweight and easy to configure but by default it does not give you very much information about your requests and method calls.

Admittedly, it is a ”mini” profiler so you cannot expect great things from it, such as memory usage like you would get from a full featured out-of-process profiler – but this thing can go pretty far.

Unfortunately, I did not want to add using() statements all over my code in every method I want to profile.  Being able to mark methods with attributes would be great, and ASP.NET MVC lets you do just that which makes it easy to mark your base controller with an attribute that allows you to profile actions.  This does not, however, give you any information about the methods being called from within the action.

C# has no built in way to intercept method invocation so the only way to accomplish this is to use some sort of Aspect Oriented Programming (AOP) library\utility.  There are a few out there, including:

I’ve decided to use PostSharp Community Edition.  It is a free, commercially backed product, and it works pretty well.  With PostSharp, you can define attributes (or aspects) that allow you to run code before or after a method is invoked and catch & handle exceptions.  IT does this by post-processing the IL that is generated by the C# compiler and modifies the areas of the code necessary to make your code work as you intended.

It does add an additional process to the compilation but if you need this sort of power, its worth it.

Here is the code for using PostSharp and MiniProfiler together

And wherever you want to profile, you can mark either the entire class or a specific methods with [ProfilingAspect] and now you will see those method calls showing up in your MiniProfiler logs.

Pretty easy, isnt it?

16Jul/111

Call mulitple services or methods asynchronously in ASP.NET MVC controller

Posted by Bryan Migliorisi

I recently had to write some code that reached out to both Google and Bing, performed searches on both, combined and manipulated the results and return the result to the client via JSON.

My problem was that sometimes either of those two services could be slow and there is a possibility that I may need to add additional data sources at a later time.  The code originally looked like this:

 

old-code

 

As you can see, this code would accomplish the goal without a hitch, however if Google took longer than usual, Bing would have to wait for Google to finish.  This just creates a bad experience for my users.   I needed a way to be able to fire off both of those searches at the same time without blocking one another, however to be of any use to my users, the action would have to wait for both of them to complete before combining the results and return them to the client.  This problem would be amplified by adding additional data services (like Yahoo, for example).

Even though I had done this several times in PHP, I had no idea how to accomplish it in C#.  I know that AsyncControllers exist and it sounds like they rock, but what if I wanted to keep this all in the same controller as other related code?

I did some digging and found nothing, so I turned to a developers best friend – StackOverflow.  I posted a question asking how to accomplish this and got back a few great answers.

This is what I decided on, and it works great:

new-code

You can create as many Task’s as you need, and then start each of them with the Start() method.  Then using the Task.WaitAll() method, you instruct your program to wait until all of those Task’s have completed before continuing to the next line of code.

You can also specify a timeout as the second parameter of Task.WaitAll that will prevent your Task’s from running indefinitely, which is definitely helpful for Ajax requests when the client is waiting on some response.

10May/111

Why I don’t want to talk to recruiters without knowing what they are selling first

Posted by Bryan Migliorisi

As I’m sure many people have experienced, I receive a handful of recruiter emails every week.  I categorize these messages into two groups.  The first group is very untargetted – promoting positions for things which I am not qualified for.  Take a look at my resume, my blog, my twitter stream, and\or my LinkedIn profile for a minute and you’ll see what I am proficient in and capable of.  Did I say that I was a ColdFusion developer? No, I didn’t.  So don’t waste my time (or yours) offering me a Senior ColdFusion Engineer position.

Then there is the second group of messages I get.  Many of these unsolicited messages say nothing more than "Hey I have a great position to tell you about. Lets get on the phone and talk about it".”

Again, No.  I don’t want to get on the phone with you.  I don’t want to hear what you have to say.  I don’t know you and I don’t trust you.  Why? Because its most likely that you don’t know what you are talking about.  You are a recruiter, not an engineer so please don’t try to pretend that you know anything about writing code or solving difficult problems.  I don’t want to waste my time hearing you pitch some startup to me – or pitch what you consider to be a “startup” either. 

Instead, tell me who you are recruiting for.  I know startups and all I need from you is to tell me who the company is.  I’ll decide if they are really a “startup” with the startup culture, mentality and environment.  I don’t need you to try to convince me of it over the phone.  I can do my own research. 

Don’t worry! I’m not going to go around you.  You’ll get your commission but if you want to work with me, it wont be all on your terms.

1May/110

How do you define scalability?

Posted by Bryan Migliorisi

“Scalable” is an interesting word that gest thrown around all too much in the development\information technology world.  I recently had an argument a discussion with a co-worker about the possibility of building  a brand new set of services on top of our old, rotting code base.  My opinion is that we should take a step back and take a serious look at the current code base.  I don’t believe that it is a good idea to build an important new service (or set of services) on top of the current code because it was “architected” by several out-sourced junior developers 5 years ago. 

The code is… garbage.  Some of the recent stuff is good and usable because it was developed by seasoned engineers. The older stuff is so poorly written that every time we are required by our product team to add a new feature or enhance an existing one, the time it takes to get the product out the door is months when it should be weeks and weeks when it should be days. 

The co-worker in question continually argued that the current application has scaled quite a bit over the past 5 or 6 years and is fully equipped to scale further.  He argued that over the lifetime of the codebase, we have added so many new features.  The thing that kept jumping out at me was his use of the word “scalable” to describe our applications ability to handle more traffic, and nothing more.

This made me think – is the application the only thing that needs to be scalable?  I think the answer is unequivocally “No.”

In our case, we can scale the application to handle more requests but we cannot scale the development team.  That is our problem – scaling the development of our software is impossible.  Like hardware scaling, development scaling has two options and for the sake of simplicity we’ll call them by the same names.

Vertical scaling:  Hire more developers.  Its easy to find low quality people to work on low quality code, but they still cost a decent amount of money.  Single point of failure because since the code is so complicated, its more difficult (if not impossible) to find people who can quickly learn the old code to a point that they can build something on top of it.  In my experience, few developers were willing to work in such a disaster of code.  We hired a number of developers who quit after just a couple of months.  Its not fun or interesting to be in “bug fix” mode forever.

Horizontal scaling:  Use the engineers\architects\developers you already employ and take the time to fix the code (or write new code).  This is harder and cant always be done (in our case, it’s a viable option). Its harder also because you would most likely need to consider all the things your software does now and recreate that experience.  You eliminate the points of failure noted above because, if done right (and hopefully it is, since that’s why you're doing it in the first place), you’ll be able to hire any eligible developer and they should be able to pick up the new, modern, well architected code much quicker than above.

The ability to re-build from scratch is rarely an option in the software development world but when it is, you should seriously consider it.  When you hit that point where you can no longer scale your development to a level at which you can easily and quickly iterate on your application or build new features, you should think about your options and find out if re building makes sense.  It might not and you might be stuck working with unscalable software, even if it does handle the load and generate cash flow.

Tagged as: No Comments
20Apr/117

Why I choose the Microsoft stack for my new startup

Posted by Bryan Migliorisi

Microsoft webOne thing is for sure - Microsoft gets a bad rep these days.  Maybe its because of Windows Vista.  Maybe its because of classic ASP, or even ASP.NET’s WebForms.  Maybe it is because they are a large company who’s focus has too long been on the enterprise, and not enough on the consumer.  Most likely, though, it is because its simply cool to make fun of Microsoft.

I had plenty of options when I decided to start building a new web application.  My favorite language is C#.  I’m not talking about web app frameworks, or frameworks in general – no, just the language.  I love that C# does not do very much magic, like Ruby does.  I love that C# has a cleaner and more expressive syntax than Java does.  I won’t even compare the language syntax and API to that of PHP. Of course, there were other options too, such as Python and Scala.

Java

I’ve been working for the past 3 years with Java and Spring 2.x.  Older versions of Spring are god-awful, what with their dependence on a metric ton of XML configuration files.  Spring 2.5 began to add support for annotations (attributes in C#) and Spring 3 continued to improve even further in this area.  Java has a fairly good amount of cool technologies, frameworks, and specifications too.  For me, though, the ecosystem feels very broken.  Having many options is good.  Having too many options is bad.

Ruby and RoR

I began toying around with Ruby and, consequently, Ruby on Rails too.  It is a nice and powerful language and framework but at the end of the day it didn’t feel right.  I like type safety and compile-time checks.  I like knowing what my code does – in fact, I like telling my code what to do!  Ruby loves to do magic for you.  Rails builds on top of this magic to provide even more magic.  Honestly, it is pretty impressive but for me, it just didn’t feel right.  I’ve spoken to fellow developers who feel the same way: It is very cool, but doesn’t feel natural.

With that said, I have already written a couple of supporting services in Ruby for my new app.. because Ruby was the better choice for those services.  They are exposed as web services running on Sinatra.

PHP

I’ve used several PHP frameworks, including CakePHP, CodeIgniter, Kohana, Lithium and Yii.  My favorites are the last two, Lithium and Yii.  They both do a great job of making it easy to build web applications and both are extensible.  However, I despise PHP as a language.  It is arguably one of the ugliest languages ever “designed.”  (It really never was designed, it just grew organically which is why function names, parameter order, etc is so different from function to function)  If I choose PHP, I know I would not be able to sleep at night.

As for the others, I just didn’t have enough experience with them to make a fair (to me) comparison.  Nor did I have several months to learn them to a point that would make a fair comparison.

Home, sweet, home

This all brings me back to my personal favorite language, C#.  It has a very clean and expressive API (look at LINQ).  The ecosystem is smaller than that of Java, but it is tighter because one company runs the show – Microsoft.  With Microsoft’s latest MVC framework release, ASP.NET MVC3, writing a web application has become so simple its scary.

The ill-named ASP.NET MVC framework learned quite a bit from Rails and the open source community in general. Microsoft studied what people want to do with their frameworks and what they don’t – and it shows.  ASP.NET MVC is a fantastic framework and they’ve built in extensibility at every level.  Don’t like something? Write your own and plug it in.  It really is that easy. Seriously.

With version 3 comes the Razor view engine which I think is absolutely beautiful.  I’ve used several view engines in different languages but Razor stands out to me as a new approach (which is sometimes scary to some people) where you don’t need weird braces, brackets, or custom HTML tags to render content or run code in your views.  I think its just very streamlined and easy to look at and read.

It scales – they all do!

Scalability isn't a feature of any language or framework.  Nowhere is there a bullet that lists scalability as an important feature.  Instead, scalability is something the application designers must think about while they built there app, no matter which language its built in.

ASP.NET scales very well.  So do Java, Ruby, PHP and all the others – when done right.  Scalability is about engineers, not language.

The Community

People often complain that Microsoft is a large corporation who doesn’t care about the community. Those same people often ignore the fact that Microsoft has open sourced much of the .NET framework, including ASP.NET MVC. They ignore that most (though, not all) .NET programs will run happily on any operating system, including Linux, OSX, and iOS. This is made possible through the open source Mono project, sponsored by Microsoft and Novell.

Microsoft and the community also collaborated on a cool new package manager called Nuget.  It is similar in nature to Ruby’s Gems and Java’s Maven, though it is not a copy of either of them.  What is amazing is that immediately upon its release, cool open source (and some commercial) libraries began showing up in the Nuget listing.  So many libraries that I, and presumably many other people, had never heard of were suddenly at our fingertips, ready to be installed as easily as a Ruby  gem.

Since releasing Nuget, the amount of packages has been steadily growing and the amount of package downloads has been growing even faster.

In addition to this,  there is a healthy community of people willing to help you solve any issues you have.  You can head over the the ASP.NET Forums or StackOverflow if you need help with anything and your question will be answered usually in minutes.

The Microsoft stack, minus Microsoft

For my newest web application, I’ve made the decision to go with MongoDB for my database.  It is a super fast, document-oriented database as opposed to standard relational databases such as MySql, Postgres, and Microsoft’s own SQLServer.  I made this decision because it best fits the type of data I will be storing and I’ve been working with MongoDB since its alpha stage so I know what it is capable of.

MongoDB runs on Windows but runs better on Linux, and that is where I plan to run it.

If C# code and ASP.NET MVC applications can also run on Linux, then you have no need to run on Windows.  You have removed Microsoft from the Microsoft stack.  Where is your vendor lock in now?

I will most likely run my application on Windows Server 2008 but the point is that I don’t have to if I don’t want to.  Even with the Microsoft stack, I still have my options.

Bonus: WebSite Spark and BizSpark

WebSite Spark and BizSpark are two initiatives by Microsoft to bring down the initial cost of getting up and running with the Microsoft platform so that you can get all the tools and resources you need to do it right.

Conclusion

With Microsoft's new commitment to building better tools for the web and working with the community, I feel that my decision to go with the Microsoft stack is the right one, for me.  You may not agree – and that is fine – but don’t knock it before you try it.  Version 3 of ASP.NET MVC brings some really great stuff to the table. Nuget makes finding packages just as easy as it has been for Ruby developers for years. Portability of the code means not needing to worry about vendor lock-in.

So far, I am more than happy with my decision.

31Dec/104

ASP.NET MVC 3, Razor, & RenderAction causing server to hang and crash

Posted by Bryan Migliorisi

I am working on a new project and decided to use the awesome new ASP.NET MVC3 (RC2) framework with Razor templating.  Razor is awesome.  Its clean and gets the job done nicely, but when I tried to render an action into my view, all hell broke loose.

This is what my controller looked like:

public class MyController : BaseController
    {
        public ActionResult Index()
        {
            return View();
        }

        public ActionResult ProductDetails(String id)
        {
            return View();
        }
	}
}

And in my view I had this:

@{Html.RenderAction("ProductDetails", "My", new { id = ViewBag.Id});}

But whenever I would navigate to a URL that corresponded to a view containing this RenderAction snippet, the browser would hang and the server would stop responding completely.  I double checked my code, I restarted the server, I restarted the browser, I restarted the IDE.  I tried everything, but no luck.

Problem Solved

It has something to do with Razor’s layouts and what I believe may be an infinite loop.  I think what is happening is that the action being rendered via RenderAction is also trying to load the base template that is found in _ViewStart.cshtml which is rendering the body which is calling RenderAction… and this continues infinitely.

The solution is to either tell your view to NOT use a layout or to change your action from ActionResult to PartialViewResult.  I chose the latter and once I restarted the server again, everything started working correctly.

Tagged as: , , 4 Comments
12Jul/101

ObjectID’s with MongoDB and the mongodb-csharp driver

Posted by Bryan Migliorisi

I mist say, the latest release of mongodb-csharp is rather awesome.  Typed collections and LINQ support mean I can worry more about my application than about the data layer.

Here is an example of using typed collections:

public class Customer
{
	public Oid Id { get; set; }
	public string Name { get; set; }
	public CustomerBillingInfo Billing { get; set; }
	public List Depts { get; set; }
}

public void AddCustomer(Customer customer) {
	...(code removed for simplicity)...
	IMongoCollection collection = database.GetCollection();
	collection.Save(customer);
}

Gotcha: Beware of the ID property!

One thing that threw me off when I began using the typed collections was that I had defined my ID property as “_id” because That is what MongoDB uses internally.  While this made sense to me, the mongod process kept throwing errors whenever I tried the following:

...(code removed for simplicity)...
IMongoCollection<customer> collection = database.GetCollection<customer>();
Customer customer = collection.Linq().First(c => c.Name == "test customer");
customer.Name = "A new name!";
collection.Save(customer);

The error looked something like this:

Fri Jun 25 10:43:14 Exception 11000:E11000 duplicate key error index: test06.Customer.$_id_  dup key: { : ObjId(4c24c07a189cf31bd4000002) }
Fri Jun 25 10:43:14    Caught Assertion in insert , continuing
Fri Jun 25 10:43:14 insert test06.Customer exception userassert:E11000 duplicate key error index: test06.Customer.$_id_  dup key: { : ObjId(4c24c07a189cf31bd4000002) } 21ms

It was driving me crazy for days before I realized that the driver was doing some magic – the POCO object needed its ID to be named “Id” instead of “_id” an as soon as I changed that – it started working properly.

25Feb/106

Convert C# classes to and from MongoDB Documents automatically using .NET reflection

Posted by Bryan Migliorisi

There are a number of C# based MongoDB projects being actively developed right now but one thing that I needed was a way to convert a standard C# class to a MongoDB document for easy insertion.  It isn't hard to manually type out and set each property by hand, but it certainly is not the most efficient way, especially when you know you are going to be doing it a lot.

 

For example:

Lets say I have a class called SomeClass that looks something like this:

class SomeClass {
	public string StringTest;
	public int IntTest;
}

And somewhere in my code, I have an instance of this class named someClassInstance.  If I want to create a MongoDB document from this class, I’d have to do something like this:

Document document = new Document();
document.add('StringTest', someClassInstance.StringTest);
document.add('IntTest', someClassInstance.IntTest);

So that isn't such a big deal, right? But what about when I have a class with many more properties?  Then it starts to get messy and cumbersome.  I thought that there should be an straightforward way to easily convert any class to a mongo-csharp compatible Document object. (I am using Sam Corder’s mongo-csharp driver, so that I am targeting the Document object from that library.)

Default values

I also wanted to have a way to specify what the default values were for each class property so that when we did the conversion, we would (hopefully) not end up with any null values.  Plus, if for some reason there was a document in MongoDB that was missing a particular key-value pair, the DocumentConverter would automatically fill in that empty field with the default value so in the code we should never have any nulls.

This is something that I would like for my own purposes and may not suit everyone’s needs.  If it doesn't, simply leave off the DefaultValueAttribute and you’ll never know the difference.

My proposed solution

I figured the easiest way to accomplish this was to create a class that would encapsulate all the functionality needed to convert to and from Document objects and have my other classes inherit from that one. I imagined that the above code would change to something like this:

class SomeClass : DocumentConverter {
	[Attributes.DefaultValue("Default StringTest value!")]
	public string StringTest;
	[Attributes.DefaultValue(16)]
	public int IntTest;
}

And to do the conversion would be very simple.  To convert from someClass to Document would be:

Document document = someClassInstance.ToMongoDocument();

To convert from a Document object to someClass would be:

SomeClass someOtherClassInstance = new SomeClass();
omeOtherClassInstance .FromMongoDocument(someDocumentObject);

The DefaultAttribute class

using System;
namespace MyApp.Attributes
{
    [AttributeUsage(AttributeTargets.Field | AttributeTargets.Property, AllowMultiple = false)]
    class DefaultValueAttribute : Attribute
    {
        private readonly object _value;

        public DefaultValueAttribute(object Value)
        {
            _value = Value;
        }

        public object GetDefaultValue()
        {
            return _value;
        }
    }
}

The DocumentConverter class

Reflection isn't something that I use too often so there may be better ways of accomplishing what I am trying to do, but this is what I’ve got for now.  If there are better ways, please let me know.  Without further ado…

using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using MyApp.Classes.Attributes;
using MongoDB.Driver;

namespace MyApp.Classes
{
    public class DocumentConverter
    {
        public void FromMongoDocument(Document document)
        {
            foreach (DictionaryEntry kvp in document)
            {
                object propertyValue;
                if (kvp.Value != null && (kvp.Value.GetType() == typeof(Document)))
                {
                    // We have a document object - Now lets get a reference to the class property's type
                    var propertyType = GetType().GetProperty(kvp.Key.ToString()).PropertyType;

                    // create new instance of that class
                    var propertyInstance = Activator.CreateInstance(propertyType);

                    // call FromMongoDocument on that class and pass in the document
                    MethodInfo method = propertyInstance.GetType().GetMethod("FromMongoDocument");
                    method.Invoke(propertyInstance, new[] { kvp.Value });

                    propertyValue = propertyInstance;
                }
                else
                {
                    // This is not a Document so lets just assign the value
                    propertyValue = kvp.Value;
                }

                GetType().GetProperty(kvp.Key.ToString()).SetValue(this, propertyValue, null);
            }

        }

        public Document ToMongoDocument()
        {
            Document document = new Document();

            foreach (PropertyInfo property in GetType().GetProperties())
            {
                // Get the value of this property
                object propertyValue = property.GetValue(this, null);

                // If this value is null, then lets try to see if there is a default value attribute and assign that
                if (propertyValue == null)
                {
                    object[] attributes = property.GetCustomAttributes(typeof(DefaultValueAttribute), true);
                    foreach (DefaultValueAttribute defaultValue in attributes.Cast())
                    {
                        propertyValue = defaultValue.GetDefaultValue();
                    }
                    document.Add(property.Name, propertyValue);
                }
                else
                {
                    // We have a property, now lets see if this property has a ToMongoDocument method
                    MethodInfo method = propertyValue.GetType().GetMethod("ToMongoDocument");

                    if (method == null)
                    {
                        document.Add(property.Name, property.GetValue(this, null));
                    }
                    else
                    {
                        document.Add(property.Name, method.Invoke(propertyValue, null));
                    }
                }
            }
            return document;
        }
    }
}

That’s all for now

I hope this is useful for someone.  It is a rough draft of what I threw together last night at around 1AM while half asleep.  So far, it has passed all of my initial tests but if you have suggestions to make it better, please leave some comments here.

23Feb/107

The Current State of MongoDB and C#

Posted by Bryan Migliorisi

As a C# developer, I am often disappointed with the lack of drivers and connectors to cool services like MongoDB.  All the cool languages (and Java) get all the love but C# is often an afterthought.

Luckily for me, there are some kickass developers in the C# community who also share my frustration and as such, they have begun building their own C# MongoDB drivers.

I keep stumbling across more and more C# related MongoDB projects, so I figured I would write up a list and some short descriptions of these projects.

List of C# MongoDB Projects

Each of these projects are still rather new, so expect some features to be missing or not fully functional.  A couple of them are usable in your projects today while the rest are still under heavy development

mongodb-csharp

Originally written by Sam Corder (@SamCorder) with help from a handful of contributers, this is the most complete driver of the bunch. It has been evolving quickly and Sam & team are very quick to resolve any bugs that may arise.

I am using this driver in 2 projects that I am working on and so far things have been great.  It even includes GridFS suport.

From the project description:

Current Features

  • Connect to a server.
  • Query
  • Insert
  • Update
  • Delete
  • All BSON types supported
  • DBRef support
  • Isolation and conversion between BSON types and native .net types.
  • Database, Collection and Cursor objects.
  • Index handling routines (List, Create, Drop)
  • Count
  • Roughly 80% unit test coverage. This can and will be improved on.
  • Paired connections
  • Authentication (Does not reauthorize on auto reconnect yet).
  • Database Commands
  • Basic Linq support
  • GridFS support
  • Map Reduce helpers.
  • hint, explain, $where

They are currently working on connection management features (auto reconnect, connection pooling, etc).

Get involved or check out the code at their mongodb-csharp project page on Github.

mongodb-net

Written by the unnamed developer at DevFuel.com, the mongo-net project aims to be a C# port of the 10Gen\MongoDB official Java driver.  While a lot of work has been done and a load of code written, it is currently unusable.  Over the past couple of weeks a significant amount of progress has been made and functionality is beginning to work but it seems that a functional state is months away.

I would keep an eye on this project, though, as having an API compatible with the official Java driver has its benefits.

Get involved or check out the code at their mongodb-net project page on Google Code.

MongoDB.Emitter

Andrew Rondeau’s MongoDB.Emitter is a pretty cool project that provides a strongly-typed Document mapper for C#.  It works in conjunction with Sam Corder’s mongodb-csharp driver allowing the programmer to define strongly typed interfaces and properties.

I have not tried this yet, but this will be on my list of things to check out.

Get involved or check out the code at their MongoDB.Emitter project page on bitbucket.

CSMongo

Hugo Bonacci (@hugoware) has been working on a driver of his own called CSMongo. CSMongo doesnt support everything that mongodb-csharp does but it does have some interesting features, such as the approach to creating Mongo Documents.  Their approach definitely has a more dynamic feel to it which fites nicely in the unstructured MongoDB world.

I am looking forward to the next version which should have more features including support for Hugo’s own jLinq.

Code doesn't appear to be released yet but you can follow his progress at his blog, Hugoware.

simple-mongodb

Simple-mongdb is another project without public source that is being worked on by Daniel Wertheim (@danielwertheim).  I am not sure if it is even being actively developed but it too has some nice ideas.  The goal of this project is to keep the driver JSON-centric and should be compatible with awesome Newtonsoft’s JSON.net library.

They have a few examples of the proposed API but no code has been released to make said examples work.  This is another one to keep an eye on in the meantime.

Check out the simple-mongodb project page on Google Code.

DocumentConverter

This is a small class I wrote that works with mongodb-csharp.  Its name will likely change at some point if and when it gets packaged up and put on source control.  It exposes two functions that will allow any C# class to convert to and from a MongoDB Document object automatically.  It makes my life a lot easier and it uses System.Reflection to do this.

Read more about DocumentConverter on this blog post.

Conclusion

Well it looks like there is a significant amount of interest in MongoDB from the C# community which is great news because it looks like MongoDB is going to continue to thrive and grow.  My bet is that Sam Corder’s driver will be the most common C# driver, simply because it is so far ahead of the rest but time will tell.  Extensions of Sam’s project, such as MongoDB.Emitter, are equally as cool as the drivers they are built on.

Thanks toeveryone who has contributed to these drivers.  Each of them have some great concepts and I hope that one day we will have a driver that supports all these great ideas and features.

If there are any more projects that I have missed – let me know in the comments!

11Nov/090

Gotcha: 32-bit applications may not be able to see files on 64-bit Windows

Posted by Bryan Migliorisi

winlogo-300x265 This one really threw me off tonight.  I am running Windows Server 2008 on one of my boxes and I was trying to set up some advanced URL Routing on IIS7.  IIS7 Manager has a very nice easy to use GUI interface, but I prefer working directly in the configuration files.

I fire up my Notepad++ and attempt to open a file through the file browser.  I navigate to the IIS config folder (c:\windows\system32\inetsrv\config\) and I see an empty directory.  Huh? How is that possible?!

Now I switch over to Windows Explorer and go to the same folder as above and to my disbelief… there are all the config files.  Ok now I am truly confused!

Conclusion

While I cannot seem to find anything from Microsoft about this issue, my findings are that 32-bit applications cannot see the entire file system!  I installed a few applications that I know are only 32-bit to verify this and sure enough they all suffered from the exact same issue. 

Files simply do not show up and if you attempt to open the file (because you do know the full path & filename), it simply tells you that the file does not exist.