While in search of the Windows Live Hotmail for Outlook Connector (future blog post in the works), I found a small add-on that enables the ability to save office documents as PDF (or XPS). The add-in adds a new option under “Save As”, and worked well in my limited testing. This works different from other PDF utilities, in that it does NOT install a virtual printer driver. The add-in is limited to the following programs, and sadly, outlook is not one of them, but all the other major office applications are: - Microsoft Office Access 2007
- Microsoft Office Excel 2007
- Microsoft Office InfoPath 2007
- Microsoft Office OneNote 2007
- Microsoft Office PowerPoint 2007
- Microsoft Office Publisher 2007
- Microsoft Office Visio 2007
- Microsoft Office Word 2007
Remember, you access this add-in by going to “Save As”, not Print, like you may be used to for other PDF utilities. OneNote adds a new option under File, other applications may differ as well. Info and Download:
I’ve decided to add a new non-technology related category to my blog, simple titled Fitness. I plan on blogging about various fitness activities I do, such as running, biking, swimming, general workouts at Monkey Bars, Ju-Jitsu, and race training. I should have started this in the spring, as I’m not sure how much interesting stuff I will do over the winter, but I have to start sometime. Today I did my second 40+ mile bike ride, basically to set a baseline for next season. Like last week, I did one time around the Ironman Wisconsin loop (Verona –> Mt. Horeb –> Cross Plains –> Verona). You can view this route on MapMyRide by clicking on this link. Today’s Status: Time: 2:25:07 Miles: 42.8 Avg Pace: 3:23 min/mi Avg Speed: 17.7: mi/hr Avg HR: 139 bpm Approx Calories Burned: 2072 This weeks ride went allot better, although it’s hard to say why. It was about 10 degrees cooler, and cloudy this week, I’m two weeks past the head cold I had instead of one, and of course I have the experience and training effort from the previous week. I didn’t ride the early hills as aggressive in an effort to save the legs, and I think it paid off. Last week I could barely make it back to my car, and was extremely sore, this week, I feel like I could have made it around a second time, albeit slower. I think this will provide a good baseline for when I start up again next season. I also ordered a RoadId for me and the wife. While I bring my drivers license with me, I can’t really attach it to me like the RoadId, so I have a lot better chance of it staying with me in a really bad crash or accident (knock on wood). One thing I really took away from being an Eagle Scout was “Always Be Prepared”, and for $19.99, this was just something I couldn’t pass up on.
The SharePoint site I am responsible is pretty small and not used by allot of people. However, that is soon to change, as I am adding allot of content to the Wiki library for technical support and trouble shooting, and I wanted to make use of the search functionality to allow people to search for content. So I went to the search bar, and received an error message indicating that “Your search cannot be completed because this site is not assigned to an indexer. Contact your administrator for more information.” I always find it troubling when an error message says to contact me. I started doing some searching online and made my way to the Central Administration Portal Page for our SharePoint Server. I found that you need to assign your content database to a search server, so I went to Application Management\Content Databases, selected by one and only content database, and saw that they drop down box used to select a search server was greyed out, how unfortunate. Some more on the job training led me to Operations\Services on Server, where I saw that I was missing the “Windows SharePoint Services Search” service. Looking at the services applet under administration tools, I saw that I did have a “Windows SharePoint Services Search” service installed, and after configuring it to log on as Local System, I was able to get it started. However, I couldn’t get it to show up as a service in central administration. I read a couple of posts online about re-running the Sharpoint configuration wizard, so I thought I would try that. Under Start\Programs\Administrative Tools, there should be a short cut for SharePoint Products and Technologies Configuration Wizard. After starting this application, I was prompted to change various aspects of my SharePoint installation. I choose to keep everything the same. I was a little disappointed in that I didn’t see any options for adding SharePoint search, but after the wizard completed, and I went back to Operations\Services on Server, I had “Windows SharePoint Services Search” now listed, but stopped. I’m wondering if restarting the IIS Application Pool for my SharePoint server, or the Windows SharePoint Services Administration service after starting the Windows Sharepoint Services Search service would have yielded the same results? Back in Central Administration, I clicked on the Start link in an attempt to start the Search service, but was redirected to a configuration page. On this page I was prompted to select a Service Account, Content Access Account, Search Database, and Indexing Schedule. - Service Account: It specifically says you can not use a built in account, such as Local Service or Network Service.
I choose to use a domain service account that I used for some related services on this server. This account should be the same account as the Content Access account (read my section below about the content sources cannot be accessed error) - Content Access Account: This account should be separate from the service account and only have read-only access to the content database. I decided to create a new local account to achieve this. I made this account a member of the Guests local group, and added it to the data_reader role in the content database.
- Search Database: Accepted Defaults
- Indexing: Accepted default value of every 5 minutes to start, and then I went back and changed it Daily between 3-4 am.
After clicking start, the page took awhile to redirect, but I didn’t get any errors or warnings. I checked the Search service, and as I assumed, the log on account was changed to the domain account I specified. I also had a new database named WSS_Seach_ServerName, so it looks like things were at least setup correctly. Jumping back to Application Management\Content Databases and selecting my lone content database, I was now able to select a search server. Running a search on my SharePoint site seemed to work, although no matches were found, which could be because the indexed had not run yet. Five minutes later, and still no search results for obvious terms. In the Timer Status page on Central Administration, I could see that the Search Process was running every five minutes, so I went to the application log figuring errors would show up there. Sure enough, I was getting “The update cannot be started because the content sources cannot be accessed.” every five minutes. Checking my database permissions, I see that my service account has dbo permissions to the content and search databases. My content serach account, has data reader permissions to the content database (which I added previously), and dbo permissions to the search database (added automatically during setup it seems). Back to Google. I found a discussion thread where someone stated that the Service Account and Content Access Account need to be the same, and re-affirmed the requirement that the account used only have read only permissions. So I went ahead and stopped the search service via Central Administration, deleted the search database, and then reconfigured and started the search service. The search database was re-created, and I noticed that my processor pegged at 100% for awhile and my search database grew in size from 4mb to 31 MB indicating that something actually got put in it. Since I had stopped and reconfigured the search service, I had to reselect the search server for my specific content database under Application Management like I did before. After waiting five minutes for the indexing to run, I was getting search results.
Today, Jeff Atwood posted about a deadlock issue he was having. He had a couple of ideas as to how to solve his issue, including the nolock statement. What I found most interesting were the comments that followed. Here is a summary: - SQL Server sucks
- NoLock is ok
- NoLock is a hack
- I can’t believe you don’t/didn’t know how to fix a dead lock
I can’t believe how critical people were of Jeff. I guess I was a little surprised that the author of the great Coding Horror didn’t know the answer to something, but that’s no reason to be critical of the guy. A couple of the more decent links included: We have a couple of deadlock issues in our current database that I’d like to sit down and fix, so these might come in handy. Update: Someone who knows allot more about SQL posted a blog entry in response to Jeff’s original post. The author believes that using nolock is never a good idea and goes on to give some advice on how to start solving deadlock issues.
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: - It’s support by Microsoft, and as such, will gather much momentum and community support
- It’s good enough for X% (usually stated as greater then 50%) of software projects out there.
- GUI editor/mapper makes it easier to use then other ORM tools like nHibernate
- EF is part of a larger push by Microsoft to provide technologies that focus on an Entity Model (See Ado.Net Data Services)
Cons: - No support for POCO’s and Persistent Ignorance
- Hard (or impossible) to develop using a Domain Driven Design, or Test Driven Design methodology
- Single model/mapping file introduces merge conflicts in a source control environment
- 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. - 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).
- 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.
- 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.
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.
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.
I spent the last day and a half trying to figure out why a query using FOR XML AUTO was returning the wrong result set. Some background is in order. I’m migrating a database from SQL 2000 to SQL 2005, as well as running the same database created from scripts on SQL 2005 but in a different environment. Both databases contain the exact same SQL in the stored procedure that was the source of the problem, but they were returning different result sets. I even restored the database that worked to the server that had the non-working database and saw that the database created from scripts was still working as expected. I figured there was a database level setting causing the issue, so I opened up the database properties for both databases and compared them side by side, except I missed the 3 drop down boxes at the top, specifically the compatibility mode. I finally decided to run the SQL 2005 Update Advisor, which comes on the install media, or available online as a download. After about 10 minutes of checking my database (it was across a remote connection), it found the exact problem I was having, and the fix was to get rid of my derived tables, or set the comparability mode to 90. From the Upgrade Advisor help, here is an example of my original problem. Consider the following table: CREATE TABLE Test(id int);
INSERT INTO Test VALUES(1);
INSERT INTO Test VALUES(2); Now run this query, which produces different results under different compatibility levels. SELECT * FROM
(SELECT a.id AS a, b.id AS b
FROM Test a JOIN Test b ON a.id=b.id)
AS DerivedTest
FOR XML AUTO;
Under Compatibility Level 80 you get:
<a a="1"><b b="1"/></a><a a="2"><b b="2"/></a>
Under Compatibility Level 90 you get:
<DerivedTest a="1" b="1"/><DerivedTest a="2" b="2"/>
The XML under Level 90 is what I was looking for. Remmeber, under SQL 2000, the same query worked fine, it was only under SQL 2005 with Level 80 that I started having problems.
Of course after switching to level 90 I found another bug, and wouldn’t you know it, the compatibility wizard told me about this one as well, I just felt like ignoring it at first. This time it was a problem with a table prefix in an order by clause. Funny thing is, the table prefix didn’t even exist in the stored procedure, but under SQL 2000 it worked fine. Turns out someone else had already fixed the issue in the SQL 2005 version.
While looking for the stored procedure in error (since at first I ignored the warning in the upgrade advisor which even told me what stored procedure), I found a quick way to search stored procedures and functions in SQL 2005. SELECT ROUTINE_NAME, ROUTINE_DEFINITION
FROM INFORMATION_SCHEMA.ROUTINES
WHERE ROUTINE_DEFINITION LIKE '%SearchString%'
Lesson of the day, try using and paying attention to the tools that Microsoft gives you.
Late last year I posted briefly on the SQL Publishing Wizard. I haven’t had a need for this since I reformatted and installed Server 2008 64 bit as my main workstation at work, and wouldn’t you know it, it’s not there now. As usual I headed off to Google and found some posts that pointed to this install path, C:\Program Files\Microsoft SQL Server\90\Tools\Publishing\1.2. Seeing as I am running a 64 bit Windows OS, my path is actually C:\Program Files (x86)\Microsoft SQL Server\90\Tools\Publishing\1.2. Now you could just run SqlPubWiz.exe, or run the VSInt.reg file to add the context menu option in Visual Studio 2008. Not so fast, the registry file doesn’t seem to work as is on a 74 bit OS due to the new subkey, Wow6432Node. I modified VSInet.reg to include the keys the Wow6432node, and in the end got my Publish to Provider context menu option back. Windows Registry Editor Version 5.00 [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VWDExpress\9.0\Menus] "{40d75537-ce10-4311-a7b0-6b164d80405d}"=",1000,1" [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\9.0\Menus] "{40d75537-ce10-4311-a7b0-6b164d80405d}"=",1000,1" [HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\VWDExpress\9.0\Menus] "{40d75537-ce10-4311-a7b0-6b164d80405d}"=",1000,1" [HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\9.0\Menus] "{40d75537-ce10-4311-a7b0-6b164d80405d}"=",1000,1"
|