Jan 12 2012

SharePoint 2007 Error: The type or namespace name 'Publishing' does not exist in the namespace 'Microsoft.SharePoint' (are you missing an assembly reference?)

Category: ASP.NET | SharePointDavid @ 19:06

If your looking for the solution to the above error in SharePoint due to the use of the SPUrlExpressionBuilder (SPUrl) you will want to try a couple of things. The first is to include the following page declarations in the MasterPage if you have not already. 

<%@ Register Tagprefix="PublishingWebControls" Namespace="Microsoft.SharePoint.Publishing.WebControls" 
Assembly="Microsoft.SharePoint.Publishing, Version=12.0.0.0, Culture=neutral,
PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="PublishingNavigation" Namespace="Microsoft.SharePoint.Publishing.Navigation"
Assembly="Microsoft.SharePoint.Publishing, Version=12.0.0.0, Culture=neutral,
PublicKeyToken=71e9bce111e9429c" %>
<%@ Register TagPrefix="PublishingVariations" TagName="VariationsLabelMenu"
src="~/_controltemplates/VariationsLabelMenu.ascx" %>
<%@ Register Tagprefix="PublishingConsole" TagName="Console" src="~/_controltemplates/PublishingConsole.ascx" %> <%@ Register TagPrefix="PublishingSiteAction" TagName="SiteActionMenu"
src="~/_controltemplates/PublishingActionMenu.ascx" %>

If you continue to get the above error you might be having the issue that I ran into where I was using the SPUrl inside of an ASP.NET User Control.  This has to do with the way that the User Control and MasterPage are parsed.  The User Control is parsed by ASP.NET first prior to the MasterPage.  This means that the declarations in the MasterPage are not present for the User Control.  The solution is to also include the above declarations in the markup for the User Control. Including the declarations in the User Control insures that the SPUrl tag prefix has been registered prior to the parsing of the expressions that use it.


    

Tags: ,

Sep 30 2011

Getting C# Source Code From a COM Interop Assembly With ILSpy

Category: .NET | Tips & Tricks | COMDavid @ 15:43

Many of you were no doubt ticked when RedGate decided to stop providing Reflector as a free tool.  Well, this post is not designed to harp on that or talk about how Redgate backtracked on that decision.  Instead, let’s talk about a great replacement for it that is free and open source! 

This great new tool is called ILSpy.  It has a great feature that will let you output the disassembly code to actual C# files.  This comes in super handy if you have a COM Interop assembly that you need to modify. I ran into this situation when working on a project leveraging the VirtualBox API.

The great thing is that it is supper easy to do.  Once you open the interop assembly in ILSpy simply select the assembly node in the treeview and then on the File menu select Save Code…  You will then be prompted to save a C# project file.  Once you do that it will generate the project file and will create a .cs file per object  in the assembly.  And that is it!

Tags: , ,

Sep 13 2011

Windows Server 2008 R2 Installation Problem: “Setup was unable to create a new system partition…”

Category: General Tech | Hardware | Tips & Tricks | Windows 2008David @ 02:32

Recently I decided to virtualize all three of the primary servers that I have running on my network.  To do this I decided to install Windows Server 2008 R2 on two new servers.  To save space I chose smaller cases and to save money I left out the optical drives since I have a USB DVD drive that would work for my installations.  In addition I downloaded the latest drivers onto a large flash drive in preparation for the install.

The motherboard that I chose is the MSI 890FXA-GD65 which supports USB boot as well as RAID 0, 1, 5, 10, and JBOD.  So, I chose to run a RAID 1 setup with two disks. After setting the array up in the BIOS I inserted the USB DVD drive, a flash drive with the RAID drivers, and cranked up the machine.  Things moved pretty fast and I landed on the screen for selecting the drive to which I wanted to install Windows.  It was blank and so I simply loaded the drivers from the flash drive and the RAID drive appeared with full capacity.  Normally the next thing you should do is select the drive and hit the next button, but when I did that I got this wonderful error message:

