newtelligence poweredRSS 2.0
# Sunday, May 31, 2009

On Saturday May 30th I attended the first ever Chicago Code Camp. Thankfully it wasn’t actually in Chicago, but closer to Wisconsin which made the drive bearable. I rode down with Steve (thanks for driving) and I-Lin, and met up with Lance down there. Overall, the event was a great success I think, and it’s something we’d like to put on in Madison sometime in the near future.

Session #1 – Introduction to AOP with Post Sharp by Michael Hall

This was a good introduction to Aspect Orientated Programming (AOP) using Post Sharp (.Net Environment). I’ve looked into Post Sharp before when it first came out, but it looks like it has come a long way in terms of stability and features.

AOP involves moving code which implements non-functional requirements such as logging, security, transaction management, into Aspects which can be then applied across your application. Another term for non-functional requirements would be cross cutting concerns. An aspect can be though of as a class, and is made up of advice, or methods.

A common example used when describing AOP is the cross cutting concern or non-functional requirement of tracing. Typically, in each class where you require tracing, you will create a static read-only variable for your tracing object, and then in each method, you will call Trace.Write(). With AOP, you can apply an attribute to the class to perform tracing for all methods, or on specific methods. When the method is invoked, the tracing code is executed, either before and/or after the method body depending on how the aspect is coded. The advantage in this scenario is that you do not have to declare that tracing variable or write the code to write the trace statement every time. This way if you need to change the way the tracing works, you only have to do it in one location.

Post Sharp provide a framework for building and applying the aspects. The aspects are applied at compile time by injecting code into the compiled MSIL code. Aspects are created as attributes by inheriting from several Post Sharp base classes, which include:

  • OnMethodBoundaryAspect: Used with code you own. Allows for code to be executed before and after the method body.
  • OnMethodInvocationAspect: Used with code you do not own, allows for code to be executed before method.
  • OnExceptionAspect: Code to be executed if an exception occurs.
  • OnFieldAccessAspect: Code to be executed when a field is accessed, providing for property getter/setting like functionality on fields.
  • CompositionAspect: Change code at compile time. For example, you can force a type to implement a specific interface.

Out of the box, Post Sharp gives you an incredible amount of functionality with those base classes, but you can add new custom aspects if needed. Normally Post Sharp needs to be installed with the MSI installer since it is integrating with Visual Studio. However, instructions are available for an XCopy deployment.

Session #2 – Guarding your code with Code Contracts by Derik Whittaker

Code contracts is a project from Microsoft Research which is being integrated into VS2010, and is available in VS2010 Beta I, or as a download for VS2008. Code Contracts are a way to define static assertions at design time, to be validated at compile and run time.

You probably have written a “code contract before”, but have never realized it. A simple example is where you check to see if an object is null at the beginning of a method, and if it is, you throw an ArgumentNullExpcetion. The Microsoft version of Code Contracts replaces the If Then Throw convention with Contracts.Assert(boolean expression).

So why is the Microsoft Solution better? The Microsoft solution integrates directly into Visual Studio giving you support for Static Analysis at design time. This means that if you call a method with a Contract.Assert(paramter != null) and pass in null, you will get an error at compile time, as well as a warning in the form of a squiggly line under the method call at design time. Automatic testing tools like Pex can take advantage of the code contracts as well.

The real power of Code Contracts can be seen when you look at some of the advanced contracts offered. For example, you can validate that a return variable is not null, as well as validate a condition every time a method is called using the Invariant contract.

Run time errors are displayed using Debug.Assert behind the scenes. This is automatically disabled in the build type is set to release. You can also handle the debug assertion yourself by implementing an failed contract event handler.

Session #3 – Fluent NHibernate by Hudson Akridge

This was an excellent session and probably my favorite of the conference. Hudson is a member of the Fluent NHibernate team, so he obviously is an authority on the topic, and also has a deep passion for Fluent NHibernate that is hard to reproduce. Hudson had all of his demos compiled and running ahead of time. He simply created new projects and used printed copies of the source to type from. This saved a tremendous amount of time. When time did start to run out, Hudson simply switched over to his already completed projects to finish things up. Memo to presenters, follow this approach!

The Fluent NHibernate (FNH) wiki, as well as the project members blogs provide an excellent amount of documentation, that I simply can not duplicate in this blog post, so be sure to check out those resources.

FNH is built on top of NHibernate, and it’s purpose is to replace the NHibernate Mapping Files (HBM) with a strongly typed fluent interface, with the goal of making the use of NHibernate easier, while producing more maintainable code. It succeeds on both fronts.

FNH provides two mapping options, AutoMapper, and Fluent, both of which can be used at the same time. AutoMapper uses a convention based approach where Property and Class names map to tables in the database. This is great for simple domains and green field projects with simpler database schema requirements. The fluent interface provides for a much more granular approach to mapping, and currently supports most of the functionality provided by HBM files (most people will not know that anything is missing). The fluent interface allows you define conventions which allow you to reduce repetive mappings. For example, if all of your entities have an integer based Id field, you can define that, saving yourself from having to write the mapping code over and over.

FNH does have some limitations, such as, all properties must be public. Obviously there are some situations where this is not desirable, so you could switch to HBM files, or utilize on of three work-arounds for fluent. The first two involve nesting code at some level, while the 3rd involves the use of strings to identify the non-public field names. While you loose the strong typing and compile time checking, I think I like the string option the best.

Two general tips I learned during the session, was to always make your public properties virtual so that NHibernate’s default behavior of lazy loading will work. Hudson made the comment that you should not try to outsmart NHibernate’s lazy load mechanism. The only time you should consider eager load is if you have to detach your object from the NHibernate session. The other tip was the feature that allows you to generate a complete database schema from the NHibernate mappings. From comments I heard in the crowd, the schema generation is very impressive compared to other ORMs.

Session #4 – Mass Transit by Dru Sellers

Mass Transit is an Enterprise Service Bus (ESB) written in .Net 3.5 and is designed around simplicity and speed. I had a general idea of what Mass Transit was going into this presentation, and was hoping I would learn that it would be directly applicable to a project at work. However, it’s a little too much functionality for what we need, and that’s not a bad thing, as we could probably make use of it in the future.

While I have no immediate need for an ESB at work, I was very impressed with the .Net 3.5 syntax the project uses to handle subscriptions. I’m currently starting a prototype project that could make use of an in memory service bus, and I think I will be reviewing the Mass Transit source to see what I can borrow.

Coming from a BizTalk background, a lot of the features and functionality was comparable. However, whereas BizTalk costs money, Mass Transit is free, open source, and would probably meet the needs of most organizations. Both of the authors (Dru, the presenter is one of them) use Mass Transit daily in their jobs in the banking industry.

Session #5 – Solid WPF by Michael Eaton

This presentation could have been titled WPF and the MVVM pattern. Not that Solid WPF is a bad name, but for those of you at home, it was a talk on MVVM with some YAGNI thrown in for good measure.

This is not my first MVVM presentation, and it probably won’t be the last. Unfortunately I’m still struggling to fully understand the pattern, which is partly due to my lack of experience with WPF (which I need to remedy soon).

However, the approach that Michael took in presenting MVVM was different, in that he started with a WPF app coded using just the code behind, then did a copy/paste to a new project and tried a MVC pattern, and then finally worked in MVVM. Seeing the transformation of the application from the first to the third project did help solidify some of the MVVM concepts.   

Sunday, May 31, 2009 4:30:49 PM (GMT Daylight Time, UTC+01:00)  #    Comments [0] -
Programming
# Saturday, April 25, 2009

Back in March, I posted about creating a custom authorization filter to enable Partial SSL. While using the filter on an application I was porting to Windows Azure, I discovered a bug, which has led me to revisit my implementation. Here is the original code.

   1: public class RequireSslFilter:AuthorizeAttribute
   2: {
   3:  protected override bool AuthorizeCore(HttpContextBase httpContext)
   4:  {
   5:   if (httpContext.Request.IsLocal == false && httpContext.Request.IsSecureConnection == false)
   6:   httpContext.Response.Redirect(httpContext.Request.Url.ToString().ToLower().Replace("http", "https"));
   7:  
   8:   return base.AuthorizeCore(httpContext);
   9:  }
  10: }

 

As you can see, I’m calling base.AuthorizeCore at the end, which is what you usually do when overriding a method. However, since the purpose of he Authorize Filter is to, well authorize, the call to base.AuthorizeCore will return false if the user is not authenticated. This is a problem because you might not be authenticated at the time that this filter runs.

The reason I chose to use the Authorize Filter, is because it’s called before any other filter, as explained by Phill Haack. At first I thought about removing the call to the base.AuthorzieCore, but that seemed more like a hack, then a correct solution. Digging deeper, I discovered that the AuthorizeAttribute that I am inheriting from, implements the IAuthorizeFilter, which requires you implement the OnAuthorization method. So instead of inheriting from AuthorizeAttribute, I could just implement IAuthorizeFilter.

However, someone already did it for me. In the Asp.Net MVC futures project, released with the Asp.Net MVC RTM source, there is a RequireSSL attribute ready to use. The future’s project has more functionality then mine, allowing for the option to redirect or throw an exception. It’s nice to see I was on the right track at least.

RequireSSL Attribute from Asp.Net MVC Futures:

   1: public void OnAuthorization(AuthorizationContext filterContext) {
   2:             if (filterContext == null) {
   3:                 throw new ArgumentNullException("filterContext");
   4:             }
   5:  
   6:             if (!filterContext.HttpContext.Request.IsSecureConnection) {
   7:                 // request is not SSL-protected, so throw or redirect
   8:                 if (Redirect) {
   9:                     // form new URL
  10:                     UriBuilder builder = new UriBuilder() {
  11:                         Scheme = "https",
  12:                         Host = filterContext.HttpContext.Request.Url.Host,
  13:                         // use the RawUrl since it works with URL Rewriting
  14:                         Path = filterContext.HttpContext.Request.RawUrl
  15:                     };
  16:                     filterContext.Result = new RedirectResult(builder.ToString());
  17:                 }
  18:                 else {
  19:                     throw new HttpException((int)HttpStatusCode.Forbidden, MvcResources.RequireSslAttribute_MustUseSsl);
  20:                 }
  21:             }
  22:         }
Saturday, April 25, 2009 10:08:27 PM (GMT Daylight Time, UTC+01:00)  #    Comments [2] -
Asp.Net MVC | Programming
# Monday, April 13, 2009

I’m using LinqToSql as a quick way to access my database for some brownfield testing. I needed to execute a stored procedure that returned a result set, but after adding it to the LinqToSql design surface, I noticed that the return value was set to none, and I was unable to change it.

This stored procedure had two exec statements, and a Set Transaction Isolation level statement as well.  After commenting these out and re-adding the stored procedure to the design surface, I was still faced with a return value of none. I ended up deleting the stored procedure, rebuilding, and then re-adding. This finally resulted in a auto generated return value. I then uncommented the lines I had previously commented out.

While researching this, I found some other people with a similar problem, and rebuilding helped a few people, but not all, so your mileage may vary.

Monday, April 13, 2009 10:15:42 PM (GMT Daylight Time, UTC+01:00)  #    Comments [0] -
Programming | Sql
# Saturday, March 28, 2009

On Wednesday, March 25, the first meeting of the Madison All.Net special interest group (SIG) was held at Herzing College. The All.Net SIG is all about discussing all things related to Microsoft .Net technologies in an open spaces style meeting. Instead of the lecture hall style room we traditionally use for the Madison .Net User Group meetings, we opted for a classroom style room due to the format of the meeting itself. Aside from a brief survey form I created to get an idea on what people were interested in, we had no set agenda.

Below are the results of the survey, which I took to get a general idea of what people were looking to get out of the group. Just because something didn’t get a lot of votes (i.e. Windows Embedded only got one vote, which was me) doesn’t mean people can’t come to a meeting to ask for help, share their code and participate.

Topics

Asp.Net MVC 8 WCF 5 Windows Mobile 2
Architecture 8 Project Management 5 Windows Forms 2
Silverlight 8 SQL Server 4 IIS 2
Agile 7 Asp.Net Web Forms 4 BizTalk 2
Test Driven Design/Development 7 TFS 4 Other ORM 1
Entity Framework 6 WPF 4 XNA 1
Alt.Net (General) 6 Sharepoint 4 Linq2Sql 1
Domain Driven Design 6 nHibernate 3 Windows Embedded 1

 

Topics – Write-in Suggestions

Scrum, Prototyping, Requirements Gathering and Analysis, Networking (Wired, Wireless, etc), Dynamic Languages (Iron Ruby/Python), Security, WMI, Debugging, Best Practices, Subversion, db40 SQL CE, Sync Framework, Ado.Net Data Services, Azure

Meeting Formats

Group Project 8 Peer Code Reviews 6 Open Spaces 3
Pair Coding 6 Scheduled Topics 6 Guest Speakers 3

After the survey, I talked about the Mix09 conference I attended last week. This was a two way discussion, with lots of good questions, and not a presentation (no power point at all!). We talked briefly about Silverlight 3, Blend 3 (Sketchflow), Expression Web 3 (Super Preview), and .Net RIA services. While we were enjoying some Pizza, we watched a bit of the Bill Buxton/Scott Guthrie keynote, and had a good laugh at Scott’s intro video.

After the Pizza break we started looking at the Entity Framework, and some ideas on a group project. I did a quick tally in my head of the technologies people were interested in, and Asp.Net MVC, ORM (EF, nHibernate, etc), and general architecture were the top 3. I sketched out a pretty lame diagram showing how we could create a project that allowed us to tackle the top 3 (and other) technologies.

The project I proposed was basically a typical 3 tier application consisting of a Asp.Net MVC front end, domain layer (business logic/objects), and a data access layer implemented using a variety of ORMs. The reason for working with multiple ORMs, is that everyone has different needs, wants and desires, and we’re trying to be as inclusive as possible. I think almost everybody has some type of standard they need to use at work, and in addition to pushing the boundaries of technology they be already familiar with, they also want to try new things, and see how things work when implemented with a different ORM.

In order to allow for the use of multiple ORMs, I suggested the use of a repository pattern, which in simple terms, is a in memory collection of domain objects. To implement, you define a set of interfaces in your domain (business layer), and then create concrete implementations of the interfaces for each ORM you wish to implement. This is quite a common approach in Domain Driven design, and in the Alt.Net space, however, it’s usually done to aid in the testability and maintainability of the code base.

The following is my best attempt to create a list of all the web sites and projects that I referenced during the discussion (in no particular order). It is important to note that everyone’s implementation and terminology is a little bit different.

I don’t believe there was any final decision made on if or when we will start a group project, but I am excited to continue to talk about this. I already got one e-mail from someone who attended asking for examples which is why I included the list above.

Our next meeting should be around April 15th, but be sure to check the MadDotNet web site for the official date and time.

Saturday, March 28, 2009 2:14:01 AM (GMT Standard Time, UTC+00:00)  #    Comments [1] -
Programming
# Saturday, March 14, 2009

UPDATED: 4/25/2008 – See my new post of Partial SSL in Asp.Net MVC using the RequireSSL attribute from the MVC Futures Project

Tonight I was working on a small Asp.Net MVC project and was trying to add authorization and “require ssl” to specific pages using IIS. Of course you don’t have pages like you used to in Web Forms, so setting security and SSL on a per directory and per file basis doesn’t work like I’m used to.

The authorization requirement is actually pretty easy to handle once I approached the problem from a strictly MVC point of view. Using the Authorize attribute, which is included with Asp.Net MVC, I was able to pick and choose which controller actions I wanted to secure. In the code sample below I’m requiring the requestor to belong to the Users role.

[AcceptVerbs(HttpVerbs.Get), RequireSslFilter(Order=1), Authorize(Roles="Users",Order=2)]
public ActionResult ToServer()
{
   return View("ToServer");
}

When you need a little more control, you can implement a class that inherits from AuthorizeAttribute. Examples of when you might want to do this, would be if you wanted to change the authorized role at runtime, or not require any role (perhaps in your dev environment), or when you want to require SSL. In the above example you can see the RequiresSslFilter, which is a custom filter implemented as shown below which requires the use of SSL.

public class RequireSslFilter:AuthorizeAttribute
{
protected override bool AuthorizeCore(HttpContextBase httpContext)
{
   if (httpContext.Request.IsLocal == false && httpContext.Request.IsSecureConnection == false)
   httpContext.Response.Redirect(httpContext.Request.Url.ToString().ToLower().Replace("http", "https"));

   return base.AuthorizeCore(httpContext);
}

}

In the code, I’m checking for if the request is local and secure, and redirecting to a secure version of the request. The check for IsLocal is useful for development scenarios. I added the Order parameter to the use of the RequiresSslFilter attribute to ensure that I check for the use of SSL before the check for the role. This helps ensure that credentials are only sent over SSL.

Saturday, March 14, 2009 3:44:29 AM (GMT Standard Time, UTC+00:00)  #    Comments [0] -
Programming
# Friday, February 06, 2009

Last night was the regularly scheduled meeting for the Madison .Net Users Group and consisted of a presentation on MVVM by Christopher Huganen, and the first meeting of the TFS SIG, led by Travis Feirtag.

MVVM

MVVM stands for Model, View, View Model, and is an architectural pattern that focuses on testability and separation of concerns. While MVVM can be used in a variety of application environments, the focus of this presentation was on it’s use with WPF. As a matter of fact, I’m seeing MVVM paired specifically with WPF more and more.

Some key advantages of MVVM that were talked about include:

  • Separation of Concerns
  • Use the force of WPF (bindings)
  • Write less code
  • Easy to Unit test
  • Split Designer/Developer responsibilities

To the inexperienced WPF developer (which includes myself), it may seem difficult to believe that MVVM leads to writing less code. At first glance, and from reviewing numerous (short) examples, it basically looks like you are rewriting your business entity class, but adding support for binding and other View concerns. I believe that overall it will lead to less code, but I can’t comment directly on it until I actually implement something using this pattern (which I hope to start soon).

Here are a few links that were provided last night that talk more about the MVVM pattern:

And for the sake of completeness, here are a couple of definitions for some similar patterns.

TFS

As I mentioned in my opening, last night was the first meeting of the TFS SIG. Travis put together a short slide deck outlining the purpose of the SIG (TFS SIG Slides), and also brought an external hard drive with a VPC image containing TFS 2008 and Team Suite 2008 (running on top of Win2k3 Server).

I am really excited about participating in the TFS SIG, as TFS is something I started, but I guess you could say never finished. So in addition to the labs and topics covered initially at the SIG, I’m hoping to start a project with the purpose of better understanding TFS from the project management point of view.

