I needed to change a bunch of project references such that they referenced a different location so that I could provide a solution to a 3rd party for a review. The idea of going thru 20 some projects and removing and re-adding the references was not appealing, so much that I thought about writing an application. I've learned my lesson though, and decided to Google to see if something was already written, and came across Cool Commands. Cool Commands was written by Gaston Milano of Deklarit. It's a very good plug-in, it just doesn't have much documentation, and since the tool is free, I'm not complaining. Install I was unsure how to install the plug-in, as there is no documentation, other then to unzip and run the setup.bat from a VS command prompt. - Download Cool Commands from this Direct download link
- UnZip - I unzipped to %MyDocuments%\Visual Studio 2005\AddIns\CoolCommands. I would suggest unzipping to a permenant location, and not a temp folder.
- Open up VS 2005 command prompt (you must run this as an administrator)
- Navigate to where you unzipped Cool Commands and run Setup.bat.
- The step where devenv /setup is run, took about 1 minute to run on my computer, so you should expect this.
- Start up VS 2005 and load a project to test it out.
- Review this blog post for a good overview.
Summary While commands does not have a find and replace reference, which is what I exactly needed, the global remove and add reference was close enough. Also, all the extra features more then made of for the lack of an exact solution. Tempting fate, I decided to try installing Cool Commands for VS 2008. I copied cool commands to by Addins folder under 2008 and ran the setup from a VS 2008 command prompt, which succeeded without error. However, non of the options are available in the context menu, so it looks like it needs to be updated for VS 2008. References
I was doing some Google searches for more information on Linq and SqlCe 3.5 this morning. While I knew you could use the SqlMetal command line utility to get Linq to Sql Support for SqlCe 3.5, I made an incorrect assumption that Linq to Sql was available on the compact framework. For the love of god, could Microsoft please release a Compact Framework builder, akin to platform builder for Windows CE. For smart phones and other off the shelf devices, keep an official CF release, but for those of us writing applications bundle withed devices, let us determine what we need, and do not need in the compact framework.
Anyway, during my search, I came across Dan Vanderboom's blog. Dave is a Windows Mobile developer and shares some of the same pain that I do. He has alot of good information, and is currently working on a enterprise manager like application for SqlCe running on devices, but will not require active sync.
Thanks to Dave, I found 2 new applications for my smart phone.
- Task Manager - The name is somewhat deceiving, as it is allot more then just a task manager. You can view processes, window handles, device drivers, edit the registry, view network stats and more.
- WiFiFoFum - War driving application for the Pocket PC.
While searching for WSS 3.0 SP1 I came across a download for some SharePoint templates. I am impressed by the list at least, and if they work as good as they sound, they could replace some existing systems someday. I found a site that has allot of the templates installed and available for demo. Server Admin Templates: Server admin templates are created as site definitions, providing tighter integration and enhanced functionality within the Windows SharePoint Services platform. They will require a server administrator to install. If you do not have Central Server Admin rights, you can still install the site admin templates (see second list below) in the sites/workspaces that you own or administrate. - Absence Request and Vacation Schedule Management
- Help Desk
- Budgeting and Tracking Multiple Projects
- Inventory Tracking
- Bug Database
- IT Team Workspace
- Call Center
- Job Requisition and Interview Management
- Change Request Management
- Knowledge Base
- Compliance Process Support Site
- Lending Library
- Contacts Management
- Physical Asset Tracking and Management
- Document Library and Review
- Project Tracking Workspace
- Event Planning
- Room and Equipment Reservations
- Expense Reimbursement and Approval Site
- Sales Lead Pipeline
Site Admin Templates:Site admin templates are easy for site administrators to install in a template gallery without requiring server administration access. - Board of Directors
- Employee Training Scheduling and Materials
- Business Performance Rating
- Equity Research
- Case Management for Government Agencies
- Integrated Marketing Campaign Tracking
- Classroom Management
- Manufacturing Process Management
- Clinical Trial Initiation and Management
- New Store Opening
- Competitive Analysis Site
- Product and Marketing Requirements Planning
- Discussion Database
- Request for Proposal
- Disputed Invoice Management
- Sports League
- Employee Activities Site
- Team Work Site
- Employee Self-Service Benefits
- Timecard Management
Let this be my first post in my new Windows CE category. I have a feeling I will be writing more stuff about WinCE in the coming months. I wanted to jot down some notes from a couple of articles I read over at OpenNetCF for future review. Most of the high level concepts I already knew, but it's nice to get some details once in a while. Data Caching - No performance gain in keeping the data connection open for the life of an application.
- Cache reads are two orders of magnitude faster then a database read. As the article points out, this is interesting due to the fact that the database, and cached data were both stored in RAM.
- Several of the reader comments were interesting
- The first time a SqlCE Connection is opened, the database is loaded into shared memory
- One option is to have a connection opened for the life of the application, but not to use it, this is just to keep the engine loaded. Then open/close connections in your DAL as you normally would. This was recommended by Steve Lasker, a member of the SQL CE dev team. Steve also points out that reusing a command object and changing the text code hurt more then help, as you can't take advantage of query plans. Reusing a command object can sometimes help with the garbage collector.
- Another reader provided a example where it looks like he is doing an index scan and getting faster results then directly querying the database. It's hard to tell without running the sample code.
Garbage Collector - GC suspends all threads while it performs necessary actions, such as freeing and moving memory. Frequent GC's can have an adverse affect on performance.
- Remote performance monitor, which I blogged about before, is a valuable tool. This article provides a good example of how to interpret some of the numbers.
- Don't fear the GC, and take the time to understand what the numbers in remote performance monitor mean.
I'm also in search of a decent MVC and IoC framework for Windows CE. I'll probably be posting more on this later.
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.
Damon Payne put up his goals for 2008 and I decided to post my own. This is the first time I've ever written down goals for a new year, so we'll see how well I actually follow thru on them. I guess that's a goal in and of itself, to report back on my progress throughout the year and write something up on December 31 2008.
Programming, Architecture and Professional Development
- Continue to blog, increasing the quality of my posts (Work in Progress)
- Read at least one book on programming and/or architecture. Apply what I learn to projects I am working on and blog about this. (Need to identify books)
- Start working on one or more personal projects I have been kicking around. The main purpose of these projects is to apply learnings from numerous resources (articles, blogs, books etc), as well as try out new techniques/technologies (IoC, Asp.Net MVC, Linq, MS Sync Runtime) and tools (NDepend, VS Team System). (Work in Progress, need to setup proper home development environment)
- Present at one Madison .Net User Group meeting, most likely on one of the above, or on a project from work. (Identify possible topics)
Investing
- Learn the fundamentals of long term investing (Started)
- Put in the proper time to research new investments (Work in Progress)
Personal Development
- Continue with my studies of Martial Arts, and improve
- Continue playing, and improve at Roller Hockey
- Start learning Japanese
Stuff on the Periphery
- Purchase a Katana and take classes on how to use it
I don't know, it may be too much, but only time will tell. Thankfully, there is allot of overlap, and I've some of the 2008 goals were "goals" from 2007.
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:
Yesterday, a co-worker of mine passed on a link for the Microsoft Sync Runtime, suggesting that we may be able to leverage it in the future in order to meet some requirements we have on our project. Microsoft Sync Framework is a comprehensive synchronization platform that enables collaboration and offline access for applications, services and devices. It features technologies and tools that enable roaming, sharing, and taking data offline. Using Microsoft Sync Framework, developers can build sync ecosystems that integrate any application, with any data from any store using any protocol over any network. Reading thru the initial article, I was quite impressed, but it left out a key piece of information, how does the sync runtime work over the Internet. Not just the internet, but also any decent corporate network were clients do not have direct database access. I made my way to an overview of the Sync Services for ADO.Net, which is what I would be most interested in (although syncing file systems has an interesting appeal as well), and they clearly showed the Internet cloud, but not really how the sync framework worked with it. I actually had to dig into the documentation, and finally found some details on how to get this to work on the Internet. If you read towards the bottom of the documentation, you can see that you implement a proxy on a middle tier. On the middle tier, the service inherits from and exposes the same methods as ServerSyncProvider (the abstract class from which DbServerSyncProvider inherits). The methods are then executed by the application code over a direct connection to the server database. The results are routed through the middle tier and back to the client. Basically the middle tier exposes the same interface that the client application would normally use if it could connect directly to the database. There was a link which gives a specific example of setting up a n-Tier environment and provides a good start. However, I could not find exactly what I was looking for, which was an example of using WCF as the transport mechanism. With WCF I could have 1 middle tier service with multiple end points configured, such as a Basic Http for Internet, and TCP for intranet. WCF also adds support for encryption and authentication, which I didn't see called out specifically in the sync runtime. Other items of interest include, how to setup a database for different sync scenarios, and peer to peer synchronization. All in all, the Sync runtime looks like a very promising framework for building disconnected applications. It will require some re-architecting for existing solutions, specifically the data store, but it might be worth it in the long run. I will be sure to post updates if I get a chance to play around with it at all. It is defiantly something that would save me some time on a side project I am hoping to start working on soon.
Just when I thought I was on a roll, my unit tests stopped working, all of them. At least when they all fail, and fail in the same way, you know it's not your code that's causing the issue. Switching to running the unit tests in debug showed that they were failing when I was trying to leave the service domain as part of my "database rollback" functionality (idea and code I based my work off of was from a 2004 MSDN article), which uses Enterprise Transactions. I had a previous issue with MS DTC and my unit tests, but this is different. No helpful messages in the event log (first place I looked this time) on my development server. My laptop, where I am running the unit tests from, have a couple of entries for DistributedCOM but they are kind of vague. I decided to jump over to dtctester and see what that showed. It hung on "Enlisting Connection in Transaction" for at least 1 minute (I left to get a soda) before finishing. The most recent changes I've made to my development server are: - Upgrade to BizTalk 2006 R2
- Install .Net Framework 3.5 RTM
- Install Windows Server 2003 SP2
My bet is on a fix in SP2, or the SP2 installer resetting the MS DTC configuration. I found an excellent MSDN article on trouble shooting MS DTC in an effort to verify how I should have MSDTC configured, specifically the security settings. I noticed that mutual authentication was required, and from previous issues with DTC and the fact that my machines are not on a domain, I set this to no authentication and tried again, no go. I did find a new entry in the application event log on the dev server which seems to point with an issue on the dev server itself. MS DTC is unable to communicate with MS DTC on a remote system. MS DTC on the primary system established an RPC binding with MS DTC on the secondary system. However, the secondary system did not create the reverse RPC binding to the primary MS DTC system before the timeout period expired. Please ensure that there is network connectivity between the two systems. Error Specifics:d:\nt\com\complus\dtc\dtc\cm\src\iomgrsrv.cpp:1318, Pid: 2728 No Callstack, CmdLine: C:\WINDOWS\system32\msdtc.exe Nope, it wasn't the dev server. I decided to run dtctester on 2 other computers and they both passed. The first time I ran the tool on one of the computers, I got an error that was very similar. The only difference was the native error. On my laptop (Vista) the native error is -2147168242 and on the other computer it was -2147168220. The issue on the other computer was that I had not setup DTC for network communication. So now I knew it was an issue with my laptop, which is running Vista. A couple of things I've done recently were: - Remove VS 2008 Beta 2 and all related components and install RTM
- Install various updates from Windows Update
- Installed VPN software
- Was playing around with network settings trying to get wireless working at my parents over the holidays
- Uninstalled and reinstalled newer version of VMWare
I know I had problems with the firewall before, so I turned off the Vista firewall, and success, dtctester passed. En-enabling the firewall caused the dtctester to fail again. In the simple firewall UI, distributed transaction coordinator was selected. I went back and looked at a post I wrote on our internal network, and I had mentioned that the VMWare network adapters change the zone that the firewall thinks you are in. Well, I was in the public zone, and couldn't change it. There should have been a Customize option on the Network and Sharing center. I remembered that I had gone into Services, and disabled some that I "thought" I could do without. One of them was Network Location Awareness, which caused Network List Service to fail to start. Once those 2 were running, the firewall knew I was on the private network, and DTC worked again. My firewall exception was for the private network only. Wow, that was a trip. Download MS DTC Tester: http://support.microsoft.com/default.aspx?scid=kb;en-us;293799
So I was updating another computer from Visual Studio 2008 Beta 2 to RTM over Christmas and noticed something during the install process. You know, the install process, where they show pictures of people I never saw in my computer science classes, interviewed, or seen at any of development/industry events. Got to love marketing. Back to what I saw though, the Sql Publishing Wizard. A quick Google search showed me this was previously an add in which has made it's way into Visual Studio 2008 as a default component. You can download and read about it on CodePlex. From the home page on the CodePlex, the Sql Publishing wizard supports two modes of operation: - It generates a single SQL script file which can be used to recreate a database when the only connectivity to a server is through a web-based control panel with a script execution window.
- It connects to a web service provided by your hoster and directly creates objects on a specified hosted database
I tested out the single SQL script mode on our new database, which is quite complex and has challenged other scripting tools. I am extremely happy to report, that the single generate script reproduced our database perfectly. What's even better, is that it is an open source project, so you can make some changes, maybe add some schema object filters, or separate the objects into separate files.
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.
|