“Setup was unable to create a new system partition or locate an existing system partition. See the Setup log files for more information.”

To make a long story short I had a heck of a time figuring out the cause of my problem.  In the end what worked for me was leaving the USB Flash drive out of the system until I was ready to install the drivers.  I inserted the flash drive, selected “Load Drivers” and when through the browsing, selecting and loading.  Right after the drivers were finished loading I pulled the flash drive and then hit “Next”.  And the rest, as they say, is history…  Windows installed fine from that point on and within about 30 minutes my new server was up and running.

Tags: , , ,

Mar 22 2011

An Old Trick for Speeding up .NET Compact Framework Builds: PlatformVerificationTask

Category: .NET | Tips & Tricks | Compact FrameworkDavid @ 11:48

OK! I know that most new mobile development is occurring on Windows Phone 7, iPhone or Android, but I have no other choice than Windows Mobile 6 for the application I’m currently working on due to customer requirements.  So, here I am stuck back in VS 2008 developing a mobile application for Law Enforcement.  In the past I played around with mobile development in my spare time, but never had to do any long term development for it.  Since starting on this current project I noticed how long it took for my builds to deploy to the emulator and test devices for debugging.  Deployment was taking from a few minutes to over 5 minutes at times.  Well, you know as well as I do what that can do to developer productivity!

Now,  I’m the type of developer that codes a chunk of code, builds, tests, and repeats the process in rapid succession so I was really not having any fun. So to figure out what was going on I set the Build output to “Diagnostic” in my Build options and hit F5.  Well, I noticed that it was hanging on a build task called “PlatformVerificationTask”.  Well, after digging around a little on Bing. I found this old blog post.  The short of it is that the Platform Verification Task does a check on your assemblies at build time to make sure there are no unsupported properties, methods or events in your code.  This process can really slow down the build process on large applications that have multiple DLLs. (Like my project does!)

So, what the solution?  It’s a good ‘ole file editing trick.  All you need to do is edit the file located at %windir%\Microsoft.NET\Framework\v2.0.50727\Microsoft.CompactFramework.Common.Targets and find the node:

<Target
    Name="PlatformVerificationTask">
    <PlatformVerificationTask
        PlatformFamilyName="$(PlatformFamilyName)"
        PlatformID="$(PlatformID)"
        SourceAssembly="@(IntermediateAssembly)"
        ReferencePath="@(ReferencePath)"
        TreatWarningsAsErrors="$(TreatWarningsAsErrors)"
        PlatformVersion="$(TargetFrameworkVersion)"/>
</Target>

 

Add the following attribute to the <PlatformVerificationTask"> node:

Condition="'$(DoPlatformVerificationTask)'=='true'"

Now restart Visual Studio 2008 and check out how much faster your build is!

Tags: , ,

Sep 16 2010

Lecture Series on Technology

Category: General | General Tech | Personal GrowthDavid @ 16:29

For the next 9 weeks I will be teaming up with a friend of mine, Adam Procella, to teach a series of lectures entitled, “Christianity in the 21st Century: A Biblical Worldview of Technology” at Memorial Presbyterian Church on Sunday Mornings.

Adam Porcella is a fellow classmate of mine who is, like me, working toward his Masters degree in divinity (M.Div.).  Adam graduated from Covenant College just outside of Chattanooga, TN with a degree in Philosophy.  Adam has previously co-lectured on Science and Christianity with another very good friend of mine, who is an internationally known astrophysicists, Dr. A.J. Poelarends.

In this series, Adam and I will cover some of the basic ground work toward a Philosophy of Technology and will also discuss how our life of faith intersects with Technology.  It is designed to help construct a basic framework for thinking critically about technology in general as well as Information Technology in particular and how our daily lives as Christians impact and are impacted by technology.