Here are some links to some of the things I brought up during the SIG portion of the meeting (and a few other links):

MVC

After the meeting I got to talking with a couple of people about Asp.Net MVC and promised a couple of links:

Friday, February 06, 2009 5:07:02 AM (GMT Standard Time, UTC+00:00)  #    Comments [0] -
Programming
# Saturday, January 24, 2009

Like a lot of developers, I am an early adopter, and as such I downloaded and installed Windows 7 beta (blog post forthcoming) on a variety of my computers and created new VM’s. I decided to try to switch over to a Windows 7 beta dev machine at home, to see if there are any gotchas. So far there is nothing related to Windows 7, but getting VS to work fully with my projects stored on a network share took some additional time.

Apparently I completely forgot I had to set Code Access Security on my original development machine, and even after I remember vaguely doing it, I don’t remember what I did. Going back and looking at the settings via mscorcfg.msc, it looks like I just granted the local intranet full trust. This time around I wanted to just grant the full trust permission set to my projects folder on my network share. Not that I don’t trust my local intranet, it just seems like the correct thing to do.

First I tried messing around with the command like tool, caspol, but my command line skills just were not cutting it. I looked for mscorcfg, but it’s no longer installed with Visual Studio (2008), so I downloaded and installed the latest .net SDK. I figure there are some other good tools in it any way. With access to mscorcfg, I set out to grant my user share, U:\Projects full trust permissions.

I figured out that I needed to add a new code group, but I didn’t know under which zone. Reviewing the error in Visual Studio, it referenced both My Computer and Local Intranet. I decided to try My Computer first, and that didn’t work, so I created a second code group under Local Intranet and that did work. I didn’t want to leave extra stuff around, so I removed the code group from My Computer and everything still worked.

Here are the steps I took:

  1. Open mscorcfg (as an administrator if you want to modify the CAS at the machine level)
  2. Under Runtime Security Policy, expand the Enterprise, Machine, or User, and then under Code Groups drill down to the Local Intranet Zone
  3. Right click on Local Intranet Zone and choose new
    1. Ender a name and description for your code group and click next
    2. For the condition condition, change it to URL.
    3. This is the tricky part, entering a correct URL. The path I wanted to add, as shown in windows explorer is U:\Projects, but the error message in VS showed file:///U:/Projects/, so I used that as the URL and added a * at the end, so I ended up with file:///U:/Projects/*. Click Next.
  4. Select Full Trust, and click next
  5. Click finish

You need to restart Visual Studio after you make a change. While looking for some help on the Internet, I also saw that you can use mscorcfg to create a MSI installer package with your CAS settings, which you can run on other machines, or deploy via group policy. This option is available as “Create Deployment Package” when you left click and select Runtime Security Policy.

Saturday, January 24, 2009 4:12:53 AM (GMT Standard Time, UTC+00:00)  #    Comments [0] -
Programming
# Friday, January 02, 2009

This week I started working on my first Asp.Net MVC project. The requirements I am working with approximately 5 pages or views, and is read-only in nature, which I thought would be perfect for trying out the MVC stuff. I am also trying to take a incorporate some other methodologies, tools and techniques I have been reading up on, including:

  • Domain Driven Design (DDD)
    • Repository Pattern
    • Your not going to need it principle (YNGTNI)
    • Keep it simple stupid (KISS)
  • Test Driven Design (TDD)
  • Mocking (RhinoMocks)
  • Inversion of Control (Ninject)

So far the project is going really well. I’ve created all of my views, controllers, and basic page navigation, including some URL validation that redirects the user to a page when a parameter is missing from the URL (id part of the default route).  I’ve also added Inversion of Control using the Ninject framework, which I am using to specify my data store type (In memory for testing, or a Sql based store for actual data). I choose Ninject due to it’s small footprint, focused feature set, and Compact Framework and Silverlight compatibility (while not needed for this project, I have a use for that level of compatibility on another project and wanted to limit the number of frameworks I’m using).

CodeBetter: I should have thrown this out in the beginning, but I’m using the Foundations of Programming Ebook and learning application written by Karl Seguin as a starting point. I highly recommend it for people looking to get into the Alt.Net mindset (DDD, TDD, mocking, etc).

Solution Structure: At the start of this project, I was working up an elaborate solution (directory) structure, where I would separate out my Infrastructure, MVC, Domain, and Data Stores into separate projects. I quickly realized, that this wasn’t needed based on my requirements, nor did it follow KISS or YNGTNI. Instead, I separate out my concerns in the MVC project using namespaces. Since I am making heavy use of Unit Testing, if the need ever arose I could split stuff out into separate projects in less then a day, update my tests and be good to go. So in the end, I have one MVC project, a unit test project, and a Web Test project.

TDD: I have two testing projects, one for unit tests, using Xunit, RhinoMocks, and TestDriven.Net. This project tests all of the code for the model/domain, controllers, and infrastructure. My other project uses MSTest and is for my Web Tests, which are more of integration tests. There are some things you just can’t unit test that well, like did the menu get hidden when no account number was present in the URL.

Routes: I am using the default route Controller/Action/Id that comes with the sample project. This fits my requirements perfectly, as I need the Id part for an account number. My requirement was to have a URL in the form of http://Website/Home?Account=123456 which I was able to change to http://Website/Home/Account/123456

Code Behind: I’ve gone ahead and removed all of the code behind files on my views and user controls to make sure I don’t take any shortcuts with the code behind files. I’ve read several work around's for getting strongly typed views without a code behind file, so I’m covered there. By removing the code behind you eliminate 2 extra files per view/user control (ViewName.cs and ViewName.Designer.cs). Just remove the AutoEventWireup and Codebehind attributes in your view, and change the inherits attribute to System.Web.Mvc.ViewPage or ViewUserControl

<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %>

Passing Id: One thing I found out I needed to do often, was construct a URL the conformed to my routing. Thankfully there is a helper method you can use in your view called Html.ActionLink, which has several overloads. I’m using the overloaded method that takes the name of the controller, action, an object for values, and an object for html attributes. Getting the object passed for values was not apparent right away, but you make use anonymous types.  The following code creates the following link, Home/Account/123456 (assuming ViewData[“Id”] is set to 123456), and gives it a text value of Home.

Html.ActionLink("Home", "Account", "Home", new { id = ViewData["Id"] }, null)

Filters: As I mentioned before, in using the default route, I’m “mapping” id to an account number. If there is no account number present, or the account number does not correspond to an actual account, I need to take some action. At first I had a helper method that I would call from each action that needed the account number, and redirect to a certain view if the account number was missing. Then I read about filters, and the OnActionExecuting override in the controller object, and thought that would be a better way to go. However, I’m going to go back to calling a method in each action for the following reasons:

  • Easier to unit test. With OnActionExecuting override, I havn’t been able to find a way to unit test the method or the overall behavior.
  • Code Smell. While one could argue writing the same line of code in each each action method smells, it is not as bad as having to check for certain action names in OnActionExecuting. For example, I didn’t want to redirect to the account entry page if I was already there. This way, I can call the method only on the action methods that need it.
  • Easier to understand. To the uninitiated MVC programmer, it’s simpler to follow then attributes or a base class override.

That’s all for now. I’ll try to write an update after I finish the project. I need to work with grids, and the new MS Charting controls, so that would be worthy of a follow up post.

Friday, January 02, 2009 2:23:06 AM (GMT Standard Time, UTC+00:00)  #    Comments [0] -
Programming
# Monday, December 08, 2008

In part I, I talked about how I had a need for a way to managed suspended messages in BizTalk using something other then the BizTalk Administration tool. Using a combination of BizTalk dll’s I was able to query, read and suspend BizTalk messages. The need for a “web” based tool is one of accessibility to our BizTalk server from remote machines that are not directly connected to the DMZ zone that they reside in. I’ve also been wanting to create a tech support tool for myself to manage other aspects of our hosted solution, and this would fit in nicely with it.

Being a glutton for punishment, I decided to sacrifice my weekend and go for the more complex, but really cool sounding idea of a set of web services that interface with SilverLight 2. I choose SilverLight as I’ve been wanting to get my hands dirty with it for some time, and another member of the team was talking about doing the same, and what’s a little friendly competition? While I had a grand vision of what my tool would look like, which I will refer to as the Unified Administration Tool (UAT), I knew I wouldn’t be able to code everything in one weekend. I had to set some realistic goals and try to add only what was needed, while still allowing for future functionality to be “plugged-in”. The good thing was, since this was pretty much just for me, I didn’t have to worry about other peoples requirements ;)

The UAT is an n-tier application which will provide administrative functionality over our hosted solution that is distributed among several servers in different DMZ zones (as mentioned in Part I of the BizTalk Web Admin). In addition to dealing with the distributed nature of our servers, the tool must also account for the various environments, with one environment consisting of an instance of our solution deployed across one or more servers. Perhaps to put this more simply is that I wanted to be able to perform the same functions on our development, staging, demonstration and production environments.


I started out by created a new project folder to which all my various Visual Studio projects will be added. I moved my BizTalkUtilities projects into the Components folder as shown below, and then started adding the other components and UI projects as needed. Below is an overview of how I have my solution folder setup, which will probably change over time. The idea is that Components are reusable across all the UI and Services, and will probably have some more domain specific wrappers. Controllers under UI will be re-usable across each of the UI projects and provide an interface between the components and the UI.

  • UnifiedAdmin
    • _Solutions
    • Components
      • BizTalkUtilities
      • BizTalkUtilitiesTest
    • Documentation
    • Scracth (Prototypes and other throw away code used for quick tests)
      • BizTalkMessageBrowser (Test win forms app for BizTalk Utilities)
    • Services
    • UI
      • Controllers
      • Silverlight
      • SilverlightMobile (Future project)
      • WPF (Future Project)

I decided that I will use the Entity Framework as my “ORM”, combined with Ado.Net Data Services as my primary web services mechanism. Combined with Silverlight, I’ll get to tackle three new technologies at once, and either learn allot, or give up, ultimately frustrated, wishing I would have chosen a few older tried and true technologies. Before we even get to the UI, I needed to start setting up my services and entity model. I have a feeling I’ll be re-arranging some of these projects, but for now I have a class library called Entities under Components, and a web project called UnifiedAdminService under Services.

I really don’t know what the best practice way for organizing my entity models are, and it seems like one entity model per project seems a bit of an over kill, however, putting all the entities I will be working with in the same project doesn’t seem to smell good either, as there defiantly a clear break between them. I started out with an entity model for a database called Utilities, which will be the “glue” that holds my Unified Admin tool together. It’s sort of a catch all database that currently contains tables for some SQL based monitoring I have setup, as well as users (who can access the UAT), and servers (what servers does the UAT work with). I created a new Ado.Net Entity data model and had it auto generated the model from the database schema. This was pretty easy and straight forward. I prefix all my table names in my schema with various prefixes for grouping and identification, such as “mon_t” which means the table is used for the monitoring functionality, and it’s a table. I don’t want these prefixes in my code, so I am going to rename the entities in the model. To start with I’m only renaming a couple until I see how the EM is updated and used throughout the code.

Next I created a new Ado.Net data service in the web project. This created a new .svc file with a code behind file that inherits from DataService<T>. I updated T to reference my entity model (Entities.UtilityEntities) and also configured the security to allow read access for entities. You do this by using the config.SetEntitySetAccessRule method in InitializeService. 

public class TsiUtility : DataService<Entities.UtilityEntities>
{
   // This method is called only once to initialize service-wide policies.
    public static void InitializeService(IDataServiceConfiguration config)
    {
       config.SetEntitySetAccessRule("*", EntitySetRights.AllRead);
    }
 }

Even thought the auto-generated comments for InitializeService make it sound like it’s only called once in the life-cycle of an AppDomain, I wasn’t sure. This post talks a little bit about the InitializeService method, and does in fact point out that the InitalizeService method is only called once.

I attempted to browse to my newly created service and was greeted with an un-informative error, “The server encountered an error processing the request. See server logs for more details.”. Since I’m running the development server that’s included with Visual Studio, there are not much in the way of server logs (that I could find anyway). Jumping into debug mode showed that the error was caused by an incorrectly configured connection string. The connection string used my the Entity Framework is not your standard connection string, so you need to make sure that you copy the connection string created for you in your Entities project to your web.config in your web project (assuming your entity model is in a separate project). I was trying to use the Server, Database, Trusted_Connection syntax, and apparently that’s not OK.  Example connection string:

<add name="TsiUtilityEntities" connectionString="metadata=res://*/TsiUtility.csdl|res://*/TsiUtility.ssdl|res://*/TsiUtility.msl;provider=System.Data.SqlClient;provider connection string=&quot;Data Source=Server;Initial Catalog=Utility;Integrated Security=True;MultipleActiveResultSets=True&quot;" providerName="System.Data.EntityClient" />

Once I had the correct connection string, I was able to navigate my entity model using just my browser. Of course I haven’t done any type of authentication, and I don’t want to have just anybody browse to the URL for the UAT and start browsing, so it’s time to add some security. Ado.Net data services makes use of existing security provides as long as they set the HttpContext principle, so you can use HttpContext.Current.User.Identity.Name and then compare that against records returned by the EM. Something that I didn’t fully grasp at first, was that by the time Ado.Net Data Services “takes over” the user should have been authenticated, so there really is no “login” event in Ado.Net data services where you can set additional information.

For simplicity, I decided to use Integrated Authentication, and store additional information after the user is authenticated. Since this is a regular asp.net application, you can add a Global.asax, and add code to the AuthenticateRequest event handler to perform additional security related code. When AuthenticateRequest is called, whatever mechanism that is configured to handle authentication has finished, and there should be a value in HttpContext.Current.User. What I did was user the Name property to query my users table that was part of my entity model and cache the results in a hash table, which itself is stored in the application context. If the user does not exist in the database, I set the Current.User to null, and cache a null value with the key of the user name that was authenticated.

protected void Application_AuthenticateRequest(object sender, EventArgs e)
  {
   string userName = HttpContext.Current.User.Identity.Name;

   //Get a collection of cached users. If it doesn't exist create and cache it.
   System.Collections.Generic.Dictionary<string, Entities.User> users = (Dictionary<string, Entities.User>)HttpContext.Current.Cache["Tsi_Users"];
   if (users == null)
   {
    users = new Dictionary<string, Entities.User>();
    HttpContext.Current.Cache.Add("Tsi_Users", users, null, DateTime.Now.AddHours(1), System.Web.Caching.Cache.NoSlidingExpiration,
     System.Web.Caching.CacheItemPriority.Normal, null);
   }

   Entities.User user = null;

   //Check to see if we have a cached user for this username. Use ContainsKey as we will store
   //a null value to indicate a user is not authorized.
   if (users.ContainsKey(userName))
    user = users[userName];
   else
   {
    Entities.TsiUtilityEntities entities = new Entities.TsiUtilityEntities();
    user = entities.UserSet.FirstOrDefault(u => u.WindowsUserName == userName && u.IsEnabled == true);
    user.ua_tx_UserServers.Load(); //load servers this user has access to.
   }

   //User doesn't exist in the database either, so un-authenticate them
   //allow to continue thru so we add a null object with the username to cache
   if (user == null || HttpContext.Current.User.Identity.IsAuthenticated == false)
   {
    //When this is set to null, this method should finish, but no data will display. 
    //Seems like aspx pages will still display though. However if you check the CurrentUser
    //it will be unathenticated.
    user = null;
    HttpContext.Current.User = null;
   }
   
   //save to users collection. Double check to make sure it wasn't added somewhere else.
   if(users.ContainsKey(userName) == false)
    users.Add(userName, user);
  }

What I have not decided upon, nor have I done the research into, is if I should be caching the DataContext in the application or session cache for the user.

So where does this leave me? Well, I certainly didn’t get even close to what I wanted to accomplish in one weekend, as I haven’t even touched SilverLight yet. I do have some basic authentication, but that’s more using traditional asp.net then doing anything special with Ado.Net data services. From the looks of it, I will have to add QueryInterceptors to every entity I wish to do security on, which seems like a pain and allot of extra un-necessary work. Next time I hope to accomplish the following:

  1. Research to find out if you should cache the data context
  2. Write out security requirements and research the best way to implement in Ado.Net Data Services
  3. Figure how I am going to have one set of services that can connect to multiple databases (assuming the database schemas are kept in sync).
Monday, December 08, 2008 3:09:26 AM (GMT Standard Time, UTC+00:00)  #    Comments [0] -
BizTalk | Programming
# Tuesday, October 14, 2008

Scott just blogged about T4, the Text Template Transformation Toolkit. It’s a full blown template driven code generation tool that uses the same syntax as Asp.Net. It’s lacking things such as syntax highlighting and intellisense, but it’s free, and part of Visual Studio.

I feel with the recent press this tool is getting, it will become even more popular, and some of the missing features added by the community. Scott has a whole list of links on his post that provide good samples, as well as a link to a company that provides a free and pay version of a plug-in to add some of the “missing” functionality.

Tuesday, October 14, 2008 9:33:04 PM (GMT Daylight Time, UTC+01:00)  #    Comments [0] -
Programming | Review For Future Projects
# Tuesday, October 07, 2008

Rob Conery, creator of SubSonic, and the ASP.Net MVC Store Front video series has released an early prototype of a Visual Studio 2008 add-in called the SubSonic MVC Scaffold Addin. Let me point out right away that there is no dependency on SubSonic itself, rather this add-in uses Linq2Sql, although Rob says a SubSonic plug-in is on the drawing board.

Not to rehash his announcement, but basically this add-in takes a Linq2Sql class, and generates some views (view, edit, list), and a controller based on the class. This is meant as a quick start kind of thing, not a full fledged commercial web site generator.

I encourage you to visit his blog post and watch the video he has prepared, it does an excellent job of showing you what the Scaffold does. Here are some of my take-away's:

  • Uses pre-existing Linq2Sql generated classes
  • Creates wrapper objects around Linq2Sql classes
  • Creates MVC views (you can create your own template to use in this process)
  • Creates MVC controller
  • If you re-run the scaffold on a class you previously generated, no files are updated (overwritten). You can delete individual files, and scaffold will generate them again.
  • Not everything works perfectly, you will/may need to go in and change some code. This is to get you started with something quickly.
  • RESTful style URL
Tuesday, October 07, 2008 10:37:11 PM (GMT Daylight Time, UTC+01:00)  #    Comments [0] -
Programming | Review For Future Projects
# Saturday, August 23, 2008

