newtelligence poweredRSS 2.0
# Tuesday, October 23, 2007

This is my second, and hopefully last post detailing the work I did to upgrade TFS to 2008 Beta 2, move computers and change domains. You can read part 1 here. As it stands, the source control and work items are working, reports are almost working, SharePoint is on life support, and I should purchase stock in Pepsi given how much Mountain Dew I have consumed during the course of this adventure.

 

Work Items

All of our work items were assigned to users in the previous domain. Even if I had followed the instructions and added "throw-away" accounts in the new domain, they would still have to be updated. Using the built in support for viewing work items in Excel, made it pretty easy to change. Just open a query in Excel, and do a find/replace all for the user name. I only had 4 projects and 5 users, so it wasn't too bad. You do have to open up each project separately, so if you had allot of projects, it could become tedious, at which point I'd probably look to writing a SQL script to do the update for me.

Work Spaces

In TFS, you can only have a physical path on a specific computer, mapped to a TFS workspace once, regardless of the user or TFS server. In my case, a conflict arose because of the change in user names. There were plenty of hits on Google for the error message, but they all pointed to removing a xml file that caches workspace mappings locally. This didn't help me, as the problem was on the TFS server itself. Using the TFS command line tool tf, I was able to view all of those workspaces from my local machine using "tf workspaces /owner:*". The /remove option only seemed to work with the local cache file, and even after installing VS 2008 on the TFS server, the tf tool was no where to be found. This was because I installed as much as I could to E, and the environmental variable was set to C:

There doesn't seem to be an option to update the username for a workspace, if the user id has changed (which is what happened in our case). So I'm going thru and deleting the workspaces using "tf workspace /server:TfsServer /delete workspace;owner". There are allot of workspaces that no longer make sense due to computers no longer existing in the new domain. These can be removed outright, along with workspaces that have no pending changes associated with them. Since I had very few changes, and didn't care about them, I decided to delete my workspace to see what would happen. After recreating the workspace and doing a get latest, my changes were overwritten without any warning. I was hoping to have the option of merging, but unfortunately I did not. At this point I am going to have to have a couple of developers take a look at their pending changes and decide if they need to manually merge them.

While I was searching for a way to change a workspace owner, or what the effects were of deleting a workspace with a pending change, I came across a free set of tools that provide a GUI to some of the command line stuff. Check it out here.

Web Access

As long as I'm going cutting edge (Beta 2 with a go live license is cutting edge, not bleeding), I figured I'd install the CTP of the Web Access power tool. We have a couple of people who need to edit/view work items who are not developers, so avoiding an install of Visual Studio/Team Explorer is idea.

Other then requiring Team Explorer on the web server (which is already present since this is going on the TFS server), the Web Access is a pretty light weight install, and I have no fear of not being able to upgrade to the release version of the power toy. I originally tried to install it under the default web site with integrated authentication since this is used over a VPN only, but that failed with a trust issue. I then moved it to it's own virtual site running in it's own application pool, and it worked fine.

Reporting Services:

I fixed my permissions issue, it was a bad password on the OLAP data source. However, I have another problem. The warehouse does not seem to be getting updated, as there is no data in the reports. I also get an error message in the event log: "System.Security.Principal.IdentityNotMappedException: Some or all identity references could not be translated." I can reproduce the error by directly invoking the warehouse thru the web service, so at least as I try fixes, I can verify quickly if they worked or not.

Doing some searching, I came across this article (which I've come across before), which is a step by step guide to identify issues with the warehouse. Given my symptoms, I decided to delete and rebuild the OLAP warehouse using the command line tool specified in the article, as well as the TFS migration guide. "setupwarehouse -o -s datfsp100 -d TfsWarehouse -c Warehouseschema.xml -a Domain\TfsService -ra Domain\TfsReports -v -mturl http://Server:8080 -rebuild". I then manually invoked the warehouse update from the web service, checked the application logs (clear), checked TfsWarehouse.CurrentWorkItems (actually had something), and checked the reports (they had data). My only remaining concern is that the warehouse updates on it's schedule (UPDATE: Everything is working normally after 1 day of monitoring).

SharePoint:

I was following the MSDN instructions (see previous post) for restoring SharePoint as part of the restore based migration. However, I ran into an issue in that I could re-add the content database. To recap, I restored the STS_Content_TFS database to the WSS_Content database. I then used Sharepoint Administration to remove the content database, and was trying to re-add it. When you go to add it, it tries to name is WSS_Content_Random, so remove the random stuff so you are left with just WSS_Content. I then had to grant DB_Owner permissions to the WSS_Content DB for my TFSService account, which is what the SharePoint admintool application pool was running as. After setting DB_Owner rights, I was able to add the WSS_Content DB as the content database, after which I went into Application Management\Site Collection Admins, and changed the primary admin from my old account, to my new account. I was then able to connect to share point sites so that I could start setting up the other user rights permissions. I was very happy to see Sharepoint working again, as I thought I was in for another all night battle.

I was having an issue whereby I could browse the site from computers that belonged to the new domain, but unable to browse to it from other computers. This is because the web app was talking my FQDN and turning it into just the host name, and the  computers outside of the domain could not resolve that. This was fixed by using SharePoint Administration to add a new external link for the intranet zone for the FQDN (this is done under alternate mappings). This issue was also present when trying to view reports from Sharepoint, as the links were redirecting thru a TFS helper page, which was not user the FQDN. I fixed this by editing the following registry key: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\9.0\TeamFoundation\ReportServer\80\sites

Cleanup:

  • System drive on the TFS VM was getting a little low, so I created a new 3GB virtual disk and moved the swap file over to it.
  • Setup new backup schedules and cleaned up the log files from the restore 
  • Event logs are looking pretty clean.

Final Thoughts

I don't think I used consistent formatting in either of my two posts, which probably is a violation of blogging etiquette, and will not win me and readers choice awards anytime soon. The Microsoft documentation was very helpful, and definitely saved me allot of time compared to either doing it on my own from scratch, or compiling a guide based on Google. I'd like to see the TfsAdminUtil changeaccount operation support changing user accounts instead of just service accounts. I expect the in place upgrade to TFS 2008 RTM will be easy, and hope to never have to migrate TFS again anytime soon.

Tuesday, October 23, 2007 8:21:34 PM (GMT Daylight Time, UTC+01:00)  #    Comments [2] -
Technology
# Monday, October 22, 2007

My task for the past week, and likely for the next week, is the migration of our production TFS 2005 server (data), to a new server, running TFS 2008, in a new domain. The process that seems to have work somewhat, is to upgrade the existing TFS server to 2008 Beta 2, then do a restore based migration using the MSDN documentation. There are a few issues to clean up, and you can read about them in my follow-up post.

Preparation

  • Start with a clean Win2k3 R2 SP2 32bit OS. This OS is vitalized under ESX server.
  • Read over the latest version of the installation guide located at: http://go.microsoft.com/fwlink/?LinkId=79226. I will be doing a single server installation, which all TFS components on the same server. At this point, I am unsure of where the build server components will go, and will be the topic of another post.
  • Create service accounts for use with TFS.
    • TFSService
    • TFSReports
    • SqlServiceInternal - Not required for TFS, but a service account for running SQL server under (vs. local system).
  • Turn on Windows Firewall with Remote Desktop. I prefer to get things working with Windows Firewall running. The installation guide says that most ports will be added to Windows Firewall exception list, but some manual configuration will be necessary.

Prerequisite Installation on New Server

  • Install IIS as per the instructions in the installation guide.
    • Do not install FrontPage server extensions 2002, this is explicitly stated in the guide.
    • Do not install WSS at this time, as 3.0 can be installed with TFS.
    • I also added the option for a local smtp service, such that it can handle sending emails to our primary email server, preventing individual applications from being blocked while waiting for mail to be sent.
  • Install SQL Server 2005 Standard Edition as per the instructions in the installation guide
    • The following components are required
      • SQL Server
      • Reporting Services
      • Analysis Services
      • SQL Browser Service
    • I also installed the management components.
    • IT Requests:
      • Install all components to the E:\ Drive, which is the "data" drive. Some stuff is hard coded to install to the C:\Drive
      • Move all log files to the F:\ drive, which is designated for logs.
    • Moving Log Files
      • Follow these instructions from MSDN on moving system database: http://msdn2.microsoft.com/en-us/library/ms345408.aspx. Before installing user databases, change the data base properties such that the default install locations are correct.
      • Move model, msdb, and temp db using the following commands (You can run all 3 at once, then shutdown and move all 3 log files):
        ALTER DATABASE model MODIFY FILE (Name=modellog, FileName='F:\SqlLogs\modellog.ldf')
        ALTER DATABASE msdb MODIFY FILE (Name=msdblog, FileName='F:\SqlLogs\msdblog.ldf')
        ALTER DATABASE tempdb MODIFY FILE (Name=templog, FileName='F:\SqlLogs\templog.ldf')
      • Shutdown SQL, move the log files on the file system, then restart sql server.
      • Verify success by querying the system database
        SELECT name, physical_name AS CurrentLocation, state_desc
        FROM sys.master_files
        WHERE database_id = DB_ID(N'DatabaseName');
      • Move the master database. Follow the instructions from the MSDN article, as it's a little more involved. Here is the command line statement I executed for the step to move the resource database.
        E:\Program Files\Sql\90\Tools\Binn>sqlcmd -S 127.0.0.1 -d master -E -Q "alter database mssqlsystemresource 
        modify file (name=log, filename='f:\sqllogs\mssqlsystemresource.ldf')"

      • Make sure that when you go into single user mode, that all SQL services are stopped, otherwise they will take the single connection that is available.
  • Install SQL 2005 SP2
    • There is an issue with SP2, and having the ldf file for mssqlsystemresource in a different location. If possible, on a clean installation, I would install sp2, then move the ldfs. If you move the ldf's, then install sp2, copy the newly created mssqlsystemresource.ldf from your default data file location to your custom ldf location, overwriting the old ldf.
  • Install QFE KB925673 from the TFS installation media
  • Change to static IP
  • Download and install .Net Framework 3.0
  • Snapshot server so we can roll back changes if we need to do this again, either with fresh data, or because something went really bad.
Upgrade Existing TFS 2005 to 2008
  • Snapshot existing server
  • Backup databases for extra safety
  • Turn on windows firewall to prevent access to TFS during upgrade process, although at 12:30am I don't think many people are trying to access it.
  • Even though the upgrade instructions didn't tell me to do this, I shut down the TFSServerScheduler
  • Install to E:, even though original installation was to C, C drive was running very low on space.
  • Installation failed on first attempt. Exact failure was during the .net 3.5 beta 2. This might have been due to the fact I was down to < 250MB free space on my System drive. Reverted the snap shot to start over. 
  • Moved the 2GB page file to the E:\ Drive to free up some space. There was also some updates that had not been applied.
  • Applied all updates, and then installed the .net 3.5 Framework by itself first.
  • Checked to make sure I could still connect to TFS, but I could not. It failed with error TF30331, which is a generic can not connect error. Looking at the error details, there was mention of assembly manifests not matching. A quick Google search yielded a result indicating to try aspnet_regiis -i, which fixed the problem.
  • Now was a good time to back up the databases and perform a snapshot.
  • TFS upgrade went better this time, no errors.
  • The virtual servers in IIS were wiped and reset, which was a bit of an issue. We were running on https port 8088. Adding the cert back was easy, as was changing the port, however, there are several places that need to be updated to point to the correct url and port. I was getting 503 and general asp.net errors.
  • Edit app.config in E:\Program Files\Microsoft Visual Studio 2008 Team Foundation Server\TfsScheduler
  • Edit URLs web.config in E:\Program Files\Microsoft Visual Studio 2008 Team Foundation Server\Web Services
  • Update TfsIntegration.dbo.tbl_subscription. There were 4 new rows for the default URL. I removed the 4 new rows.
  • After updating the config files, TFS started working again.
  • I noticed that there was a lack of commands available from the source explorer view on machines that only have VS 2005.This didn't seem to have an impact for the 1 day that TFS was running.

TFS Install

  • Install TFS 2008 to E:\...
  • Install TFS 2008 Team Explorer to E:\...
  • Snapshot
  • Copy TFS databases to new TFS server
  • Started out by following instructions on how to move from 1 server to another server.
    • Use RSKeyMgmt -l to generate Reporting Services Accounts, there was 1.
    • Stopped TFS Scheduler and WSS Timer services
    • Stop the SQL Server that Reporting Services was running on, which is the only sql server on the box.
    • Restore TFS, ReportServer, and Sharepoint databases to SQL 2005 (I would suggest scripting this out so you can easily re-run the next time thru).
      • Databases
        • ReportServer
        • ReportServerTempDB
        • STS_Content_TFS -> WSS_Content
        • TfsActivityLogging
        • TfsBuild
        • TfsIntegration
        • TfsVersionControl
        • TFSWarehouse
        • TfsWorkItemTracking
        • TfsWorkItemTrackingAttachments
      • The only tricky one was the sharepoint content database as the name changed. I used the following T-SQL:
        RESTORE DATABASE [WSS_Content] FROM  DISK = N'E:\Temp\TFS\STS_Content_TFS_backup_200710201600.bak' 
        WITH  FILE = 1,  MOVE N'STS_Content_TFS' TO N'E:\Program Files\Sql\MSSQL.1\MSSQL\Data\WSS_Content.mdf',  
        MOVE N'STS_Content_TFS_log' TO N'F:\SqlLogs\WSS_Content_log.LDF',  NOUNLOAD,  REPLACE, STATS = 10
        GO
  • Change the connection string in %TFS%\Web Services\Services to have the name of the old data tier server name. The TFS admin tool for renaming expects this.
  • Use the TfsAdminTool to execute the RenameDT function.
    • Started getting errors saying that the tool could not connect to the database.
    • Tried allowed named pipes, and changed the name of the database in the web.config file. Named pipes didn't work, and I got an error saying I need to use the old data tier name (as expected) with the new name in the web.config file.
    • SQL Profiler showed that tfsAdminTool was not connecting.
    • Event logs were clean
    • Turned off windows firewall
    • Tried renameDT localhost
    • Using reflector to inspect TfsAdminUtil and related assemblies, it looks like it's trying to make a call to the old TFS server's Reporting Services web service so that it can update connection string info on the new service. The new TFS server does NOT have access to the old server so this obviously is not going to work.
    • Using reflector, identify changes made during a RenameDT operation and make those changes manually
      • Update connection strings in Reporting Services Data Sources. I'm going to wait until I am instructed to turn RS back on, then go in thru the web interface to upgrade the data sources. They are stored as binary data in the DB.
      • Update the web.config file we changed above
      • Grant login access to service account (which was done by the TFS setup on the new server before we even tried to rename the data tier)
      • Update tables by calling stored procedure prc_update_database_servername, which I can't look at, but can manually execute by passing the old server name and new server name to. This is in the TfsIntegration database.
        • When executing I got 1 row affected. I guess I could have ran sql profiler to see what it did. For sure, it update tbl_database.servername.
      • TfsIntegration.dbo.tbl_subscription. Update address to http://datfsp100:8080/*
  • Ran "tfsAdminTool ActivateAT newApplicationTierServerName" to "change" the name of the application tier to the new server name. This completed the first time without errors.
  • I'm now up to the part that deals with user accounts for users and services. Since the new TFS server is on a completely different domain, all of the account names are different. This was one of the steps that worried me from the start. I'm not sure what I need to do to restore my server to an operational state. Adding a bunch of throw away accounts isn't appealing. I'm going to go back to Reflector to see what the TfsAdminUtil is doing for this step.
    • It looks like it calls a stored procedure prc_security_update_sid, which I think updates tbl_security_identity_cache.
    • I went ahead with the instructions. There was an error, but the instructions said this was to be expected.
    • I didn't have a service account for reports, so I skipped that step.
  • The step to remove and re-add the content database failed. This is possibly due to mis-matched schemas.
  • Clean up Reporting Services
    • Update DataSources
    • Add tfsReports account to TfsWarehouse TfsWarehouseDataReader role.

Current Status

  • TFS work items and source control are working, however all of the work items need their assigned user updated. While source control works, users and their machines that had connected to the old TFS Server, have conflicting workspaces.
  • Reporting Services works, but none of the reports will run due to some type of login/permission error.
  • SharePoint isn't doing so well, as the content database can not be restored.

Stay tuned for my follow up post.

Resources

Monday, October 22, 2007 12:43:26 AM (GMT Daylight Time, UTC+01:00)  #    Comments [0] -
Technology
# 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
# Saturday, October 06, 2007

PolyMon is an open source agentless monitoring application written in the .Net Framework, and available, with source on CodePlex. It is designed as a client/service/server architecture, consisting of a WinForms management application, Windows Service monitoring engine, and uses SQL 2005 for it's data store. I have written about Polymon before in my post about Network Monitoring, so you should check that out for some more details. I will re-iterate the available monitors here.

  • CPU
  • Disk
  • File (Age and Counts)
  • Windows Performance Counters
  • Ping
  • PowerShell Scripting
  • SQL Monitor via Stored Procedures
  • SNMP
  • TCP Port
  • URL
  • Windows Service Monitor
  • WMI Monitor

I set this up at home, with limited success, and at work (to monitor dev and test instances) with better success. The only difference between the 2 installs is I'm using integrated authentication at home, and SQL authentication at work. I've noticed some other issues with domain authentication at home, so I feel that it's an AD issue at this point, and not a problem with Polymon, although there may be the opportunity for more robust error logging in Polymon if this turns out to be the case.

I setup Ping and SQL monitors based on our production monitoring system at work, and only had to monitor the SQL monitors slightly to support Polymon, which requires two output parameters defined in the stored procedures. I wanted to setup the WMI and Powershell monitors in place of some of the custom SQL monitors, but didn't have the time. I've added some links at the bottom to BizTalk Powershell resources for future reference.

Pros:

  • Free and Open Source
  • Actively Developed with a road map that makes sense
  • Extensible without modifying the core application
  • Little need to extend given the excellent coverage provided by the default monitors, especially PowerShell
  • Runs on SQL 2005, so you get all of the benefits of SQL 2005, plus you could write custom reports in Reporting Services and have those emailed.
  • Monitor not just uptime, but other stats as well. For example, response times are logged, and the SQL monitor supports returning

Cons: 

  • Monitoring Engine is not multi-threaded - If you had 61 monitors set to run every minute, and they all took 1 second, you would start to see lag. This is a know limitation and can be worked around by not having that many monitors set to run that often. It is on the development roadmap for the project, and is going to be addressed in two ways. The first is to multi-thread the monitor engine, which will allow scale-up. However, any good developer would know that just multi-threading is not the end all solution, and you could run into additional limitations as a result of running multiple threads. Therefore, the second part is to allow monitoring engines installed on separate computers, to run off the same database, effectively adding scale-out capabilities. Another possible benefit to this, is it would allow you to install the service on the servers you want to monitor and not have to deal with as much security. However, this would be the same as a monitoring application that requires an agent.
  • Database can grow large very quickly, which can also slow performance. You need to use some common sense, set appropriate retention policy, and possibly re-index to meet your individual needs.
  • No web interface. I actually like the WinForm application, but can also see were a web app would have it's advantages. There is a plan to replace the WinForm application with a Web Application. I'd like to see both, but can understand limited resources.
  • No Operator Groups - Operators are defined individually. However, if you have a distribution list setup, it makes it a little easier.
  • Only Email Alerts
  • No email of reports that I can see, however, this could be considered a Pro, as you could use SQL Reporting Services to make your own reports
  • Remote connections for monitors represent administrative and security considerations. For example, you need port 1433 open to make remote sql connections, WMI does not look very administrator friendly for remote connections, and the same would apply to WMI thru power shell. This is a limitation of the technologies themselves, and not Polymon, but worth pointing out.

Links

Saturday, October 06, 2007 11:12:22 PM (GMT Daylight Time, UTC+01:00)  #    Comments [0] -
Review For Future Projects | Tools
# Thursday, October 04, 2007

Just a quick post about a project called Rifidi, an open source project developed by Pramari and the University of Arkansas. Rifidi allows you to simulate how RFID would affect your processes using a graphical interface. I've only had the chance to do a quick once over of the web site, but it defiantly looks interesting. While I don't know if it will have an immediate impact on my current project, it may in the future.

Almost more interesting, is in the programming behind the simulation, and the fact that it is open source. Pramari is characterized as a "world leader in open source RFID software" in the press release, so I will defiantly be checking out their web site to see what they offer.

Thursday, October 04, 2007 8:12:38 PM (GMT Daylight Time, UTC+01:00)  #    Comments [0] -
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
Archive
<October 2007>
SunMonTueWedThuFriSat
30123456
78910111213
14151617181920
21222324252627
28293031123
45678910
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 2010
Adam Salvo
Sign In
Statistics
Total Posts: 251
This Year: 26
This Month: 0
This Week: 0
Comments: 34
Themes
Pick a theme:
All Content 2010, Adam Salvo
DasBlog theme 'Business' created by Christoph De Baene (delarou)