We will cover a number of topics and  areas that will include to a lesser or greater extent the following:

  1. A History of Technology
  2. Toward a Philosophy of Technology
  3. Social Networking and Relationships
  4. Identity and Technology
  5. Video Games and Virtual Reality

Last week was the initial introduction to the series.  This week I will be presenting a lecture entitled: “A History of Innovation: Toward an Understanding of the Nature and Course of Technology.”

I hope to have a running series of blog posts related to this that I will post on my other blog (technologian.us) which will be less technical than this one and geared more toward things such as what will be contained in the lecture series.  If you are interested or want more info on this lecture series then shoot me an email.

Tags: , ,

Sep 16 2010

Visual Studio 2010 Web.config Transform adds unwanted linebreaks and whitespace

Category: .NET | ASP.NET | Visual Studio 2010David @ 11:12

One of the cool features in Visual Studio 2010 in the new web.config transform functionality for “automagically” changing the values in your web.config file based on your deployment scenario.

I’ve been working with this new feature now for a bit and just ran into an issue that was completely unexpected.  In one of my web applications I have an application setting that hold a filepath.  When I moved to using the web.config transform I encountered a bug where extra linebreaks and whitespace gets inserted into the body of the Value node for a given application setting.

Here’s an example of what you might have in you web.config file to begin with:

   1: <configuration>
   2: ...
   3:     <applicationSettings>
   4:       <MyApp.Properties.Settings>
   5:         <setting name="LocalFilePath" serializeAs="String">
   6:           <value>C:\temp</value>
   7:         </setting>
   8:       </MyApp.Properties.Settings>
   9:     </applicationSettings>
  10: ...
  11: </configuration>

And lets say that you have the following in your Web.Release.config transform file.

   1: <configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
   2:     <applicationSettings>
   3:       <MyApp.Properties.Settings>
   4:         <setting name="LocalFilePath" serializeAs="String" xdt:Transfrom="Replace" xdt:Locator="Match(name)">
   5:           <value>D:\MyAppWebRoot\Files</value>
   6:         </setting>
   7:       </MyApp.Properties.Settings>    
   8:     </applicationSettings>
   9: </configuration>

After you publish the site and examine the the changes to your web.config file you will discover it looks like this:

   1: <configuration>
   2: ...
   3:     <applicationSettings>
   4:       <MyApp.Properties.Settings>
   5:         <setting name="LocalFilePath" serializeAs="String">
   6:           <value>
   7:           D:\MyAppWebRoot\Files
   8:           </value>
   9:         </setting>
  10:       </MyApp.Properties.Settings>
  11:     </applicationSettings>
  12: ...
  13: </configuration>

The resulting extra linebreaks and whitespace will cause all kinds of problems in your code if you don’t modify your code to trim the value of the property.  So, what can we do to fix this problem?  Well, you have one of three options:

  1. Add “.Trim” to your code in every place you use an application settings of type string. (What the heck!  Who wants to do that!?!)
  2. Forget about using the config transform until SP1 is release with a fix and just do it all manually. (Uh…have I ever mentioned how much I don’t like doing that now?)
  3. Modify the “Settings” class that is auto generated so that it trims the value of any application setting of type string. (BINGO!  I’ll take option three please!)

So, if your like me and you want option three then here is the code in both C# and VB that will get you what you want.  All you really need to do is create a code file in your project and drop the appropriate code in it with the right namespace defined.

BTW,  if you want to vote to have this fixed then here is the issue on the Microsoft Connect website.

C#

namespace MyApp.Properties
{
    internal sealed partial class Settings
    {
        public override object this[string propertyName]
        {
            get
            {
                string value;
                if ((value = base[propertyName] as string) != null) { return value.Trim(); }
                
                return base[propertyName];
            }
            set { base[propertyName] = value; }
        }

    }
}

 

Visual Basic.NET