I’ve been looking at a couple of the new technologies that were released with .Net 3.5 SP1, mainly the Entity Framework (EF), and ADO.Net Data Services ADNS). I happen to look at ADO.Net Data Services first, and it seemed to look pretty good on paper. There was a reference to the Entity Framework in that Data Services uses the Entity Model (EM) from EF to provide the data access layer.

Last night I started searching for more information on the Entity Framework, and instead of finding examples, best practices, etc, I found a battle waging between the Creators/Supports of the Entity Framework and people practicing what I have come to know as Alt.Net.

I am using the term Alt.Net to refer to ideas and concepts such as Domain Driven Design (DDD), Test Driven Development (TDD), Agile, Plain Old CLR Objects (POCO), Persistence Ignorance (PI), and nHibernate (as there is allot of comparison made to the EF). I should also note that the ideas and concepts listed are not entirely specific to .Net, nor is this a complete list. Furthermore, you could be a practitioner of Alt.Net and completely support EF.

To get an idea of where the Alt.Net crowd is coming from you should start off by reading the Vote of No Confidence on WuFoo. Then simply Google for Entity Framework and you will see all sorts of competing opinions. Frans Bouma, creator of LLBLGen Pro, has a couple of posts (here, and here) that I think show he is against the EF, but for slightly difference reasons then the Alt.Net crowd. Here are some of the top Pros and Cons I’ve found.

Pros:

  1. It’s support by Microsoft, and as such, will gather much momentum and community support
  2. It’s good enough for X% (usually stated as greater then 50%) of software projects out there.
  3. GUI editor/mapper makes it easier to use then other ORM tools like nHibernate
  4. EF is part of a larger push by Microsoft to provide technologies that focus on an Entity Model (See Ado.Net Data Services)

Cons:

  1. No support for POCO’s and Persistent Ignorance
  2. Hard (or impossible) to develop using a Domain Driven Design, or Test Driven Design methodology
  3. Single model/mapping file introduces merge conflicts in a source control environment
  4. No additional functionality of products like nHibernate

I kind of see Pro #1 being the cornerstone to the argument. I feel that the Alt.Net crowd knows that EF has a good chance to become the defacto standard, and that they will be forced by their clients and employers to use it. As such, they are trying to point out some of it’s short comings to Microsoft in hopes that if it does become the defacto standard, that it won’t suck (to them) as much.

The EF team has been very open with the community, and reading posts leading up to the release of the EF, you can already see that the team was listening to the community. They introduced something called IPOCO, which removed the requirement that Entity classes implement a base class, and instead implement interfaces. This pleased some, while it annoyed others, since it still breaks true Persistent Ignorance.  I feel it’s a step in the right direction.

There are other indications that V2 of the EF will introduce true Persistant Ignorance, although the EF team usually talks about a performance hit (and it sounds like it could be a big performance hit) if you want to go the POCO route. The reason for this is the lack of the EntityKey field in a POCO object, which is used in subsequent operations after an entity is retrieved from the framework.

Overall, I find myself smack dab in the middle of the two camps. I’ve been trying to explore and learn more about Alt.Net, while at the same time keeping up on the latest from Microsoft. I’ve come up with the following guidelines for myself.

  1. Since EF is not support in Compact Framework, and I need to write business entities for the Compact Framework, or one’s that can be used in both the Full and Compact Frameworks, EF is out (so is nHibernate for that matter).
  2. If I need to work on a new back end application that is going to be using SQL server exclusively (there is support for other data stores in EF), then EF might not be a bad way to go.
  3. If I need to work on an existing back end application, I don’t think it’s worth the time to switch to EF yet, as it’s still a V1 product.

In the near term, I see my self doing some CF programming, as well as some one-off programming against our backend, which gives me a nice blend I guess. I’ll get to play around with EF some, and keep exploring the ideas of Alt.Net.

One final item I’d like to point out is the Entity Framework Contrib Project on CodePlex. While it hasn’t had a release since before RTM of the EF, it does provide some very interesting additions to the EF. The one that interests me the most, might just in fact be the bridge between the EF and POCO that everyone is looking for. Using PostSharp, the IPOCO interfaces are implemented at compile time, thus keeping your entities persistent Ignorant. The trade off is that you have to add some attributes to your code, but at least you could add these conditionally, which would help with the CF/FF issues I have.

Unfortunately the main contributor has taken a job and Microsoft on the SilverLight team, and in response to the EF’s team to add POCO support, has lost some of his interest in the project. I really like the post compile time option that the contrib project uses, as it seems to address the performance hit that the EF team says their POCO solution will have.

Saturday, August 23, 2008 8:51:13 PM (GMT Daylight Time, UTC+01:00)  #    Comments [0] -
Programming | Review For Future Projects
# Sunday, August 17, 2008

With the release of all Visual Studio 2008, TFS 2008, and SQL 2008, I set about upgrading I set about upgrading my main development laptop. Currently I have VS 2008, Team Explorer 2008 and SQL 2005 client tools installed. I opted to download the full installer for the SP1 updates as opposed to the bootstrapper options.

I knew I needed to install VS 2008 SP1 prior to TFS 2008 SP1, but for some reason decided to go with the SQL upgrade first. As I mentioned before, I currently only have the client tools installed, as I like to keep my SQL servers on virtualized development servers.

The SQL 2008 installer starts off by checking for .Net 3.5 SP1, and if it does not exist, it will install it on your machine, along with a hotfix for windows installer. After this is complete, you are required to reboot your machine. I opted for the upgrade option, hoping that everything just works. I’m not sure if you can do a side by side install with SQL 2005 client tools and 2008.

After selecting my options, an upgrade check is preformed, and it failed because I have not installed VS 2008 SP1 yet. OK, I wanted to install that anyway, so I canceled out and launched the VS 2008 SP1 installer. As with most service packs for Visual Studio it takes awhile to apply, but my experience was more positive then the service packs for VS 2005. No reboot was required, so I moved onto the TFS 2008 SP1 install.

So I must have mis-understood or did not read something with the TFS 2008 SP1 installer. It looks like it’s for the server components only, and VS 2008 SP1 handles upgrades to Team Explorer as well. This blog post makes reference to this, and even says that if you are installing Team Explorer on your TFS server, to install VS 2008 SP1. Looking at Help/About Microsoft Visual Studio, I see the version number for VS 2008 is now 9.0.30729.1 SP, and looking at the details for Team Explorer shows the same version number.

Jumping back to the SQL 2008 installer, I proceeding with my update. However it wasn’t really an update as much as it was a side by side install. Remember, I was just doing the client tools, had I had the database components installed, I assume that those would have been upgraded. I have a couple of SQL 2005 instances I can try an upgrade on to see what happens. The install went very smoothly and there were no issues.

First impressions of the new SQL Management studio are extremely positive. I saw the intelli-sense demo at the launch event, but can’t really test it as I already have SQL Prompt installed. My job as a Pseudo-DBA just got easier.Here are some new features I found.

  • When running queries, you can view the results in traditional grid view, but also as text (with options to choose your column delimiters), or export to a text (.rpt) file.
  • The new activity monitor actually provides useful information (well alot more information then the old one ever did). It reminds me of the task manager in Windows Server 2008. The new activity monitor does not work with SQL 2000, but I will be eliminating all SQL 2000 boxes by the end of September. As 4 line graphs across the top you get % Processor time, Waiting Tasks, Database I/O and Batch Requests/Sec. On the bottom you get 4 collapsible lists: Processes, Resource Waits, Data File I/O and Recent Expensive Queries.
  • The database publishing wizard from Visual Studio is now included. Actually there are a lot more options to control how your scripts are generated.
  • There are some very nice default reports built in now as well. The reports were an add-on for SQL 2005, but they are now included (and you can of course write your own). Stuff like Disk Usage, Index Usage, etc. I hope I can find a way to schedule these to be emailed.
  • New option to generate Create and Drop Script (along with the original separate options of generate create and generate drop). There is also an option to generate as SQL Agent job.

Finally I went ahead and upgraded our TFS server to SP1. First thing I did was install this month’s Windows Updates, as I was going to have to reboot anyway. Next up was Visual Studio 2008 SP1, as I have VS and Team Explorer installed. Unfortunately I was out of room on my system drive so I had to take the extra step of expanding my virtual hard disk first.

I rebooted the server, and then proceeded to install TFS 2008 SP1. It looked like everything was going good, but it failed at some point. Turns out the SQL server did not survive the reboot, VS 2008 SP1, or the system drive expansion. Somehow my mssqlsystemresource.ldf file got messed up at some point. The event log error stated “One or more files do not match the primary file of the database.”. I got better information out of the SQL error log which pointed me right to the System Resource ldf. I copied the ldf file from another SQL 2005 server and was back in business. The TFS update proceeded without incident after that. In case you are wondering, you can determine your TFS version by looking at the version of Microsoft.TeamFoundation.Server.dll in %Program Files%\Microsoft Visual Studio 2008 Team Foundation Server\Web Services\Services\bin. For SP1, the version number matches that which is displayed in Visual Studio 2008, or 9.0.30729.1.

Sunday, August 17, 2008 1:00:32 AM (GMT Daylight Time, UTC+01:00)  #    Comments [0] -
Technology | Programming | Sql
# Wednesday, August 13, 2008

My weekly Code Project newsletter had a link to a submission which talked about, and rated various Aspect Orientated Programming (AOP) frameworks for .Net. While I’ve heard about AOP in the past, I haven’t looked into much. What got me off the side lines, was that one of the .Net AOP frameworks, Post Sharp, lists support for the Compact Framework and Silverlight. In my experience, it is rare to see stuff that actually supports the compact framework, so this is a welcome change, however I have not tested it out yet.

Before I dive into Post Sharp anymore then I have, I wanted to read up a bit on AOP. WikiPedia has a good article explaining the AOP using AspectJ as the example language. PostSharp itself has a an article that focuses on the .Net Framework as well.

What is Aspect Orientated Programming (AOP)?

  • AOP increases modularity by allowing the separation of cross-cutting concerns
  • A concern is a cohesive area of functionality (think encapsulation).
  • Cross-Cutting concerns are those concerns which are used in multiple concerns
  • Logging is the most typical example of a cross-cutting concern. It itself is a concern (encapsulated functionality), that is used everywhere in your program.

Examples of Cross-Cutting Concerns

  • Logging
  • Exception Handling
  • Tracking is dirty on fields
  • Auditing
  • Security
  • Transactions

How does it work (based on Post Sharp)

  • Implement cross-cutting concerns as classes creating attributes (implementing various interfaces in Post Sharp)
  • Decorate your code using your attributes. Attributes can be added at the method, field, class and assembly level. At the class and assembly level you can specify a filter specify which methods or classes to work on.
  • When you compile, Post Sharp performs post build processing injecting code into your compile MSIL, producing modified MSIL as the final output.

AOP Frameworks

Performance

I was originally under the impression that by injecting code at compile time, there would be no performance hit at run time. This is not true, at least in PostSharp using the simple performance test from the user provided samples.

The simple performance test sample shows that AOP using Post Sharp incurs a variable performance hit. Running the sample application multiple times shows the first time the post sharp code is hit (view the complied .exe in reflector) it takes 73ms, and then this drops down to 14 ms, compared to 4 ms for the non PostSharp code. On subsequent runs, the first access of the post sharp code takes ~21ms and then drops down to 14ms, while the non PostSharp code remains at 4ms.

The sample in question uses the works on a field in a class. The aspect (attribute code) is required to cast an object passed in by the event args to a string. Perhaps generics could help with performance by eliminating the cast?

Final Thoughts

AOP and PostSharp look like very powerful tools that I would like to take advantage of. Learning from my past mistakes, I need to make sure that I take the time to understand these tools and use them where appropriate and not go overboard with their use. I think a good first step would be to find, or write some examples that implement some basic AOP functionality covering all of the cross-cutting concerns identified above.

The only complaint I have so far is that you have to either install PostSharp on your computer, or manually edit every project file that needs post processing. This seems a little heavy handed, but I’m willing to consider it a fair tradeoff. It just makes it hard to do a strictly x-copy deployment of a project/solution.

I’ve also been reading up on software architecture, including topics on Separation of Concerns and Loose Coupling. I think it is obvious that AOP can help with the separation of concerns (it’s pretty much stated in the definition). I also get the feeling that it could help with loose coupling, but I haven't seen a good example on that yet. All the examples I have seen would require tight coupling of your aspects (attributes) to something like log4net (in the logging example).

Finally, I will need to continue to evaluate performance to determine if it’s a fair tradeoff with increased maintainability of code. I am most concerned on the compact framework side of things, as the processing power that those apps run on is not as great as their desktop counterparts. This is not a knock on PostSharp, but just something to be aware of.

Wednesday, August 13, 2008 4:36:47 PM (GMT Daylight Time, UTC+01:00)  #    Comments [0] -
Programming
# Wednesday, July 09, 2008

We have some WSE 2.0 secured Web Services that we are migrating to a new data center. As part of this migration effort I needed to write some automated tests to make sure everything was working. In addition to working with the WSE 2.0 clients our customers have, I also wanted to see what was needed to make the services consumable by WCF clients. After finding this article on WSE 2.0 Interoperability on http://wcf.netfx3.com, it was pretty easy.

The main problem I was having was issues with the username token. In WCF some basic concepts were changed, such the removal of password encryption (instead recurring the transport, https for example to handle encryption), and replay detection.  

Here is the config section from the WSE 2.0 server piece (the diagnostic piece is optional)

<microsoft.web.services2>
   <security>
      <securityTokenManager xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" qname="wsse:UsernameToken">
         <replayDetection enabled="false"/>
      </securityTokenManager>
   </security>
   <diagnostics>
      <trace enabled="true" input="logs\InputTrace.webinfo" output="logs\OutputTrace.webinfo" />
   </diagnostics>
</microsoft.web.services2>

Here is a sample configuration section for the WCF Client:

<system.serviceModel>
        <bindings>
            <basicHttpBinding>
                <binding name="InventorySoap" closeTimeout="00:01:00" openTimeout="00:01:00"
                    receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false"
                    bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
                    maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
                    messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
                    useDefaultWebProxy="true">
                    <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                        maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                    <security mode="TransportWithMessageCredential">
                        <message clientCredentialType="UserName" algorithmSuite="Default" />
                    </security>
                </binding>
            </basicHttpBinding>
        </bindings>
        <client>
            <endpoint address="https://Server/Directory/Service.asmx"
                binding="basicHttpBinding" bindingConfiguration="InventorySoap"
                contract="MonitoringServices.Inventory.Wcf.InventorySoap"
                name="InventorySoap" />
        </client>
    </system.serviceModel>

Most of the client configuration was created for me when I added a service reference to my project. The key part is the mode=TransportWithMessageCredential and clientCredntialType = “UserName”.

We have another project underway were we want to rewrite the WSE 2.0 services with WCF while maintaining full compatibility with deployed WSE 2.0 clients. The netfx3 article covers this scenario as well, and it seems like we will be able to accomplish our task. Look for a future post on that endeavor.

Wednesday, July 09, 2008 5:30:23 PM (GMT Daylight Time, UTC+01:00)  #    Comments [0] -
Programming
# Monday, July 07, 2008

Today I tried to use the web recorder in Visual Studio to create some new web tests, but the recorder tool bar would not show in IE. A quick search found Diagnosing and fixing Web Test recorder bar issues, by Michael Taute which had several troubleshooting tips.

I ended up changing my home page which is about:blank (and loads when web recorder is launched) to belong to the local intranet zone, as this is where my test site is. That didn’t fix the problem initially, so I deleted the following two registry keys using the 32 bit registry editor (C:\Windows\SysWOW64\regedit.exe):

  • HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Discardable\PostSetup\Component Categories\{00021493-0000-0000-C000-000000000046}
  • HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Discardable\PostSetup\Component Categories\{00021494-0000-0000-C000-000000000046}

You need to make sure all instances of IE are closed before deleting the registry keys. Once I did this, my web recorder was up and running. I’ve left about:blank in the local intranet zone for now.

Monday, July 07, 2008 9:24:10 PM (GMT Daylight Time, UTC+01:00)  #    Comments [0] -
Programming
# Friday, July 04, 2008

Once again I need to generate some self signed certs for local development. Installing certificate services in Windows is a bit of an overkill for what I need, however, it would be nice to have a root CA to work with.

After some Googling, I found a site, http://ssl4net.com/ which allows you to create a self signed root CA, and then additional certs signed by the CA you created. It is extremely easy to use and once I got the certs I was able to install them without issue.

My only concern is that the certs do not appear to be encrypted on their server, nor do they use SSL (seems ironic). However, since I will only be using this for internal use, I have no problems with this. I would be a little cautious if I was going to use to verify my identity to other people.

It looks like they might be using open-ssl as the cert creation mechanism, so maybe it’s worth the effort to setting up a VM running linux to generate my own certs in house, but that’s for another day.

Friday, July 04, 2008 5:25:36 AM (GMT Daylight Time, UTC+01:00)  #    Comments [0] -
Programming | Tools
# Monday, June 23, 2008

This one took me a little longer then I figured. Maybe I’m just trying to do stuff the wrong way, but I don’t know, I feel like my use case is correct.

What am I talking about anyway? I am talking about creating a set of web tests in Visual Studio Test Edition (well Team Suite) that I can actually use in a real world situation (i.e. Have tests that work on a dev, staging and production server). The problem is/was, hard coded URLs for my dev server, which ultimately would have to be changed to point at staging and production.

Before proceeding, let me spell out what I’m trying to do (use case):

  • Use the VS GUI to create and most likely run my tests
  • Single place to store the web server, and other settings that I can use for all my tests

At first, I thought this was going to be a very easy change, as there is a “Parameterize Web Servers” option when you right click on the root node of your web test. This creates a context variable, which I thought was cool, until I realized it was on a test by test basis, not project. I guess I was looking for a project wide context parameters file, but couldn’t find one.

I did some searching and supposedly you can set an environmental (yes, from a command prompt) variable named Test.<ContextParameter>, however I was unable to get this to work. I think this might only work when invoking mstest from the command line which makes some sense, but kind of throws a wrench in the works. While this would be perfectly acceptable for a un-attended build server, what if I needed to point to a new dev server in the GUI?

I then moved to a XML data source with a single “line” of data":

   1: <?xml version="1.0" encoding="utf-8" ?>
   2: <Config>
   3:  <UrlRoot>http://dapltp101.dmz.pri</UrlRoot>
   4:  <LoginUserName>asalvo</LoginUserName>
   5:  <LoginPassword>123456</LoginPassword>
   6: </Config>

 

This worked pretty good, except that when selecting UrlRoot from the drop down list of available options, it replaced the entire URL, and not just the URLRoot. I do like how they made the property grid “strong typed” in that it gives you the fields you defined for your data source, but I didn’t want to replace my whole URL. Also, I could not edit the value after selecting my XML data source value.

Looking at the format of ContextProperties in values, as well as how the data source was referenced, I decided to try typing what I wanted in myself. I went to the URL value and replaced the URL root with the name my XML data element, and this worked.

For example, given:

Type this in the value field for your URL in the Request object on the test: {{ConfigXml.Config.UrlRoot}}/Location1

Like I said, that took me a little while longer then I would have thought. I should have went with my gut and tried that format soon after getting the regular XML data source to work.

I do have one last issue (well the fist of many I am sure), and that is, I have two URL’s when I really should only have one. When I hit the root of my website, I am redirected to a https:// URL, and that is treated differently. I’d like to capture the redirected URL and use that so I don’t have to maintain two values in my configuration file, but I’m just gonna roll with it for now.

Monday, June 23, 2008 10:14:44 PM (GMT Daylight Time, UTC+01:00)  #    Comments [0] -
Programming
# Thursday, June 19, 2008

Today I was working on installing a WCF application on Windows Server 2008, hosted by IIS 7. This was my first attempt at running WCF on IIS 7/Server 2008, and the first time WCF was used on this particular box. Needless to say, things didn’t work as expected.

Since this is a test box, I didn’t have a public cert for use with SSL, but IIS 7 adds a very nice Self Signing Cert feature, which is accessible in the IIS Manager under the root server node (look for server certificates under IIS). Unfortunately, the self signed cert uses the computers fully qualified host name, and you are not given an option to fix this. Looking around, it looks like the self signing cert tool that shipped with the IIS 6 resource kit allowed you to specify the domain name. Anyway, this is a minor inconvenience, and easily fixed by using the windows hosts file to redirect. You need to remember to export the cert from the IIS management tool, and import it to your trusted root certs on any client computer to avoid getting warnings in IE, and errors in your WCF client applications.

However, certs were not the reason for this post, the following error was:

Error the client and server are no longer in sync for their wcf service settings. System.ServiceModel.ProtocolException: The remote server returned an unexpected response: (405) Method Not Allowed. ---> System.Net.WebException: The remote server returned an error: (405) Method Not Allowed. at System.Net.HttpWebRequest.GetResponse() at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout) --- End of inner exception stack trace --- Server stack trace: at System.ServiceModel.Channels.HttpChannelUtilities.ValidateRequestReplyResponse(HttpWebRequest request, HttpWebResponse response, HttpChannelFactory factory, WebException responseException) at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout) at System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout) at System.ServiceModel.Channels.SecurityChannelFactory`1.SecurityRequestChannel.Request(Message message, TimeSpan timeout) at System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message message, TimeSpan timeout) at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout) at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs) at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation) at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message) Exception rethrown at [0]: at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) at …

Looking back at this error, I think I may have missed a key clue. The phrase “The remote server returned an unexpected response” should have clued me in that something wasn’t setup right. I usually see this type of error when IIS tries to display an error message in HTML, thinking that it’s a browser request. The WCF client application isn’t expecting HTML, so it throws an error.

It’s been awhile since I worked with WCF, and I forgot basic trouble shooting 101 for a couple of minutes, and finally remembered to just type in the URL to the .svc file on the server. I was greeted with an IIS 7 error page that listed some pretty good trouble shooting steps. The first one said to check the server handler mappings, which I did, and noticed there were not mappings for .svc. I found a blog post on wcf and silverlight, which explained how to enable WCF on IIS 7.

Now I had installed WCF (.net 3.0) via the features section of server manger in Server 2008, but I guess that doesn’t actually enable it to work with IIS 7. Maybe I didn’t install something in the correct order. Fair enough, and the fix is simple. From a command prompt (I ran mine with admin privileges under UAC), execute ServiceModelreg -i in c:\Windows\Microsoft.NET\Framework\v3.0\Windows Communication Foundation. Once this was done, I went back to my handler mappings and saw entries for .svc. 

I’d like to note that the error messages returned by IIS 7 in the browser window (when browsing from the web server itself), gives allot better error and diagnostics information for trouble shooting.

Thursday, June 19, 2008 10:16:52 PM (GMT Daylight Time, UTC+01:00)  #    Comments [0] -
Programming

So I find my self downloading disc 1 and disc 2 of VB 6 enterprise edition from MSDN subscriptions. I also downloaded the VB6 runtime files and SP6 for VB6.

You may be wondering why I am doing this. I wrote, and sold a copy of an application in a former life (or so it seems looking back to the year 2000), and I need to help my “client” get the app up and running on a new PC. However, I have to make a few tweaks in the VB6 code. I hope I still have all of the dependencies still.

This might actually motivate me to rewrite the app in .Net, something I have been wanting to do since .Net came out, now almost 7 years ago I think.

Thursday, June 19, 2008 4:21:57 AM (GMT Daylight Time, UTC+01:00)  #    Comments [0] -
Programming
# Friday, February 29, 2008

CLSA 3.5 is getting closer to release, with a beta announced this past weekend. CSLA 3.5 will be for .Net 3.5 and Visual Studio 2008 only. There is a 3.04 maintenance release which still targets .Net 2.0 that is coming out soon.

Announced earlier today, is a new way to write properties in CSLA, which Rocky refers to as property code reduction. Having worked with CSLA since version 1.0, I see this mainly as a welcome relief. My hesitation is in the fact that Rocky identifies a performance hit when using the fully reduced property declaration code. Adding an additional line which declares the backing variable (member variable, field, etc) alleviates this somewhat. Another way in which code is reduced is in the addition of child property management by CSLA. In the past you needed to override IsValid and IsDirty, and now CSLA handles this for you.

I love less code, truly I do, but I have attempted to implement stuff in the past with the good intention of less code, only to create something that didn't work out so well. Usually this involved an over use of reflection, where code generation would have worked just as well. I'm certainly not trying to compare my code writing skill to Rocky's, but I wonder if this is a case of programmers getting lazy? Well, I use code generation, so I guess that could be considered lazy as well. I guess the best thing to take away from this is, make sure you evaluate and inform your users (which Rocky has) of changes that save you, the programmer time. In the end the customer doesn't care if it took you 5 lines or 10 lines to implement a property, they just want their application to work.

Friday, February 29, 2008 4:58:21 AM (GMT Standard Time, UTC+00:00)  #    Comments [0] -
Programming
# Monday, February 25, 2008

ScottGu posted over the weekend about Silverlight 2, and even though I will be away from the web scene for awhile while working on my current project, I am still excited. There are links to 8 Silverlight 2 tutorials.  Key features include:

  • WPF UI Framework: This is a compatible subset of the WinForms WPF framework. You should be able to re-use controls written in Silverlight 2.0 in your WPF projects. Some WPF controls may not be compatible, and hopefully control creators will try to target both frameworks.
  • Rich Controls: TextBox, CheckBox, RadioButton, StackPanel, Grid, Panel, Slider, ScrollViewer, Calendar, DatePicker, DataGrid, ListBox were listed in Scott's post.
  • Rich Networking Support: Out of the box support for REST, WS*/SOAP, PX, RSS and HTTP. You can access resources on the web, and there is also built in support for sockets.
  • Rich Base Class Library: A compatible subset of the base class library including collections, IO, generics, threading, globalization, XML as well as LINQ and LINQ to XML.

Now the question is, what ever happened with Silverlight on the Compact Framework? If you remember from Mix 07, during the MLB demo, the presenter showed off a "Silverlight" application running on a Smart Phone (see this blog post for some details). Is it any coincidence that this Silverlight 2 announcement happens only weeks before Mix 08 and painfully leaves out any compact framework details? Scott uses the phrase compatible subset in two places when describing the features of Silverlight 2.0. Compatible Subset is an interesting choice of words, as you could describe the Compact Framework in that way as well. Should I really be getting this excited in thinking that Silverlight 2 will be released for the Compact Framework when we having even seen a 1.x build that runs on it?

Yes. Maybe I'll be disappointed, but I will be keeping a very, very close eye on the Mix 08 conference. Larry has a great post up entitled 5 things to do if you are not going to MIX. If you are stuck in the middle of a frozen wasteland like Larry and I (well maybe not wasteland, but compared to Vegas, the upper Midwest leaves something to be desired right now), or can't attend MIX for any reason, I suggest you read up on how to make the most of MIX as a "virtual" attendee. So set your outlook calendar to out of office for Mach 5-7th.

Monday, February 25, 2008 1:25:22 AM (GMT Standard Time, UTC+00:00)  #    Comments [0] -
Programming
# Wednesday, February 13, 2008

Three items were the focus of my attention today. Well, rather 2, and the 3rd I just saw over on daily tech and it got me very excited.

MSF for CMMI

I have been reviewing the process guidance for MSF for CMMI version 4.2 which ships with TFS 2008. I plan on using this process as the foundation on my next software development project. While out of the box it is a bit of an overkill for my team, project and company, I prefer to start with more (process) and remove what I don't need. I also feel that CMMI is a great compromise between management, who is used too, and wants a more traditional software development approach, and the developers, such as my self who are advocating a more agile process.

The great thing about MSF for CMMI is that it is written around agile concepts, yet still has processes in place for oversight. The process guidance, is written in HTML, making it very easy to edit and customize it after the project is created to meet your needs. There is a way to edit the template so that it generates the new project to meet your needs, but I figure this way is easier for the first go around.

My plan is to make changes to the HTML as needed, and then create a new template. In addition to tracking my changes, you can use a tool like WinMerge to compare your modified document library with a default one. You can access a document library via windows explorer by going to the document library and choosing open in explorer from the actions menu. This creates a UNC path in the form of \\SharepointServer\Sites\SiteName\Process Guidance, which you can supply to WinMerge.

I have spent some time going over the default tasks that are created with a new CMMI based project to see what workstreams and activities they relate to, and I think I have a pretty good handle on the first two tracks. I plan on documenting this in a future post.

Requirements

Oil and Water, Superman and Kryponite, Me and Requirements. I am having some difficulties in creating a formal software requirements specification, using this book as a guide. It's not the books fault (although I wish it hand an end to end case study of a project), but rather a differing of opinion on some of the definitions (which that end to end case study might help with).

  • Where is the line between Use Cases and Functional Requirements? Use cases look a lot like test plans to some people, and have a tendency to add test plan like information to them, which I feel is incorrect.
  • Where is the line between systems and users in the use cases?
  • How much detail is the right amount of detail?

Similar to my quest to gain a better understanding in the use of TFS and the MSF for CMMI, I'm going to have to put some time into researching (primarily looking for examples) software requirements. In addition to the book, which we now have 6 copies of at work, I found this website with some additional templates, as well as fairly detailed article on writing requirements from the perspective of a technical writer. There appear to be some good articles over at wikipedia as well, such as Requirements Analysis and Use Cases, and Use Case Diagrams. Someone today asked the question about how do all the use cases get related, and I believe the answer is the use case diagram (at least one use for a use case diagram), as illustrated in the example on Wikipedia.

I hope to be able to report back with some answers to my questions sometime in the future.

NVidia Application Processor

Daily Tech had an article on the NVidia APX 2500 application processor which is designed to add hi-def capabilities to mobile devices. The article states that NVidia has been working with Microsoft, so once can assume (as does the author of the article), that this is destined for a Windows Mobile application.

I've really been giving my HTC Mogul a work out and have always wanted a all in one device (video, mp3, phone, PDA, etc), so I am very excited about this. Since I have a bias against Apple, I am not a fan of the iPhone, although I can appreciate and respect what it is. This gives me some hope that my next Windows Mobile phone will be a force to be rekon with.

In addition to smart phones, I can also see this making it's way to other embedded systems, especially something like a mall kiosk. This brings me to the second reason that I am excited, and that is, my current software project is all about embedded systems running Windows CE. I have some future customer requirements that could take advantage of the functionality provided by this chip.

Wednesday, February 13, 2008 5:14:14 AM (GMT Standard Time, UTC+00:00)  #    Comments [0] -
Programming | Review For Future Projects
# Saturday, February 09, 2008

I am adding my name to the list of developers who have not heard about the InternalVisibleTo attribute. I came across this while checking out Derik Whittaker's blog in response to the email I got saying that Derik will be presenting at this month's Milwaukee area .Net Users Group.

The InternalVisibleToAttribute was added in .Net 2.0 and most people seem to be using it in order expose internal methods to external unit test classes. However, there is nothing to prevent you from using it in non-testing situations., although I have not seen a good reason other then unit testing to use it.

The MSDN documentation talks about the special case of applying the attribute to a strong named friend assembly. This is also a C# only attribute.

Saturday, February 09, 2008 7:33:18 PM (GMT Standard Time, UTC+00:00)  #    Comments [0] -
Programming | Tools
# Friday, February 08, 2008

Scott Hanselman today announced the Asp.Net Wiki (Beta).

"The idea is that folks spend a lot of time trolling the blogs, googling live-searching for answers to common "How To" questions. There's piles of fantastic community-created and MSFT-created content out there, but if it's not found by a search engine and the right combination of keywords, it's often lost."

I think it's a great idea and I hope to see other product groups at Microsoft follow suit. Since it's linked off http://www.asp.net, and a Microsoft entity, I see it quickly becoming the one stop shop for Asp.Net information.

If you jump on and contribute to the wiki right now, you could be a top contributor, at least for a couple of days.

Friday, February 08, 2008 11:34:45 PM (GMT Standard Time, UTC+00:00)  #    Comments [0] -
Technology | Programming | Review For Future Projects
# Tuesday, January 29, 2008

ScottGu's latest blog post talks about the VS 2008 web deployment project and the MS Web Deployment Team blog, which deals with a web deployment tool (not to be confused with the VS 2008 project).

I had to do a little digging, but found this white paper on MSDN which explains the web deployment project for 2005. From the abstract:

Visual Studio 2005 provides deployment support through its Copy Web Site and Publish Web Site features. While these are ideal for many scenarios, there are other, more advanced scenarios where developers need the following capabilities:

  • More control over assembly naming and output.
  • Custom pre-processing and post-processing for the build.
  • The ability to exclude, add, and transform files and directories during builds.
  • The ability to modify the Web.config file to change database connection strings, application settings, or the URLs for Web references, depending on the build configuration. (For example, it might be necessary to use different values for development, test, staging, and release settings).

this white paper describes a solution to these advanced scenarios and introduces a new feature called Web Deployment Projects for Visual Studio 2005.

The web deployment tool on the other hand, is a stand alone tool (currently just a command line utility called msdeply.exe), "that provides support for deploying, synchronizing and migrating IIS 6.0 and 7.0."

It supports moving configuration, content, SSL certificates and other types of data associated with a web server. You can choose to sync a single site or the entire web server. Because we know that one tool can never ‘automagically’ guess what your application relies on, we’ve tried to be pretty flexible and powerful – you can customize exactly what you want to sync using a manifest file. You can also skip sites or other objects, or you can perform regular expression replacements during a sync (like changing the home directory on the destination machine).

 

These two new tools will help make deployment a lot easier and enable a more agile environment. Unfortunately my project assignment at work has changed, so I won't be getting direct exposure to these.

Tuesday, January 29, 2008 10:57:29 PM (GMT Standard Time, UTC+00:00)  #    Comments [0] -
Programming | Tools
# Saturday, January 26, 2008

Wouldn't you know, by TFS warehouse is not updating. It seems like I have had this problem before, but today, it was a new error.

Today, I added 2 test projects to TFS, one for the MSF Agile (4.2) and one for MSF CMMI (4.2) to reference while I read Software Engineering with Microsoft Visual Studio Team System (thanks Larry). I'm not even through chapter one and I am hooked on this book. Chapter 1 was talking about the Reaming Work report, and I wanted to view it for the 2 test sites.

I was able to view the report for the MSF Agile site, but not the CMMI site. A quick look at the reports via the Reporting Services web management UI, and I had a pretty good guess that the warehouse was not updating because there were no iterations or areas listed for those report parameters.

I went checked out the TfsWarehouse.dbo._WarehouseConfig table, and saw that, yes, the warehouse stopped updating a couple of hours ago. My attempts to manually run the update using the web services interface via IE didn't seem to work. Remembering some of my previous troubleshooting, I went to the event log and found several errors, starting around the time that I created the CMMI project.

Event Type:    Error
Event Source:    TFS Warehouse
Event Category:    None
Event ID:    3000
Date:        1/25/2008
Time:        6:20:57 PM
User:        N/A
Computer:    [TFSServer]
Description:
TF53010: The following error has occurred in a Team Foundation component or extension:
Date (UTC): 1/26/2008 12:20:57 AM
Machine: DATFSP100
Application Domain: /LM/W3SVC/1977639788/Root/Warehouse-4-128456993088380000
Assembly: Microsoft.TeamFoundation.Warehouse, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a; v2.0.50727
Process Details:
  Process Name: w3wp
  Process Id: 8512
  Thread Id: 9920
  Account name: [ServiceAccount]

Detailed Message: The pending configuration changes were not successfully added to the cube because of the following error: System.Security.Principal.IdentityNotMappedException: Some or all identity references could not be translated.
   at System.Security.Principal.NTAccount.Translate(IdentityReferenceCollection sourceAccounts, Type targetType, Boolean forceSuccess)
   at System.Security.Principal.NTAccount.Translate(Type targetType)
   at Microsoft.TeamFoundation.Warehouse.OlapCreator.AddAccountToRole(Role role, String accountName, Boolean needToUpdate)
   at Microsoft.TeamFoundation.Warehouse.OlapCreator.SetupAnalysisDatabase(Server server, String analysisDBName, String accessUser, String[] dataReaderAccounts)
   at Microsoft.TeamFoundation.Warehouse.OlapCreator.CreateOlap(WarehouseConfig whConf, String accessUser, String[] dataReaderAccounts, Boolean dropDB, Boolean processCube)
   at Microsoft.TeamFoundation.Warehouse.AdapterScheduler.EnsureCubeIsUpToDate()

For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp.

So started my Google Search. I came across a post on the MSDN forums which had some code to check to see if account translation is working on the network, and it appears to be (I got a SID value back for both my tfs service and tfs reports account)

 

   1: using System;
   2: using System.IO;
   3: using System.Text;
   4: using System.Xml;
   5: using System.Xml.Serialization;
   6: using System.Threading;
   7: using System.Security.Principal;
   8:  
   9:  
  10: namespace CheckAccountForTfs
  11: {
  12:  public class Program
  13:  {
  14:   public static void Main(string[] args)
  15:   {
  16:    try
  17:    {
  18:     string accountName = args[0];
  19:     Console.WriteLine(new NTAccount(accountName).Translate(typeof(SecurityIdentifier)).Value);
  20:    }
  21:    catch (Exception e)
  22:    {
  23:     Console.WriteLine(e);
  24:    }
  25:   }
  26:  }
  27: }

 

Continuing my Google search, I found something embarrassing, I had the same exception for TFS listed on a previous post, on my very own blog. My solution last time was to run (Make sure you replace Server with your TFS server name, as well as use FQDN for the service and reports account).

setupwarehouse -o -s Server -d TfsWarehouse -c Warehouseschema.xml -a Domain\TfsService -ra Domain\TfsReports -v -mturl http://Server:8080 -rebuild

I did not remove the TFSWarehouse from Analysis Server before running this command. Also, the setupwarehouse command is in %Program Files%\Microsoft Visual Studio 2008 Team Foundation Server\Tools.

Eureka, manually invoking the warehouse job from the web service via IE actually starting processing, and with no errors in the Event Log. Looks like I might have to create a batch script to keep on the TFS server in case this happens again. I also need to search my own blog a little more carefully next time.

While I was trying to get the Remaining Work report to display initially, I somehow managed to mess up the parameter definition for Iteration and Area. I fixed this by saving the report (Go to the report's properties and click edit), along with another report with the at least those 2 parameters. Once saved as a text file, I copied the ReportParam element for both parameters from the good report to the bad report, then uploaded the fixed report back to reporting services. Problem solved.

Saturday, January 26, 2008 1:24:49 AM (GMT Standard Time, UTC+00:00)  #    Comments [0] -
Programming
# Sunday, January 06, 2008

I jumped back into some compact framework development this weekend, and it was the first time since I had installed VS 2008 RTM. I went to connect to one of my CE devices via Visual Studio 2005, and was unable to connect. I also tried the remote performance monitor power toy.

I finally went to check on what version of the CoreCon files I had installed, and noticed right away that there date modified was 11/7/2007. I coped these latest versions over to my CE device, and was able to connect again.

Sunday, January 06, 2008 8:23:01 PM (GMT Standard Time, UTC+00:00)  #    Comments [0] -
Programming
# Tuesday, January 01, 2008

Today's task, a somewhat detailed code analysis of one of our Windows CE projects. In addition to reviewing from a lead architect point of view (design and implementation), I also needed to take a look at general coding practices. For this I turned to the Code Analysis tool in Visual Studio, and NDepend.

I had remembered reading about NDepend on Scott's blog, and went back there to re-read his post. I highly recommend it, as it's a great quick start and introduction to NDepend. Scott also has a pod cast available, and the the NDepend web site has links to several video tutorials showing how to use it.

One thing I found lacking, was there were no support forums on the NDepend web site. I had a couple of issues getting my Compact Framework application to be property recognized by NDepend. The main issue, was NDepend was trying to use the full framework version of System.Data instead of the Compact Framework version. I noticed that there was an option when selecting assemblies to resolved missing ones (well, some it let me, others it didn't), and figured the resolved location was stored in the project configuration file. So I opened it up in note pad and sure enough, there were all the directory paths.

I removed all of the paths that were added by default, and added my own paths to my project. I also added paths to the SQL CE 3.5 directory, as well as the location of the compact framework dlls (See update below). Unfortunately I still had issues with NDpend detecting multiple dlls (System.Data and System.Windows.Forms) with the same name. I decided to remove the path statements for everything except my project. This resulted in warning about not being able to resolve dependencies, but the analysis completed.

There is allot of information presented, almost to the point of information overload. I highly recommend printing out and reviewing the NDepend placemat as a quick reference. I concentrated primarily on the metrics, which use NDepend's Code Query Language to identify possible problems. I found myself viewing all of the queries to figure out what they were looking at. The documentation of the queries is excellent, and each one includes a link to the NDepend web site which defines the metric is pretty good detail.

I am quite impressed with the amount of information that NDepend gave me about my project. There were/are a few usability issues, but they can be overcome. I hope that I can continue to find time to make use of this excellent tool. I spent some time watching the video tutorials, and they were very helpful. I've been trying to get a side project started at home to try out all the tools, techniques, patterns, etc that I don't have time for at work, and this will definitely find it's way onto my to do list. I think it will be very interesting to use this from the beginning and see how the different metrics change as I build out my project.

Update:

  • 1/2/2008 - After watching the videos, I discovered that when you are setting up your project in VisualNDepend, there is a screen that lest you add/remove directories in the application. This is much easier then editing the project file manually like I was initially doing.

Other Links:

Tuesday, January 01, 2008 6:01:14 PM (GMT Standard Time, UTC+00:00)  #    Comments [0] -
Programming | Review For Future Projects | Tools
# Thursday, December 27, 2007

Inversion of Control (IoC) and Dependency Injection (DI) are two practices, patterns, techniques, that I have been very interested to take a look at in greater detail. I came across a tutorial (the tutorial) which goes over IoC and DI using the Castle Windsor Container (and Micro Container), part of the Castle Project. Two other similar implementations presented in the tutorial are Spring.NET and StructureMap, as well as Microsoft's ObjectBuidler DI framework. The ObjectBuilder framework is used in the Enterprise Library, and Composite UI Application Block (CAB), which is good enough for me to steer clear of it and try out the Windsor Container instead.

I have never really been impressed with the Enterprise Library, and the CAB seemed overly cumbersome. Granted, it has been over a year since I last looked at the CAB and EntLib in any great detail, so maybe things have gotten better. I know allot of people live and breath EntLib, but I'm trying to experience some other thoughts outside the typical Microsoft sphere, such as Alt.Net. Microsoft is starting to catch onto the Alt.Net movement especially with the introduction of the Asp.Net MVC framework, a topic for a future post.

Part I

So what exactly is inversion of control? It helps if you consider how an application is traditionally written and define what "control" means. "Control" can be thought of as adding references to various assemblies, declaring instances of specific specific classes by calling the appropriate constructor and passing in parameters. The tutorial refers to this as a "canonical programming process". Now if we take the opposite, or invert the control, then our application does not reference specifically assemblies and does not instantiate concrete classes. Instead your application makes use of interfaces or abstract classes and relies on a framework to instantiate the classes as needed. This is commonly referred to as the Hollywood Principle, and what post on design patterns would be complete without a link to Martin Fowler.

The tutorial talks about another design principle, which is the separation of concerns (SoC). Separation of Concerns states that a component should do only one task, and do it very well. In the tutorial's example application, the functionality to download HTML data should be separated from the logic to parse the HTML itself. By separating the two pieces and applying IoC, if a new, faster algorithm for parsing was written, it could be swapped out with the original with no modification to the application. Under a traditional model, you would have to edit the single class, change the parsing routine, and then recompile the class and application. Then what happens when management says, "well the first algorithm was slower, but it was written by the boss's nephew....".

The tutorial defines a component as: "... a small unit of reusable code. It should implement and expose just one service, and do it well. In practical terms, a component is a class that implements a service (interface). The interface is the contract of the service, which creates an abstraction layer so you can replace the service implementation without effort."

The power of an Inversion of Control framework does not become apparent until you have components with dependencies on other components, each with their own dependency. The Castle project refers to it's IoC as a container which is offered in two versions. The first exposes the core IoC functionality and is called the MicroKernel. In the simplest of terms, you add components by specifying a key (ID), type and assembly to load. You then ask the container for an instance, which it returns, loading all required dependencies. The 2nd version of the container, Windsor, extends the Micro Kernel and is used most often. It adds supports for generics to reduce casting and external configuration (app.config and web.config) options to name a few.

Part II:

  • Constructor, Setter, and Component Injection
    • Constructor arguments, and [property] setter arguments can be specified in the configuration file.
    • If more then one component of a service is specified, you can specify which component to use, using the ${ComponentName} syntax in the configuration file.
    • The name of the XML Elements in the configuration file should match a constructor parameter and property name.
  • Collections in the configuration file
    • Arrays, Dictionaries and Lists can be specified in the configuration file.
    • This allows you to pass in a collection of components and allow the parent container to decide which one to use.
    • Collections can be specified for constructor parameters and property setters.

Part III

  • Separation of configuration and data
    • The configuration file can get complex pretty fast, especially when you are specifying a large set of data for a collection.
    • Windsor allows you to work around this by moving the data to the top of the configuration file under a <properties /> section. Child elements can be referenced in the configuration section by using the #{ChildPropertyName}
    • The tutorial points out that the real power of this, lies in the fact that you can put the properties in a separate file.
  • Custom Converters
    • Windsor supports converting from strings (in the configuration file) to other types.
    • You need to implement AbstractTypeConvertor, and a new class inheriting from WindsorContainer to register your TypeConvertor
  • Decorator Pattern
    • The decorator pattern basically has you wrapping a component that implements IInterface, with another component that implements IInterface, taking the original component as a constructor parameter.
    • Once you have the new implementation, you can perform things like benchmarking around specific method calls.
    • Since everything is setup via the configuration file(s), there was no need to re-compile the main container.
  • Define and If
    • Windsor supports an IF/Else syntax in the configuration file
    • Windsor also supports using DEFINED variables, such as DEBUG. This is not the same as the compiler flags, you have to add your own DEFINE statements in the configuration file. this can be in either the main component configuration, or your properties configuration.

Party IV

  • Lifestyles
    • Windsor supports 4 object lifecycles
      • Singleton (Default) - Each call to Resolve returns the same instance
      • Transient - Each call to Resolve returns a new reference
      • Thread - Each thread gets a single instance
      • Pooled - Instances are retrieved from a pool. If there are no more available instances in the pool, a new one is created. All instances are created upon the container being instantiated. 
      • Custom
    • Specify the lifestyle using attributes (i.e. [Transient]), or via the configuration file
  • Facilities
    • From the official documentation (taken from the tutorial): Facilities augment the MicroKernel capabilities by integrating it with a different project or technology, or by implementing new semantics.
    • Built in facilities (Covered by the tutorial):
      • Factory - Allows you to use classes which implement an Interface but use the factory pattern
      • Startable - Components are "started" as soon as possible after the application is started, and stop when it's released. You can implement an IStartable interface, or, specify start and stop methods in the configuration file.
    • The logging facility is mentioned as one being worth while to investigate, but it's not covered.
  • Commission and Decommission
    • Implement the ICommission and IDecommission to specify code which should be run when the component is created and destroyed by the container. Depending on the lifestyle chosen, the actual time at which the decommission code is called varies, and without understanding this, you may get unexpected results.
  • IDisposable
    • If you implement IDispoable, the container will automatically call the dispose method when the component is no longer needed. 

Questions:

  • Is there a utility that can analyze an assembly, namespace and/or class and generate a skeleton configuration file?
    • The StructureMap lists some tools that make configuration file management easier.
  • Other ways to store configuration data. It would be great if you could load configuration, or the properties from a SQL data store.
    • StructureMap supports full programmatic configuration.

Conclusion:

I can't wait to try out the Micro Kernel and Windsor Container in a project. The flexibility is phenomenal, and the decorator pattern makes it extremely easy to extend functionality.  I only took a quick look at the StructureMap and Spring.Net, and they have some interesting features which need further investigation.

Thursday, December 27, 2007 4:10:24 AM (GMT Standard Time, UTC+00:00)  #    Comments [0] -
Programming
# Sunday, December 09, 2007

It seems as if there is someone at Microsoft, who's sole purpose in life is to figure out how I might want to use something (WCF), and then make sure I can't use it in the way I want to. Today's issue, programmatically configuring a WCF client application.

Background

I have created a central repository store in the form of a SQL database, that put simply, contains key/value pairs that I can query. All of my applications (or each machine.config) only need to specify a single database connection string to this configuration database.  All other configuration settings are retrieved from the database (and cached), making it easy to keep track of configuration, view all current configuration settings, and deploy the applications on new servers.

Expanding upon my simple definition, there is a second "key", which corresponds to what environment (production, staging, development) the application is deployed. So my single configuration database controls the configuration of all applications in all environments. For those settings which are the same across all environments, no deployment key is specified.

So far this has worked great, and I wanted to add configuration information about a WCF client service.

WCF

WCF needs two properties set, a binding, and an endpoint, and each of these 2 properties have sub properties which may or may not have values that need to be set. Out of the box, WCF is most easily configured using application or web configuration files. All of the tools support the configuration files and it's easy to see what's going on (well sort of).

I basically wanted to take the XML sections that define the binding and endpoint, and place it into my configuration database. For some reason, I got it in my head that this would be really easy to do, but found out that it's not. Searching thru Google yielded no direct solution. While you can programmatically set the Binding and Endpoint properties of a proxy class client object, I would either have to have 1 setting per property (and sub property) in my configuration database, or come up with an XML schema, parse the schema and set the values. This was the path I was pursing, but instead of making my own schema, I just used the XML configuration schema provided out of the box, in hopes that one day I could just pass those sections to binding or endpoint objects and have it parse for me.

After creating classes to parse a single binding (WsHttpBinding), I decided there must be a better way.  The code to parse the configuration files must exist somewhere in System.ServiceModel, so I decided to go spelunking using reflector to see what was going on, and determine if I could hack something together.

Implementation

Overview

After spending a couple of hours in reflector, I realized the main roadblock was the use of the System.Configuration namespace to handle the configuration data for System.ServiceModel. System.Configuration only supports the file system, and provides no extension methods at this time (something I'd like to see from Microsoft in the future).

This left me with one option, which was to create temporary XML file with my configuration data from my database, and then read that configuration file using the proper classes/methods in System.Configuration. It took me awhile to accept this option, as writing a temporary file seemed messy, but then I realized, temporary files are a fact of life in .Net, programming, operating systems, etc.

Configuration Store

My configuration store was already defined as I mentioned previously. The 2 XML samples below are stored as separate entries in my configuration database. Below is the XML I stored for handling the bindings:

<bindings>
 <wsHttpBinding>
  <binding name="WSHttpBinding_ITwoWayAsyncVoid" closeTimeout="00:01:00"
          openTimeout="00:00:30" receiveTimeout="00:02:00" sendTimeout="00:00:15"
          bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
          maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text"
          textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false">
          <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
            maxBytesPerRead="4096" maxNameTableCharCount="16384" />
          <reliableSession ordered="true" inactivityTimeout="00:10:00"
            enabled="false" />
          <security mode="Message">
            <transport clientCredentialType="Windows" proxyCredentialType="None"
              realm="" />
            <message clientCredentialType="Windows" negotiateServiceCredential="true"
              algorithmSuite="Default" establishSecurityContext="true" />
          </security>
  </binding>
 </wsHttpBinding>
</bindings>
 

I am able to store multiple bindings, and binding configurations in a single entry in my configuration database (see below). In this example, I only have a single binding and binding configuration. I was originally planning to have 1 entry for each binding, but I don't think that will be necessary, if anything I will have a single entry for all necessary bindings per environment, and even that might be overkill.

This is the XML I stored for the end point:

<bindings>
 <wsHttpBinding>
  <binding name="WSHttpBinding_ITwoWayAsyncVoid" />
 </wsHttpBinding>
</bindings>
<client>
 <endpoint address="http://tersodemodev1/TsiCbsEsbReciever/WcfService_TersoSolutions_CBS_Fusion_BizTalk_InitialProcess.svc"
        binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_ITwoWayAsyncVoid"
        contract="TsiCbsEsbReceiver.WcfService_TersoSolutions_CBS_Fusion_BizTalk_InitialProcess"
        name="WSHttpBinding_ITwoWayAsyncVoid">
        <identity>
          <userPrincipalName value="TERSODEMODEV1\BizTalkWebServices" />
        </identity>
 </endpoint>
</client>
Notice the repeat of the <bindings> section. This was required if I wanted to use the the classes in System.ServiceModel for parsing the endpoint, I needed to define a skeleton for the bindings.
I separated the endpoints from the bindings, as that is what is going to change between environments the most for me. The endpoint specifies which server (test, production, staging), and identity (for single server test scenarios, the account will be local, for multi server production enviroments, the identity will be a domain account).
Code
I created 2 classes under a namespace called ConfigSystem. The first class, called ConfigMgr contains code that allows me to go from my configuration database to a System.Configuration.Configuration object by way of a temporary file. The second class called Wcf, contains code specific to my Wcf configuration implementation, and contains code inferred from reflector.
All of the code in ConfigMgr uses public classes and is pretty simple.
public static class ConfigMgr
 {
  #region MemberVars
  private const string configFileHeader = "<?xml version=\"1.0\"?><configuration>";
  private const string configFileFooter = "</configuration>";
  
  #endregion

  #region Methods - Public

  public static ConfigurationSection GetSection(string configKey,
   string xmlConfigFileHeaderExtra, string xmlConfigFileFooterExtra, string sectionName)
  {
   //Get an xml document from the configuration database to store as a tempory file.
   System.Xml.XmlDocument doc = PrepareXmlDocument(configKey, xmlConfigFileHeaderExtra, xmlConfigFileFooterExtra);

   //Now write out to the temp file.
   string path = System.IO.Path.GetTempFileName();
   using (System.Xml.XmlWriter writer = System.Xml.XmlWriter.Create(path))
   {
    doc.WriteTo(writer);
    writer.Close();
   }
   
   //Setup configuration file map so that we can use standard file based config file
   ExeConfigurationFileMap map = new ExeConfigurationFileMap();
   map.ExeConfigFilename = path;

   System.Configuration.Configuration config = ConfigurationManager.OpenMappedExeConfiguration(map, ConfigurationUserLevel.None);
   
   //Now return the specified section
   return config.GetSection(sectionName);
  }

  private static System.Xml.XmlDocument PrepareXmlDocument(string configKey, string xmlConfigFileHeaderExtra, string xmlConfigFileFooterExtra)
  {
   System.Text.StringBuilder sb = new System.Text.StringBuilder();
   
   //Append header
   sb.Append(configFileHeader);
   sb.Append(xmlConfigFileHeaderExtra);

   sb.Append(ConfigHandler.GetValue(configKey));

   //Append Footer
   sb.Append(xmlConfigFileFooterExtra);
   sb.Append(configFileFooter);

   System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
   doc.LoadXml(sb.ToString());
   return doc;
  }

  #endregion
 }
The code in the Wcf class uses some methods I copied via reflector, and because I don't know the legal ramifications of that, I am only providing an outline of what I did.
GetBinding:
  • Calls ConfigMgr.Get section and returns the <bindings> section. This is cast to a BindingsSection object.
  • Code taken from System.ServiceModel.Configuration creates a BindingCollectionElement which is the correct type associated with the binding stored in the XML config.
  • A new binding object is created using Activator.CreateInstance(BindingCollectionElement.BindingType)
  • Additional code taken from System.ServiceModel.Configuration loops thru BindingCollectionElement.ConfiguredBindings and initializes the binding object previously created. A check is made to make sure multiple bindings of the same type are not created.
  • Finally, the binding object is returned to the caller.

GetChannelEndpointElement: This class uses only public classes and methods so I am including it. EnpointElement contains the configuration data for an endpoint, including the URI, identity, binding, and  binding configuration. The binding and binding configuration data is actually passed to my GetBinding method to return the correct binding with the correct binding configuration.

public static ChannelEndpointElement GetChannelEndpointElement(string configKey)
  {
   ClientSection section = (ClientSection)ConfigMgr.GetSection(configKey, system_ServiceModelAsOpenXml, system_ServiceModelAsCloseXml, clientSection);

   if (section == null)
    throw new ArgumentException(string.Format("Client section returned from config db for key {0} was null", configKey));

   if (section.Endpoints.Count != 1)
    throw new ArgumentException(string.Format("There must be exactly 1 endpoint returned from the configuration. {0} endpoints were returned for key {1}", section.Endpoints.Count, configKey));

   return section.Endpoints[0];
   
  }
GetEndpointAddress: Another method I created which almost uses all public methods. It takes a ChannelEnpointElement and returns a EndpointAddress which can be assigned to a wcf proxy class.
public static EndpointAddress GetEndpointAddress(ChannelEndpointElement element)
  {
   //Create a new builder, as the endpoint address is an immutable class
   EndpointAddressBuilder builder = new EndpointAddressBuilder();

   builder.Identity = LoadIdentity(element.Identity);
   builder.Uri = element.Address;

   return builder.ToEndpointAddress();
  }
LoadIdentity: This final method was taken from System.ServiceModel.Description.Configloader. This method takes a IdentityElement (a property of ChannelEnpointElement) and returns a EndpointIdentity which is passed to the EndpointAddressBuilder in my GetEndpointAddress method. The method basically checks the the existence of certain properties, and if one exists, it returns the appropriate identity using public factory methods.
  • EndpointIdentity.CreateUpnIdentity
  • EndpointIdentity.CreateSpnIdentity
  • EndpointIdentity.CreateDnsIdentity
  • EndpointIdentity.CreateRsaIdentity
  • EndpointIdentity.CreateX509CertificateIdentity

There is a identity type of certificate reference which I was unable to add support for, because it referenced additional internal classes which I didn't want to duplicate at this time since I had no need for that identity type.

Issues

Since this is completely unsupported by Microsoft, and uses code that was never meant for external use, in a future version of the framework, something could break. I'm also not an legal expert when it comes with what someone can do with MSIL code discovered thru reflector, so for now, the actual code I wrote is not available publicly. Hopefully I provided enough information to allow someone to reproduce my steps and implement something on their own.

Another somewhat disappointing realization I came to, was that this might make it hard to support write operations to my configuration database. Currently the configuration database is managed thru scripts and direct editing. If write support to the config database became a requirement, I'd probably try to do the reverse and use the built in file save functionality in System.Configuration to save a temporary xml file, read it and then store it into my config database.

Conclusion

This was my first attempt at doing something like this, digging into framework code to see how it really works and trying to come up with a solution. I'm going to go forward using the code I wrote outlined in this post, as I have full read support for WCF XML configuration. The amount of code I had to write and test is significantly less then if I would have wanted to get the same amount of functionality (configuration support for all bindings and endpoint configurations).

Sunday, December 09, 2007 8:50:53 PM (GMT Standard Time, UTC+00:00)  #    Comments [0] -
Programming
# Tuesday, December 04, 2007

In a recent email from MSDN Flash, I first learned of the new Parallel Extensions to the .Net Framework 3.5. This is an out of band release that is currently available as a CTP on Microsoft Downloads.

The description in the MSDN Flash newsletter has me pretty excited about what this offers.

[Parallel Extensions] is a managed programming model for data parallelism, task parallelism, and coordination on parallel hardware unified by a common work scheduler.

...

Parallel Extensions provides library-based support for introducing concurrency into applications written in with any .NET language, including but not limited to C# and Visual Basic.

It is specifically designed to take advantage of multi-core processors (among other things), which is important due to the recent (last 2 years) shift in the industry from raw clock speed to multi-core.

The computational power of multi-core processors, new programming models and platforms, and advanced research in usability all promise to change the way people interact with computers.

While excited, I do have some reservations. Encapsulating the lower level knowledge needed to take advantage of multiple cores will speed up development, but it will reduce the number of programmers who know how that lower level stuff needs to be written. The concepts used to take advantage of multi-cores, should be very similar to those required to take advantage of multi-threading, which is more "widely available" on the compact framework (although I am seeing more and more embedded computers with Core 2 Duo's). If this framework is only available for the full framework, the pool of skilled workers available for the compact framework could diminish (even more so).

I actually have more of a need to take advantage of multi-threading, and parallel processing in compact framework applications. As far as asp.net applications, I would like to see if this is something that would be recommended for them. Long running processes that would take advantage of this new framework, are usually best left outside the asp.net application. Speaking of long running processes, that is the 3rd area I work in, and in a traditional environment, would love to take advantage of this. However, the applications I am writing are all running on VMWare ESX, and IT has it set so that each VM only has a single CPU, and puts the burden of scheduling the 8 physical cores on ESX itself.

This will probably end up being something I try to work into personal projects. Unfortunately, I do not have the time to play with the CTP at this moment, but it is something I defiantly want to look into in the future.

Additional Information:

Tuesday, December 04, 2007 4:12:27 PM (GMT Standard Time, UTC+00:00)  #    Comments [0] -
Programming | Review For Future Projects
# Saturday, December 01, 2007

Avoiding Development Disasters is the tile of an article I came across today and talks about how and why software projects fail. Here's what I got out of the article.

FBI Virtual Case File

The article opens up talking about the monumental failure that is/was the VCF and touches 6 factors which lead to the projects failure.

  • Lack of an Enterprise Architecture - Unfortunately the article doesn't go into what they did have, have not.
  • Poor management of developers, including a lack of management or micro-management
  • Unqualified persons were placed in critical roles
  • Constantly changing requirements
  • Scope Creep
  • Throwing more developers at the project in a last ditch effort to meet deadlines.

I am personally experiencing 3 of the listed items on a current development project, although it's far from a $100 million dollar system, I bet there are some striking similarities. I would imagine that every project at every company experiences 1 or more of the things in that list to some extent or another.

What is Success?

The VCF was eventually scrapped, but the author claims, that had it gone to production, it would have been deemed a success, even with all it's flaws. The author goes on to say that this is the general practice in the software industry (at least enterprise applications). As much as I like Microsoft, I think Vista is a shining example of this (although perhaps it is deemed less of a success inside of Microsoft).

I have to agree, and would be willing to say it's common in software projects in general, from small to large. How many times is a game released, and the day of, a patch is released? Even Epic Games, creators of the Unreal platform, and who coined the phrase "When it's done", still manage to release a product with known issues.

I'm not trying to criticize any one company or developer, other then myself, as I have created some less then magnificent code over my short life as a developer. I think part of the problem is that there are no points for creating good code. At the end of the day, "Well it works doesn't it?" pays the bills.

Why is it so hard to write code, almost 30-40 years since the first programs were written? We have better tools, faster computers, and years of other people's failures to learn from, and here we are, still producing less then our potential.

The Code to Ruin

The diagram "The Code to Ruin" presented in the article is so true, it's scary. You pretty much know what's going to happen before you start the project, but you still can't avoid it. That's depressing at best.

Maintainability

The article spends the last half, talking about the maintainability of code. Without code that is maintainable, while you launch may be a success, you next point release is probably going to be a failure. The article states that enterprise software should have a 15 year life span, that's longer then I have been coding.

I think ideas such as software as a service might help us reach that goal, and have more maintainable code overall. I'm not taking about providing software as a service, I mean, that the internal make up of your application is constructed from (loosely coupled) services. Breaking stuff down into more manageable pieces seems to be the way to go. We already do it with proper OOD design, we should also be applying it to the system in general. Of course there is a trade off, the most notable to me being one of performance, but that's what these faster computers are for ;)

All in all, it was a good article, and made me really think about software projects, both past and current that I am working on. I have to imagine that there are people out there that would be the perfect compliment to a talented programmer such as myself (well at least I think I'm talented). Or, does it mean, that I need to spend less time with technology and programming, and learn more skills like project management, documentation, business analysis, etc.? To specialize, or generalize, that is the question?

Saturday, December 01, 2007 1:29:49 AM (GMT Standard Time, UTC+00:00)  #    Comments [0] -
Programming
# Tuesday, November 27, 2007

Found some more information on TFS 2008 RTM from bharry's blog on MSDN. Most important to me and my team, is that the RTM media is not available for volume license customers until sometime in January. However, you could upgrade to the RTM Trial, and then add in your PID (Product ID) in January when it's finally available. The trial is good for 90 days, and bharry assures his readers that PID's for volume license customers will be available before then, and if not to contact him directly.

Upgrading to RTM sounds like something I will probably do around Christmas, as it's usually a slow week anyway. This would give me until the end of March to get my PID, which is probably close to when the beta we are currently running would be expiring anyway. Speaking of upgrading, it sounds like the process outlined by ScottGu which I talk about in my previous post, also apply to TFS.  There is a link script on bharry's post, which is supposed to help with the process. I will try to use the script for when I update my primary workstation, and will report back on how well it works.

Tuesday, November 27, 2007 8:38:48 PM (GMT Standard Time, UTC+00:00)  #    Comments [0] -
Programming
# Thursday, November 22, 2007

Note: While I didn't have any problems, I would recommend keeping the iso for Beta 2 around until you are confident you got everything removed. Sometimes software needs to get something from the original installer to uninstall.

In case you have been living under a rock this week, VS 2008 RTM was released. I don't expect to see much difference between Beta 2 and RTM, given how solid of a product Beta 2 was. ScottGu has a post on the recommended steps to uninstall Beta2 and install the RTM version. It sounds like you could install on the top of Beta 2, but I prefer to put forth the extra effort to get a "clean" install, or at least as clean as I can get without wiping my machine (is this another example of where moving to virtual platform would make sense?).

Of course the first step was to obtain VS 2008 Team Suite from MSDN, which was a bit of a challenge earlier in the week. I'm assuming everyone was trying to get their hands on it, and unless Microsoft is cheap when it comes to bandwidth (doubtful), it goes to show how much people wanted this as soon as it was released. ScottGu had a previous post about where to get all the bits (including the 3.5 redistributable), and I found this post which led me to the stand alone download for Team Explorer.

Next, I followed the recommended uninstall order. I'm glad that I don't install things I know I will never use, less things to uninstall. The names provided in Scott's post are word for word as they show up in Add/Remove programs, so feel free to sort by name. Even with detailed instructions, I still managed to screw up. .Net Framework 3.5 looks very similar to .Net Compact Framework 3.5, and I ended up uninstalling the full framework first. Not on the list, is Team Explorer, and Visual Studio itself. I opted to uninstall Team Explorer first, and the process froze on me.

A "quick" reboot seemed to fix the problem. I proceeded with uninstalling Team Explorer, and the two entries for Visual Studio. I also rebooted again as per Scott's recommendation, and then began the install process, starting with Team Suite, and then Team Explorer and a few more reboots and I was done.

Update:

I came across a script which is supposed to help with the uninstall of the Beta Bits.

Thursday, November 22, 2007 5:51:50 PM (GMT Standard Time, UTC+00:00)  #    Comments [0] -
Programming
# Monday, November 05, 2007

As a follow up to my last post, I wanted to post a quick note about a change in the location of AL.exe (assembly linker), in .Net 3.5.

I was attempting to use TFS Build to build a project that was 100% VS 2005 (basically the solution was still a VS 2005 solution), but I was getting an error stating that al.exe could not be found in C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727, and that I either needed to pass the path in to MSBuild, or, install the SDK. Not wanting to install an older SKD, I opted for the path option, but then I needed to determine the path. I figured a newer version of al.exe must be installed somewhere with .Net 3.5, and sure enough, it's under C:\Program Files\Microsoft SDKs\Windows\v6.0a\Bin.

I checked out the TFSBuild.rsp file and added the following line:

/p:ALToolPath="C:\Program Files\Microsoft SDKs\Windows\v6.0a\Bin"

Checked it back in, and it worked.  

Monday, November 05, 2007 3:58:30 PM (GMT Standard Time, UTC+00:00)  #    Comments [0] -
Programming
# Sunday, November 04, 2007

With our migration to VS 2008 (Beta 2) complete, the next task was to formally adopt an automate build process, and we chose Team Build as the software to drive that process. Previously I had setup CC.Net, as I had used it at a prior job so I was familiar with out. However, there was never a buy in from the whole team, so no one except me really cared when the build broke, or how to go about fixing it.

As part of our migration plan, we have gotten buy in from the entire team (IS) on an automated build process, so for at least a the development and testing level we will have an automated process. The next step after that, is using Team Build to actually automate the deployment to our staging and production environments, such that we can easily deploy small, and large changes in an efficient, consistent, and error free manor.

One of the downsides to development, at least for me, is the task of deploying a change to production. There is usually a lengthy change management process, a number of documented (and un documented) steps needed to do the actual deployment, and then a series of manual tests to run to make sure everything is still working. At a presentation I attended as part of the ARCReady series, the concept of a truly automated build and deployment process was presented, and that concept is what I hope to accomplish (eventually) on my current project.

The first step in achieving my utopia, is to start with a simple build that can be invoked at anytime. I actually have another developer working on setting up the builds for our main project. The project I'm using for this example, is for our smart devices.

To get started, open Visual Studio and select New Build Definition from the Build Menu. This opens up a dialog box with 6 tabs/sections listed on the right, and the tab details on the left. The General, Project File and Build Defaults require information in order to proceed. Workspace, Retention Policy and Trigger all have defaults chosen, but you can change them if so desired. When you are done configuring all of the tabs, click OK.

  • General:

Build definition name, an optional description, and a checkbox to enable or disable the build. I named the build "ProjectName - All", and entered a short description of what I hoped to accomplish with the build.

  • Workspaces:

You need to select a Source Control Folder, and a Local folder. The defaults are the root of the project in TFS, and a folder defined as $(SourceDir)

  • Project File:

Here you select the MSBuild file used to define the build. The default location is $/ProjectRoot/TeamBuildTypes/BuildDefinitionName. If there is no TFSBuild.proj file in the location, you will have the option to created one, which is what I did here.

Choosing to create a new TFSBuild file, bring up a new dialog that will allow you to select a solution in the workspace, 1+ configuration options (i.e. debug or release and target platform), and build options (unit tests, code analysis, etc). I happen to have a solution in this workspace, so I am using it, and chose to build both a debug and release version.

When you are finished with the TFSBuild options, click finsih to return to the Build Definition dialog

  • Retention Policy:

Here you describe how builds should be retained, and the values you choose is completely dependent on your individual needs. For now, I'm selecting "Keep Latest Only" for Failed, Stopped and Partially Succeeded, and "Keep 5 Latest" for Succeeded.

  •  Build Defaults:

You need to specify a default Build Agent (computer running Team Build), and a staging share. I was surprised to see that the Build agent we had already defined in another project, was not available in the drop down list. I recreated it by clicking the New button. I had to sepcifcy a Agent Name, computer name, and working directory (defaulted to $(Temp)\$BuildDefinitionPath)). If you don't want the source downloaded and built from C:\Documents and Settings\TFSServiceAccountName\Local Settings\Temp\Projectname\BuildName, change the working directory here.

Since the team working on this project is a little different, I've setup a different folder/share for this project so that I can assign appropriate share and NTFS rights.

  • Trigger:

Finally, you can select when to build. Options include manual (check-ins do not trigger a new build), Build each check-in, Accumulate check-ins until the prior build finishes, build every week on the following days.

For requirements, I am choosing the manual build option.

You new build definition should show up under TFSServer\Proejct\Builds in Team Explorer. Right click on the build and choose Queue New Build. Here you can select the build definition (defaults to the build you right clicked on), Build Agent, drop folder for the build (defaults to the folder you chose under Build Defaults), a queue priority, and option MSBuild command line arguments.

My build started, and downloaded all of the source from the root of the Project, which is somewhat undesirable, as it's not all needed. Also, it would be better if the build kicked off from a specific project within the solution I had selected. However, I'm in a pretty good position right now, I just need to tweak some stuff. When the build fails, a new bug is created, and if you have email alerts setup, you will be notified.

Issues Resolved:

  • Limit the amount of source downloaded (don't download the entire tree starting at $/Project

I solved this, at least for now, by going back into the build definition, and editing the workspace mapping. I change the default from $/Project -> $(Source) to $/Project/Folder -> $(Source)\Folder. Not only will this limit the amount of source downloaded, it is also used to

  • Reference Paths

There is a section in the TFSBuild.csproj file for specifying reference paths. This is very useful when you have those developers who always add a reference in a nonstandard location and break the build. It is specified in an item group property, as a child of the root <Project> element. In my file, it was inserted at the end. I am going to try to insert this into a .targets file that I can reference from multiple build files.

<ItemGroup>
    <!--  ADDITIONAL REFERENCE PATH
     The list of additional reference paths to use while resolving references. For example:
     
         <AdditionalReferencePath Include="C:\MyFolder\" />
         <AdditionalReferencePath Include="C:\MyFolder2\" />
    -->
  </ItemGroup>

 

  • Get a specific version (label)

I should have realized this earlier, but without an option in the Queue Build GUI, my need for building a specific version from a label drops significantly. I wanted QA to be able to build a version from a label, as defined by the dev team, such that the dev team could move on and start developing and checking in without impacting QA. The only "supported" way to get a specific version is to override the CoreGet task (see Ref #8), which means QA would have to check out and modify the TFSBuild.csproj file.

Open Issues:

  • Select a specific project in a solution to build from.
    • Current work around, is to create a new solution, or modify the solution I've been using to unselect some problem projects.

Miscellaneous:

  • Read on Buck's blog that you have to have an interactive session running on the build server to do automated UI tests. He has instructions on how to do this. (See Ref #5)
  • Extending the TFSBuild.csproj file. You can define reusable .targets files, which are just MSBuild files, and then import them into the TFSBuild.csproj file using <Import Project="Path\FileName.targets"/>
  • You can add tasks based on TF Build targets in either the TFSBuild.csproj file, or your imported .targets. (See Ref #2)
  • You can do incremental builds by setting the SkipClean property to true (See Ref #3).
  • The .rsp file that is created with the TFSBuild.csproj file is a file that is used to pass command line arguments to MSBuild (See Ref #7).

References:

  1. MSDN Documentation
  2. Customizable Team Foundation Build Targets
  3. How to: Customize the SolutionToBuild Item Group
  4. Buck Hodges Blog
  5. Buck's basic guide to Team Build 2008
  6. Incremental Builds
  7. MSBuild command line reference
  8. Get a specific version
Sunday, November 04, 2007 10:19:19 PM (GMT Standard Time, UTC+00:00)  #    Comments [0] -
Programming
# Saturday, November 03, 2007

Not that we use the TFS reports that much, but I noticed the main report on the front page of project site in Share Point, showed the warehouse hadn't been updated in a couple of days. So begins another adventure into getting it to work again.

At first I thought it was going to be easy, the service wasn't running. We had a power failure in the data center this past week, and it looks like on reboot, the service failed to start. Our new data center isn't running at production levels yet, so a power failure due to human error is not surprising. However, after restarting the service, the warehouse still wasn't updating.

I decided to invoke the warehouse manually, and ran the scripts suggested on this familiar MSDN thread to try to see what was going on. The manual warehouse update worked once, then wouldn't work again (Status always returned idle) until I restarted the IIS server. The results of the query did not seem to update, even though the Status values returned from the web service indicated that the warehouse update had ran. I decided to look at the ScheduledServices.xml in Program Files\Microsoft Visual Studio 2008 Team Foundation Server\TFSServerSchedule, and it was showing a wierd value for last run time (lastrun="1:1:1:0:0:0"). I'm guessing that this value indicates the process started, but never finished, so it never updated the date. My final clue to work with was an event log entry stating there was an unexpected exception while calculating code churn (TF53010). The specific details spoke of a incomplete character stream and possibly invalid encoding, in an xml file I had checked in recently.

I came across a MSDN post that mentioned that you can add this (<add key="ProcessingType" value="Full" />) appKey to your warehouse app.config. I could tell the warehouse web service restarted due to the delay in the web page for invoking the warehouse, but it appears like the run command has no effect again. So after "running" once, it won't run again at all. The value in ScheduleServices.xml is not changing at all (I manually changed the value so I could tell), so things are working at all. Event log is clear, so I need to find some other type of information.

I downloaded an installed DebugView from Sysinternals (used it before in TFS 2005) and changed tracing levels as outlined in the MSDN post linked to above, however either something change in 2008, or I setup the debugger wrong cause I got nothing. There were some other settings related to tracing, so I turned those on as well (appSettings.traceWriter = true, and set all switches to level 4). Nothing at all. The changes to the web.config file, which restart the app domain, seem to have some effect in that GetWarehouseStatus returns values to indicated it's trying to process, however, I get no debug or trace information. I take that back, Debug information has finally stared showing up I just don't know why.

Unfortunately there was nothing that pointed to why the warehouse processing was failing in Debug View. It seemed to show that everything was working correctly. I'm thinking that ScheduledServices.xml is only updated when the scheduler runs the warehouse, not manually. Looking back at my reports, them seem to be updating now.

So in summary, things appear to be working for now (need to wait 1 hour to see if the scheduler runs as expected), but I don't know exactly what fixed the problem. I turned off debugging and full processing, and things seemed to continue to work. I think the TfsWarehouse.dbo._WarehouseConfig table has contains rows that provide better information on when the warehouse last ran. You can easily change the RunIntervalSeconds setting to change how often the scheduler runs the task. I restarted the scheduler tasks after changing. Since our database is small, I set this to 2 minutes just to see if it was working, then set it back to 60 minutes.

Saturday, November 03, 2007 10:41:51 PM (GMT Standard Time, UTC+00:00)  #    Comments [0] -
Programming
# Saturday, October 20, 2007

While looking to download BizTalk 2006 R2 off MSDN, I came across Software Licensing and Protection Online Server (SLP Services), and an offer for MSDN subscribers for free use for 1 year. This was the first time I've heard of SLP Services, so I wanted to check it out, the home page is here: http://www.microsoft.com/SLPS/Default.aspx.

Key features include:

  • Code Protection (Advanced Obfuscation?)
  • License Enforcement thru activation and client side enforcement.
  • 1 code base, "unlimited" configurations. Create trial software, add-on packages, timed demos, etc.

SLP Services is either a Microsoft hosted, or server based product that can be used to protect, license and distribute your software. In the hosted model, Microsoft runs the service, and you pay them a fee. In the server model, you install the server onto your network and host it yourself. It might also be possible to resell SLP services, but I have not read the licensing to know that for sure. This blog post indicates that reselling the SLP Service is an intened use. In addition to the traditional use for licensing, the SLP Services web site also talks about benefits of using the technology in the enterprise, for in house applications, which include monitoring application use, and controller who can use a specific application, or feature. The Downloads page, for information on downloading a trial version of the code protection tool and documentation for online and offline products.

The basic version you get thru MSDN allows you to do the following

  • 1 licensed product
  • 100 Commercial Activations (i.e. Customers who purchase a license)
  • 1000 non-commercial activations (activations that were not purchased)
  • 1 basic permutation, which allows you to "create" 5 products from a single code base.

The more expensive licenses of SLP Services allow for more activations, permutations and you get statistics and an API for license creation. Check out the How to Buy page for details. Regular retail pricing for the basic hosted version (after your free year and for non MSDN subscribers) is $500/yr, which as I already mention, includes 100 commercial activations. Additional activations cost $1000 for 1000.

I really, really like the concept, but once again feel like Microsoft could be doing a better job at making this more accessible to smaller ISV's and independent contractors (in the same way I disagree with some of the pricing for VSTS and TFS). Granted these are retail prices, but but the point of entry for someone hoping to make $9.95 on a product, and who could really benefit from something like this, is a little high. I'd like to see a starter edition that gives you the 1000 non-commercial activations but includes no commercial activations, however, you could purchase them at $1/each. This way you could develop your code using the technology and then once you start selling, start paying for the service. I think that Microsoft is trying to avoid giving away the code protection for free so that they do not directly compete with other companies offering a similar product, which if that is the case, should offer a limited functionality version with the starter edition, again to get people started.

Software Cost Number of Copies to Break Even to cover $500/yr
$9.95 51
$19.95 26
$29.95 17
$39.95 13
$49.95 11
$59.95 9
$69.95 8
$79.95 7
$89.95 6
$99.95 5
   

 

UPDATE: Someone from MS responded to a post I made on the MSDN forums, confirming that, as a MSDN subscriber, as long as you renew each year, you have access to the basic version. This does make this a little more attractive, as a MSDN professional subscription is a good deal IMO.

I fully expect to see new hosted solutions start to popup that are based on SLP Services, that include e-commerce capabilities, and charge per copy based on purchase price.

In addition to the price, which may or may not be a detractor to you, there is one other issue. Since this is a Microsoft product, you are going to have allot of talented individuals looking to crack it. It will be interesting to see if a "universal" crack could be developed, and how MS will respond.

Saturday, October 20, 2007 5:21:58 AM (GMT Daylight Time, UTC+01:00)  #    Comments [0] -
Programming | Review For Future Projects | Tools
# Monday, October 15, 2007

Assumption: You have remote performance monitor installed and running (this will be the topic of another blog post, or you can review the references at the end of this article).

Garbage Collector

  • GC Latency Time

Memory Usage

  • AppDomain and JIT Heaps:
    • Never shrinks.
    • Returns memory at the end of the applications life.
    • Impacts the 32MB virtual memory limit on Windows CE 5.0.
    • Typically these should be under 1MB, although they can be larger on really big applications.
    • Size is related to the number of types, along with the number and size of method calls.
  • GC Heap
    • Varies with the life of the application
    • Impacts the 32MB virtual memory limit
    • 4-5 MB is not uncommon.
    • The amount of change in the GC heap is of more concern

 

How can I make my app faster?

I would suggest reading the post referenced below published by the MS Compact Framework team. I've seen it copied almost word for word at several places, so I'm not going to do that here. There is also an entire section in MSDN on Compact Framework Performance (see references below).

References:

Monday, October 15, 2007 11:43:17 AM (GMT Daylight Time, UTC+01:00)  #    Comments [0] -
Programming

WCF support was something I was really looking forward to, but I seem to have missed some announcements on what was, and was not supported. I came across this blog post today http://blogs.msdn.com/andrewarnottms/archive/2007/08/21/the-wcf-subset-supported-by-netcf.aspx and similar confirmations on the MSDN forums. The blog post was from late August, so it looks like I need to stay on top of these things a little better.

 

Basically, the lack of TransportWithCredentials as a security option kills WCF for us out right. I was able to get this working using traditional ASMX web service client on our devices communicating back to a WCF service, thanks in large part to the work Casey Chesnut did to get WSE working on the compact framework (which is now part of OpenNetCF). It looks like X.509 is the preferred method, but we have had extremely bad luck with certs, and I don’t think management will ever allow their use again. I see managing certs for thousands of remote devices to be a little more complicated than a simple username/password approach.

 

I was really hoping for binary formatting, but can’t say I’m surprised that it’s not included, because it seems like binary serialization has never been part of the compact framework. No support for Streaming Messages is also a let-down. I find it ironic that functionality such as binary formatting and streaming messaging is left you, give that the usual argument with respect to the compact framework one of size limitations. I see there is mention of a Gzip Encoder which sounds promising, but is unusable for us until we can implement a work around to no TransportWithCredentials security.

 

I was talking with Travis (president of Madison DotNet UG), and we both agreed that one of the best things MS could do with regard to the Compact Framework, is allow developers to customize what modules are included. Start with a small base install, similar to what it is now, but at least give developers the option to deploy additional functionality (without having to re-invent the wheel themselves) when needed.

 

I guess once CF 3.5 Is released, I’ll be on the lookout for what types of extensibility options are available, but probably won’t be able to program anything custom until after our first release in April.

 

From what I can tell from a few posts online, it sounds like I’m not alone in my criticism and hopefully, enough developers send MS feedback so that we can get some of this functionality introduced as an add-on at least.

Monday, October 15, 2007 12:46:48 AM (GMT Daylight Time, UTC+01:00)  #    Comments [0] -
Programming
# Friday, October 12, 2007

Slow week on the blog. Been busy with work, flooring project at home, and getting ready to announce a new personal development project (and all the research I've been putting into it).

VsTestHost was crashing on me today. It started out that TD.Net was failing, so I switched over to using the TestView to invoke the tests, fail. Since I'm running VS 2008 B2, I switched back to VS 2005 and created a new solution with only a handful of projects, fail. Installed the latest version of TD.Net, fail. Googled on VsTestHost.exe, only got a handful of results, one of which suggested re-installing VS (argh). Finally decided to test in debug mode, oh look a stack over flow exception. One of the posts on Google even mentioned that stack overflow exceptions are not (always) caught by VsTestHost. The stack overflow exception was caused by a property referencing itself, which was the result of an over ambitious find replace all.

Friday, October 12, 2007 11:33:50 PM (GMT Daylight Time, UTC+01:00)  #    Comments [0] -
Programming
# Sunday, October 07, 2007

I'm not even sure what led me to start playing around with the new Linq to SQL (formerly called DLinq) DAL in VS2008B2, but I'm glad I did. I discovered some very fascinating functionality that I believe will really shake up the way most developers approach the DAL. I see some similarities  between Linq to SQL and other OR/M plugins (tools, methodologies) out there, but since this is Microsoft's approach, I anticipate it will catch on en mass. I don't believe Microsoft is trying to make the other methods obsolete, but that they are delivering a product demanded by their customers. One of the problems with the current OR/M scene, is that there are so many options to choose from, that you never know if you've made the right choice. While Linq to SQL, may have some deficiencies, it will give developers, and their managers a little piece of mind when breaking from the traditional DAL mold. I can only hope that Linq to SQL does not disappoint, even after taking into consideration it's a Gen 1 product. Issues such as performance, extendibility, and plugability (into one's code or way of doing things) are some things that I want to explore (as with any tool such as Linq to SQL).

I used this article to help jump start my foray into Linq to SQL (let's just call it L2S from here on). Being away from WinForms for so long, I've missed out on some of the data binding features available, and was surprised to see how easy it was to get up and going with a grid and details form. I remember seeing the videos when VS 2005 was coming out, but never had a need to play around with it until now. I've also never had good luck with drag and drop data binding, as it assumes to much, I'm hoping that there are plenty of hooks available to help customize the data binding experience, but any fault with data binding should not be confused with L2S as they are 2 separate features (actually data binding is a feature, and L2S is a feature of VS 2008, and part of the .Net Framework 3.5).

In a couple of minutes, I was able to generate a data class using the new visual OR/M tool in VS2008, create a binding source, drag/drop elements from the binding source onto my form, and create a functional application. Functional should not be confused with enterprise level, nor was I expecting it to be. If I could create something like that in 2 minutes using drag and drop, my value ($$$$) as a developer would be on the decline. Allow me to recap some of my steps I took to create a functional application.

  1. Create a new Winforms 3.5
  2. Right click on the new project and select add new item, choose Linq To SQL Classses.
    1. This will create a new .dbml file. It will open a design surface where you can drag/drop tables, views and stored procedures. This creates a DataContext class.
  3. Create a new database connection, or open an existing connection on your Server Explorer Window
  4. Drag tables from the database from the Server Explorer to the design surface of your DataContext class.
  5. From the top menu bar, choose Data/Add new data source, or, show the data sources window, and choose the add new data source option
    1. Create a project data source
    2. Here is where it starts to get tricky. Select an object to make a data source for. It will depend on what you are trying to accomplish and your database schema. The schema I was using, relies heavily on extended tables, and it took me a couple of tries to pick the object that made the most sense. It's possible that I will have to go back and create a different object down the road as I get more into this.
  6. If you haven't already opened the Data Source window, do so now. Select some elements from your data source, and drag/drop them onto the default Form1. I chose a grid to list a collection of objects, and then their details below. A BindingNavigator was added for me automatically. If you didn't get one, or need to add one later, just drag one onto the form from the tool box, and set it's BindingSource property to the bind source you created in step 5.
  7. Open the code view of Form1
  8. Add a private member variable: DataClasses1DataContext test;
  9. Under the form's constructor, do the following
  10.    1: public Form1()
       2: {
       3:  InitializeComponent();
       4:  test = new DataClasses1DataContext();
       5:  if(test.DatabaseExists() == false) //Not required, just testing feature found thru intellisense
       6:   test.CreateDatabase();
       7:  x_t_personBindingSource.DataSource = test.x_t_persons;
       8: }
  11. Jump back to the Form, and add a button to your binding navigator for saving. Double click on the new button to have the event handler code generated and add the following:
  12.    1: private void saveToolStripButton_Click(object sender, EventArgs e)
       2: {
       3:  test.SubmitChanges(); //Need to add exception handling and pre-save validation
       4: }
  13. Build and Debug.

A connection string is automatically added to your App.Config file for you. You can test out the CreateDatabase feature by changing the connection string to a non-existent database. You should be able to add/edit/delete records in your database, using this simple application we just created. The DataContext class, is the top level class in the hierarchy used to work with your database. It controls the connection to the database, and, as you've seen, has support for creating and deleting the database. The create database feature reminds me of a similar feature in the Castle's Active Record project. Just take a look via object explorer or intelli-sense, all of the methods available to you. I've listed the ones that caught my attention below. 

  • Create/Delete Database
  • Deferred Loading Enabled: Implies that L2S uses deferred loading for many to one relationships
  • ExecuteCommand: Direct execution of a command.
  • ExecuteQuerey: Returns IEnumerable or <T> based on a provided query.
  • GetChangeSet: Returns changes tracked by the DataContext
  • Transaction: Set a transaction object to support transactions

Validation - Check out ScottGu's part 4 on L2S

  • Schema Validation - Linq is supposed to check for obvious schema issues, such as null values. However, the exception I got when I tried to insert a null value, came from SQL, not Linq. Also I was adding items on a grid, and added 2 items in a row. Their Id fields were both set to 0, and when I went to save, I got a Linq exception saying I couldn't have duplicate keys. Setting the ID values to something different, allowed me to get to the database at least, so I need to look into this more.
  • Property and Submit Validation - Create a partial class, then a partial method that implements validation when a property is changed. If you type partial in the code view window, you will get a list of partial methods you can implement. You have access to 2 methods for each property, OnChanging and OnChanged. You also get access to a OnValidate method. If there is an error, you throw an exception. This works OK, but doesn't provide the nicest feedback available. However, for anything less then an enterprise application, this may be OK, especially in a proof of concept, or highly iterative application, where you can add better a better user experience later. 
  • Insert/Update/Delete Validation - Same scheme as property and submit validation, but you can have validation in response to an Insert, Update or Delete.
  • ChangeSet: Starting with Beta2, you can get access to all of the changes in the DataContext. One possible use, is to inherit the DataContextClass, and override the SubmitChanges method, checking the ChangeSet and performing validation.
  • My Take on validation:
    • There is some work that needs to be done with validation. I could see an edition to the Enterprise Library designed specifically for L2S.
    • My own idea would be to create a class to track validation errors.
      • New custom exception called validation error.
      • A collection of validation errors, including error text, and the property that is invalid
      • Starting to sound allot like CSLA

Other things I noticed

    • You can manually create classes in the Design Surface, as well as edit the auto generated ones
      • Control nullable, access modifier, and inheritance modifier.
    • There is an inheritance property you can set on the design surface, allowing you to indicate which objects inherit from another. This looks very promising for some of the schemas I work with.  

What's Next?

I'm going to read over ScottGu's 7 part series on L2S to get some good ideas on what I can do with L2S, and see how it can fit into future and existing projects. I am really excited to see how people start to integrate L2S with their existing projects and frameworks. Of particular interest would be using CSLA and L2S.

Additional Resources

Note: First post where I've had formatted HTML for source code. I'm using the Code Snippet Plugin for Windows Live Writer.

Sunday, October 07, 2007 11:02:14 PM (GMT Daylight Time, UTC+01:00)  #    Comments [0] -
Programming | Review For Future Projects
# Wednesday, October 03, 2007

Wow! Microsoft is making available, starting with the core libraries of .net 3.5, the full, commented source code for the .Net Framework. ScottGu posted about it here, and ScottH has a podcast about it here. Not only are they releasing the source code, but they are doing it in such a way as to make it actually useful to the end developer, by offering full support in Visual Studio 2008. Not only can you download the source and install it, but Visual Studio 2008 will be smart enough to go out to a server hosted by Microsoft and dynamically download the correct source file. By correct, I mean, that the service is smart enough to know what patches, service packs, etc you have installed. Chalk this up as one huge reason to jump on the VS 2008 band wagon.

For those of you in legal, the code is released under the Microsoft Reference License, which in a nutshell, states you can review, but not compile. Now at first, I thought, who cares if you can't recompile, but then I got to thinking, and remembered a project someone was telling me about where they used reflector to view the source and implement an asp.net server running off the compact framework. Given the use of the compact framework on my current project, I could see a similar need arising. I will have to monitor this closely and see what other people say, as I'm sure I won't be the only one looking to implement some full framework features on our closed WinCE systems.

Wednesday, October 03, 2007 7:42:53 PM (GMT Daylight Time, UTC+01:00)  #    Comments [0] -
Programming
# Sunday, September 30, 2007

On Thursday, I attended a DevCares event on WCF. We are using WCF in allot of different places on current project and I was hoping to learn some new information on how to make the most out of WCF. While I did learn some new things, I did leave feeling a little disappointed, and felt I could have gotten the same things from a Webcast and saved the 2 hour round trip (more on this later).

The event was held at Inacom, in one of their classrooms, and the free snacks and soda, was defiantly one of the hightlights. Even though we were in a technology classroom, complete with 1 workstation per user, they were not setup for us to try out any of the code and examples that were being presented. I downloaded power shell and was playing around with that during that portion of the presentation. I was tempted to pull out my laptop so I could follow along, but would have felt a little out of place. The presentation itself was a mix of power point slides and demos, which didn't always work. There were some nice gifts given away at the end, which consisted of some books a copy of Expression Studio, and a Copy of Office 2007 (professional I think). I wasn't too disappointed that I didn't win, as I do have a MSDN subscription and access to all of the software given away, but for some reason, it's always nice to win.

The presenter reminded me of one of my many college professors, and read pretty much verbatim from a prepared presentation. It would have been nice if the notes he was using were made available to us, it would have saved me some typing. Perhaps they are available online, I have not looked to closely. The demos and presentation were given off a laptop running a virtualizes windows Vista, for IIS 7 I am assuming. Given the go live license of Windows Server 2008 Beta 3 and RC0, I would have preferred to see one of those used instead (ok, so RC0 was released 2 days before the presentation). However, I do not think the presenter would have been able to setup anything that wasn't prepared for him ahead of time.

The first couple of demos were pretty straight forward and actually worked. These covered the use of the configuration tool, and test harness in VS 2008. The configuration tool included in VS 2008 would have saved me a lot of time in managing my config files this past summer. Also, VS 2008 includes a new test harness tool, which creates a very simple WinForms application based on the meta data retrieved from the WCF service, which can be used for quick testing. You need to have .Net 3.0 as the Target Framework, not .Net 2.0, which if you are upgrading from VS 2005, is probably the default. Once you have targeted .Net 3.0, a new Debug Tag under project properties will be available, and by default, under startup options, the following command will specified: /client:"WcfTestClient.exe"

I won't be giving up my unit tests anytime soon, but the test harness application still has it's place. We then moved into logging and tracing using the Microsoft Service Trace Viewer, a tool I sought out well before the class, and has saved me countless hours, so it was good to see if covered in the class. The first "half" of the class wrapped up with performance counters and monitoring through WMI and PowerShell (using WMI). PowerShell is something I have read allot about, but not had the time or immediate need to play around with. That has now changed, with all of the WMI support for WCF, PowerShell is the natural choice for querying our WCF applications. Couple that with the PowerShell extension for PolyMonand we'll have ourselves a nice little monitoring application.  

After a quick break to restock on free soda and snacks, we moved into the 2nd half of the class, and this is were things started to go downhill, pretty much because none of the demos worked, and what I feel were some omissions on the topic of deployment. Topics covered in the 2nd half included custom channels, custom bindings, load balancing and deployment. However, none of the demos worked, so it was as if we were just reading from a book, which probably would have provided more detail then what we were getting. On the topic of deployment, we covered IIS and WAS, however, there was no mention of the fact that WAS is only part of IIS 7, and nothing about custom hosting in case you happen to be running WCF were IIS 7 is not available. The only reason given for using WAS was that you could use other bindings besides HTTP, but not why those other bindings might be desirable (such as the huge performance gain when using tcp and binary encoding, assuming WCF at both endpoints).

All in all, I think in the future, I will save myself the 2 hour round trip, and try to find some WebCasts, or Channel9 videos on the topic. The exception to this, would be if I knew the presenter was going to be good, based on past experience, a recommendation, or at least if they had some real world experience. I guess I can't complain, the event was free, and there were free snacks.

Sunday, September 30, 2007 10:24:00 PM (GMT Daylight Time, UTC+01:00)  #    Comments [0] -
Programming
# Wednesday, September 19, 2007

When markup won't do, why not markdown? [Scott] recently wrote about JottIt and MarkDown. JottIt is a simple way to create a web page. The content is rendered using Markdown, and feels allot like a Wiki. Upon creation of your first site (just go to JottIt and type something in the big empty text box), you are redirected to a URL like http://jottit.com/d4b8y/. You do have the ability to create a sub domain with a more meaningful URL.

Markdown is a way to support rich text, without using a rich text editor, which is how allot of Wiki's work, I just never knew there was a formal definition. The markdown that I have linked to, is a .Net port, and compiled into a .net assembly. Not requiring a cumbersome rich text control, and removing HTML formatting from user controlled text are two big reasons to consider MarkDown. The syntax as extremely easy, and rates high on Scott's WAF.

Wednesday, September 19, 2007 7:15:48 PM (GMT Daylight Time, UTC+01:00)  #    Comments [0] -
Programming | Review For Future Projects
# Thursday, September 06, 2007

I wish I could do more then just rehash other people's posts. However, one of the purposes for this blog is a place for me to write down stuff I'd like to visit in the future (such as sample code). Scott has posted his forth installment in a series he entitles "The Weekly Source Code".

Of the links posted this week, the ones that I plan on looking into more are:

  • WPF Contrib - Contrib for WPF. I'm not using WPF in any projects at the moment, however, this contrib looks like it could jump start some sample applications at home. A good way to get started with WPF.
  • Wintellect Power Collections - From the web site, and Scott's post: "
  • Some of the collections included are the Deque, MultiDictionary, Bag, OrderedBag, OrderedDictionary, Set, OrderedSet, and OrderedMultiDictionary."

Ones that I am going to save for when a need arises:

The reason I am interested in the mail ones, are that I will be sending out email notifications in my current project, thru BizTalk. In order to test the application, I will need to be able to login to test mailboxes and retrieve messages. While .Net has some built in support for email, 3rd party libraries can't hurt.

Thursday, September 06, 2007 4:01:12 AM (GMT Daylight Time, UTC+01:00)  #    Comments [0] -
Programming
# Tuesday, September 04, 2007

?? Operator

Scott's most recent post on LINQ, showed me that I still have alot to learn about C#. The ?? operator was casually thrown into the mix as if it were as common as +, =, or a semi-colon (;).

It took a couple of searches on Google to find what I wanted, but I finally found a page on MSDN that lists all of the C# operators in 2.0, and the one I was looking for.

The ?? operator returns the left-hand operand if it is not null, or else it returns the right operand.

 

int? x = null;

 

//This will assign the value of -1 to y

int y = x ?? -1;

 

//Change x to an integer, and it will be assigned to y

x = 5;

y = x ?? -1; //y now = 5

 

Extension Methods in .Net 3.5

Another tidbit I ran across, was the introduction of extension methods in C# 3.5. Basically, extension methods allow you to create a method that is associated with a type, such that you can call it (and have intelli-sense support), as if it was defined as a method if the type's definition. For example, the Subtract() method of the DateTime type, is defined in the type. With extensions, you can add some code to define a method foo(), such that you can do something like DateTime.foo(); Extension methods are most closely compared to similar functionality in Ruby.

I found an example on Phil Haack's blog which I tried out myself, and reproduced below (note to self, learn how to format code examples nicely).

namespace ExtensionMethods
{
 public static class Extenders
 {
  public static DateTime Ago(this TimeSpan value)
  {
   return DateTime.Now.Subtract(value);
  }

  public static TimeSpan Minutes(this int value)
  {
   return new TimeSpan(0, value, 0);
  }
 }

 class Program
 {
  static void Main(string[] args)
  {
   Console.WriteLine(20.Minutes().Ago()); //With Extensions
   Console.WriteLine(DateTime.Now.Subtract(new TimeSpan(0, 20, 0))); //Without Extensions
   Console.ReadLine();
  }
 }

}

I got intelli-sense on after typing Minutes(), but no intelli-sense on 20. I was also curious to scope, and where extension methods will need to be placed, and how to access them. Moving the Extenders class outside of the main namespace, I got compile a compile time error stating that int doesn't have a Minutes method (standard 2.0 error), as well as text indicating that there were no extension methods (new for 3.5 obviously). Adding a using statement allows the code to compile. I then tried duplicating my extension namespace and adding a 2nd using statement, and got the expected compile error about ambiguous methods. To me, I can see trouble in the future with conflicting Extension Methods in different namespaces. It doesn't look like you can use a fully qualified name either.

This MSDN article gives some technical info on Extension Methods (it's an article containing info on several new language features). Here is some of what I got:

  • Extension methods are declared by specifying the keyword this as a modifier on the first parameter of the methods.
  • Extension methods can only be declared in static classes.
  • Instance methods take precedence over extension methods, and extension methods imported in inner namespace declarations take precedence over extension methods imported in outer namespace declarations.

There is some debate going on in the comments section of the blog post where I got the example from. Some people seem to think that while easier to read (debatable itself), it makes for harder to maintain code. Others claim it breaks OO principles.

See Also: ScottGu's post on Extension Methods

Tuesday, September 04, 2007 2:59:37 AM (GMT Daylight Time, UTC+01:00)  #    Comments [0] -
Programming
# Saturday, September 01, 2007

I recently came across an article on UTC to store date/time values. A decision made on a current project I am working on was to use UTC for client applications. However, the dates stored in SQL currently not in UTC.

I guess I've just gotten used to the GetDate() function in SQL.  A more appropriate function for our application would be the GetUtcDate(), which will return the current date/time in UTC format.

From the article:

The primary advantage of storing date/time values in UTC is that it makes the data transportable. To see what I mean, imagine that following scenario: you have an eCommerce website that is being hosted in a web server located in the Pacific time zone (UTC -8) and this application stores the date and time orders were placed in server time. Say a user, Bob, makes an order on August 1, 2007 at 9:00 AM UTC -8. After many months of phenomenal growth, you decide to switch to a larger web hosting company, one on the east coast where the time zone is UTC -5. Since the date/time is stored in server time, Bob's previous order still shows that it was made on August 1 2007 at 9:00 AM. But since we are now in UTC -5, it is as if Bob's order was made three hours earlier than it really was (since when it was 9:00 AM on August 1, 2007 in the west coast it was really 12:00 noon on the east coast).

 The author then goes into explain how you can fix the above issue by doing an update on the data to correct the time, which he refers to as "Ick", and I will have to agree with that. You don't want to, nor should you have to ever update a time stamp type property.

The next example uses various time zones to illustrate the problem of converting from one time zone to another (not to mention DST and SDT). Since we plan on eventually offering localized versions of our Web Application, displaying all times in CST/CDT is not idea. Not to mention the change from daylight savings time to stand time makes the way we display data currently, very confusing. Things seem out of order at best.

 Well, I'm off to update my use of GetDate to GetUTCDate. Be sure to read the full article.

Note: I found this article originally from ScottGu's RSS feed. However, the actual blog doesn't have the UTC article listed under Asp.Net, or listed at all.

Saturday, September 01, 2007 10:21:49 PM (GMT Daylight Time, UTC+01:00)  #    Comments [0] -
Programming | Sql
# Tuesday, August 28, 2007

After being informed of VS2008 multi-targeting capabilities, I went to download and install Beta 2. The install was quite easy and allot faster then VS 2005. I had to reboot once after installing the framework 3.5, and then once after the install was completed.

 

My first 2 issues that I encountered were, no support for rptproj files, and it wanted to do an upgrade on the solution and project files. For the upgrade, if it just updates the solution, I'm not that concerned, as we don't keep solutions in source control. However, if the project files are updated, then that is a problem, and will prevent me from using Beta2 until the entire team is ready to upgrade.

 

To test, I copied a project to a separate folder and ran an inplace upgrade. Since I don't have TFS client installed (issue #3, need to either install the 2005 TFS client or download and install the TFS Beta 2 client, or rather the entire ISO), I had to remove the source control bindings (good for this test). The project file converted successfully with no errors. I opened up VS2005 and selected the project, and was prompted with a warning about invalid tags in the csporj file, and I could either open for browsing, or open normally. I chose to open normally, and it did successfully. There was a hint that installing a registry key will allow you to specify to ignore the new tag that VS2008 inserts. I think that this will be a suitable work around. Next step is to try upgrading on the live projects, rebuild and make sure everything works. Then create a registry file that the team users can execute.

 

Upon closer examination of the converted csproj file, it replaces an Import statement, with a new one.

Old:

<Import Project="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v8.0\WebApplications\Microsoft.WebApplication.targets" />

New:

<Import Project="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v9.0\WebApplications\Microsoft.WebApplication.targets" Condition="" />

 

I added the old line manually to the converted csproj file, and it still built. However on a machine that doesn't have Vs2008 installed, that new import path doesn't exist, and the project can not load.

 

Doing some more searching has yielded no suitable work around except coping the new build targets to each workstation. This seems to work.

 

One other upgrade issue is VS2008 will replace what version of the UnitTesting assembly you use (8 to 9). Changing the reference to use specific version to false seems to be a suitable workaround. I just need to remember to set it back to true once everyone else is up and running.

Tuesday, August 28, 2007 8:15:20 AM (GMT Daylight Time, UTC+01:00)  #    Comments [0] -
Programming
# Wednesday, June 27, 2007

So I got around to adding Database rollback functionality to my MSTest unit tests by using an article I read in MSDN magazine back in 04, before switching to MBUnit at my last job.

 

Everything was working great on my local computer (Vista even), and then I checked in my tests, and the failed, horribly on the build server. Fist issue was MSDTC network access was not enable, so I fixed that, but Then the build wouldn't even complete.

 

I dropped down to a console window and ran the tests manually using the MSTest command line tool. When running all of the tests, it hung after about test #9 of 17. When running the tests individually I was getting MSDTC errors. After spending too long just randomly trying DTC settings, I rememberd the trusty MSDTC testing tool I had stashed away for problems like this. Got that copied over to the build server and.....a generic error message that had me searching on google to no avail.

 

Around this time, I noticed that the event view was conviently located in the same MMC windows as Component Services, and had ment to check it for the past 30 minutes, I finally opened it up and BAM, there it was, a DTC error, but would it give me a clue as to what the problem was? YES! Not only a clue, but a god dam solution to boot (a welcome change).

 

The problem? My build server was from the same clone as my Dev Server that had the SQL DB on, and since I did not use sysprep, but SysInternals NewSid app, the DTC was not setup correctly (they both had the same ID).

 

The solution? Run msdtc -uninstall and then msdtc -install from the command line to reinstall msdtc. I had to run msdtc -install twice and click around in the Component Services windows a couple of times before i could get DTC configured for using a local cooridantor, but in the end, it was running.

 

Back to dtctester, which passed, back to my command line unit tests, which passed, back to the build server, which passed.

Now because I like the extra challenge, I thought I'd enable windows firewall on the build server as well. Whooops, broke it again, but I knew I had gotten DTC to work before so it was just a matter of comparing settings.

 

It's pretty easy to get DTC to work with windows firewall, just enable an exception in the firewall for c:\windows\system32\msdtc.exe, and don't forget to restart MSDTC service for changes to really take affect.

 

Bam, everything works, and now, I can go home.

Wednesday, June 27, 2007 3:05:47 AM (GMT Daylight Time, UTC+01:00)  #    Comments [0] -
Programming
# Tuesday, June 26, 2007

So I got around to adding Database rollback functionality to my MSTest unit tests by using an article I read in MSDN magazine back in 04, before switching to MBUnit at my last job.

 

Everything was working great on my local computer (Vista even), and then I checked in my tests, and the failed, horribly on the build server. Fist issue was MSDTC network access was not enable, so I fixed that, but Then the build wouldn't even complete.

 

I dropped down to a console window and ran the tests manually using the MSTest command line tool. When running all of the tests, it hung after about test #9 of 17. When running the tests individually I was getting MSDTC errors. After spending too long just randomly trying DTC settings, I remembered the trusty MSDTC testing tool I had stashed away for problems like this. Got that copied over to the build server and.....a generic error message that had me searching on Google to no avail.

 

Around this time, I noticed that the event view was conveniently located in the same MMC windows as Component Services, and had meant to check it for the past 30 minutes, I finally opened it up and BAM, there it was, a DTC error, but would it give me a clue as to what the problem was? YES! Not only a clue, but a god dam solution to boot (a welcome change).

 

The problem? My build server was from the same clone as my Dev Server that had the SQL DB on, and since I did not use sysprep, but SysInternals NewSid app, the DTC was not setup correctly (they both had the same ID).

 

The solution? Run msdtc -uninstall and then msdtc -install from the command line to reinstall msdtc. I had to run msdtc -install twice and click around in the Component Services windows a couple of times before i could get DTC configured for using a local coordinator, but in the end, it was running.

 

Back to dtctester, which passed, back to my command line unit tests, which passed, back to the build server, which passed.

 

Now because I like the extra challenge, I thought I'd enable windows firewall on the build server as well. Whooops, broke it again, but I knew I had gotten DTC to work before so it was just a matter of comparing settings.

 

It's pretty easy to get DTC to work with windows firewall, just enable an exception in the firewall for c:\windows\system32\msdtc.exe, and don't forget to restart MSDTC service for changes to really take affect.

 

Bam, everything works, and now, I can go home.

Tuesday, June 26, 2007 5:29:13 AM (GMT Daylight Time, UTC+01:00)  #    Comments [0] -
Programming | Sql
Archive
<July 2009>
SunMonTueWedThuFriSat
2829301234
567891011
12131415161718
19202122232425
2627282930311
2345678
About the author/Disclaimer

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

Copyright 2009
Adam Salvo
Sign In
Statistics
Total Posts: 203
This Year: 27
This Month: 0
This Week: 0
Comments: 21
Themes
Pick a theme:
All Content 2009, Adam Salvo
DasBlog theme 'Business' created by Christoph De Baene (delarou)