Namespace My
    Partial Friend NotInheritable Class MySettings

      Default Public Overrides Property Item(ByVal propertyName As String) As Object
         Get
            If MyBase.Item(propertyName) IsNot Nothing Then
               If TypeOf MyBase.Item(propertyName) Is System.String Then Return MyBase.Item(propertyName).ToString.Trim
            End If

            Return MyBase.Item(propertyName)
         End Get
         Set(ByVal value As Object)
            MyBase.Item(propertyName) = value
         End Set
      End Property

   End Class
End Namespace

Tags: , ,

Jul 27 2010

My New Preferred PDF Viewer

Category: ProductivityDavid @ 10:44

The other day I was reading a couple of PDF docs on my TabletPC for a class that I am taking and found myself wanting to highlight and write comments in the PDF.  Well, as you may know Adobe PDF Viewer does not provide any of those features.  So, I went in search of a free PDF Viewer that did provide those features.  To my surprise I found a great FREE viewer that provides extensive functionality for marking up a PDF with your own comments, etc.  If you are looking for the same functionality in a PDF Viewer then check out PDF-XChange Viewer.

Tags:

Apr 8 2010

Great MVVM Webcast from MIX 10

Category: David @ 09:18

I finally had a bit of spare time to take in a webcast or two from the latest MIX conference.  I’ve been trying to get fully up to speed on the MVVM (Model View View-Model) pattern that is quite popular in the WPF and Silverlight development communities.  There are several videos from MIX that deal with this pattern and issues surrounding it.  For those just getting started you can check out the session by Laurent Bugnion entitled Understanding the Model-View-View-Model Pattern. The session that really got me thinking though was the one by Rob Eisenberg entitled Build Your Own MVVM Framework.  There are some really interesting ideas in this webcast, and I was particularly intrigued by his implementation of Coroutines.  If you have sometime check these webcasts out!

Tags:

Feb 1 2010

An Alternate Branching Strategy

Category: David @ 14:04

Now that I have been working with TFS for a while I’ve done some experimenting with my Branching Strategy after much consultation with the Branching Guides that are available on CodePlex (TFS Branching Guide 2.0, TFS Branching Guide 2010). These guides have a wealth of information that should most definitely be consulted when you are considering your own Branching Strategy.

One of the keys to a successful branching strategy is to branch when necessary and only when necessary; no more, no less.  That being said, there are still a number of valid ways to branch from the most basic to the more complex.  Here are three diagrams from the TFS Branching Guide that show the three most common branching strategies.

Basic

image

Standard

image

Advanced

image

As with all guidance, there are exceptions.  In my case I was looking at the Standard branching strategy and finding myself in a situation where there were times when I needed to perform several Hotfixes over a course of time.  However, with at least one of my products there was no way to determine how many Hotfixes we were going to have before the next major release.  Following the Standard or even Advanced strategy didn’t allow me to dynamically add Hotfix releases as an issue was resolved and ready for RTM.  So, I came up with the idea of branching from MAIN to a Baseline Production branch from which all my other RTM branches would originate.  This allows me to create a new Hotfix branch as needed from a common Production branch.

The diagram for my Branching Strategy ends up looking like this:

Branching Diagram

This strategy falls somewhere between the Standard and Advanced strategies defined in the Guidance but also incorporates the flexibility to branch for Hotfixes when needed.  It also allows for concurrent development on a Service Pack should that be needed while still having the Baseline Production branch that acts as an accumulation point for all changes on Production code.

I am sure I am not the first one to come up with this particular strategy since “there is nothing new under the sun.” So, I would love to hear what you all think about this particular strategy.  What do you like about it? What do you see as some of the issues with it?

Tags: , ,

Jan 5 2010

The St. Louis .NET User Group is SOLID

Category: David @ 15:39

If you’re a developer in the St. Louis area make sure make it to the next St. Louis .NET User Group meeting.  A good friend of mine, Chris Deweese, will be giving a presentation on the SOLID principles of software development.

Tags: