I just stumbles across a "new" concept of Microsoft. In the C:\Program Files\Reference Assemblies folder Microsoft installs assemblies for products that can be referenced from your code. Instead of referencing assemblies directly from the GAC or copying an assembly from an installation folder or the GAC to your project for reference, you can now reference the assemblies in this folder.

We have a similar approach in our Macaw Solutions Factory where we have a _SharedAssemblies folder to keep track of all external assemblies to reference. We prefer to keep the assemblies with the source that is checked into source control, because otherwise it is possible that a build server does not contain the expected assemblies when compiling a checked-out solution and can't successfully compile the solution.

On the MsBuild team blog you can read more about this feature that happened to be with us since the .Net 3.0 framework:

http://blogs.msdn.com/msbuild/archive/2007/04/12/new-reference-assemblies-location.aspx

Also other applications like PowerShell keep their assemblies to reference in this location. 

Posted by svdoever | with no comments
Filed under: ,

We all want to use the new features in Visual Studio 2008 during development. When using VS2008 for VsPackage development we need to install the Visual Studio 2008 SDK. The approach taken for building VsPackages in VS2008 is incompatible with the approach taken in VS2005. In this article I explain an approach to use VS2008 to build a compatible VsPackage that can be tested in the experimental hives of both versions of Visual Studio.

About VsPackage

  • A VsPackage is a very powerful Visual Studio extensibility mechanism
  • Visual studio knows about a VsPackage and its functionality through registry registrations
  • To test a VsPackage without messing up your Visual Studio, the Visual Studio SDK created a special experimental “registry hive” containing all required Visual Studio registrations. Visual studio can be started with the name of this hive to test your VsPackage in a “sandbox” environment
  • This hive can be reset to its initial state in case of problems or to do a clean test
  • In Visual studio 2005 the hive is created under HKEY_LOCAL_MACHINE, this gives issues under Vista where a normal user may not write to this part of the registry
  • In Visual studio a “per user” experimental hive is supported, so you can do Run As a Normal User development

In the Visual Studio 2005 SDK the experimental hive was created on installation because the same experimental hive was used for all users. In the Visual studio 2008 SDK the experimental hive is per used, so each user needs to recreate it’s own expirimental hive. You can do this by executing the following command from the Start Menu: Microsoft Visual Studio 2008 SDK -> Tools -> Reset the Microsoft Visual Studio 2008 Experimental hive.

What this command does is executing the following command: VSRegEx.exe GetOrig 9.0 Exp RANU. The RANU argument means: Run As a Normal User.

Referenced assemblies

A VS2008 VsPackage project will normally reference the following assemblies:

<Reference Include="Microsoft.VisualStudio.OLE.Interop" />

<Reference Include="Microsoft.VisualStudio.Shell.Interop" />

<Reference Include="Microsoft.VisualStudio.Shell.Interop.8.0" />

<Reference Include="Microsoft.VisualStudio.Shell.Interop.9.0" />

<Reference Include="Microsoft.VisualStudio.TextManager.Interop" />

<Reference Include="Microsoft.VisualStudio.Shell.9.0" />

If we want to run the VsPackage on VS2005 as well, we may not reference assemblies from VS2008 (the assemblies ending with 9.0). The set of assemblies we should reference are:

<Reference Include="Microsoft.VisualStudio.OLE.Interop" />

<Reference Include="Microsoft.VisualStudio.Shell.Interop" />

<Reference Include="Microsoft.VisualStudio.Shell.Interop.8.0" />

<Reference Include="Microsoft.VisualStudio.TextManager.Interop" />

<Reference Include="Microsoft.VisualStudio.Shell" />

VsPackage registration

But because Visual Studio uses a tool called RegPkg.exe to generate the required registry entries to make the VsPackage known to Visual Studio, and that the RegPkg.exe application for VS2008 uses the Microsoft.VisualStudio.Shell.9.0 assembly and the RegPkg.exe application for VS2005 uses the the Microsoft.VisualStudio.Shell assembly, we have a problem.

But Microsoft was so kind to provide a howto on migrating VsPackage projects to VS2008. See http://msdn.microsoft.com/en-us/library/cc512930.aspx for more information. If you have followed the steps to migrate an existing VS2005 project to VS2008, there is an interesting section on what to do if you want to use the Microsoft.VisualStudio.Shell assembly instead of the Microsoft.VisualStudio.Shell.9.0 assembly, and in that way stay compatible with VS2005.

The steps are as follows:

A VsPackage project has a project file that is actually an MsBuild file. To open this file in Visual studio do the following:

  1. Right click on the VsPackage project
  2. Select Unload Project (save changes if requested)
  3. See the project named changed from FooBar to FooBar (unavailable)
  4. Right click again and select Edit FooBar.csproj
  5. Add the following lines to the last PropertyGroup:
    <!-- Make sure we are 2005 compatible, and don't rely on RegPkg.exe
    of VS2008 which uses Microsoft.VisualStudio.Shell.9.0 -->
    <UseVS2005MPF>true</UseVS2005MPF>
    <!-- Don't try to run as a normal user (RANA),
    create experimental hive in HKEY_LOCAL_MACHINE -->
    <RegisterWithRanu>false</RegisterWithRanu>
  6. Save project file
  7. Right click on the project and select Reload Project

After these changes the RegPkg.exe for VS2005 is used to generate the registry settings. But this tool can only generate registry settings for a hive in HKEY_LOCAL_MACHINE, and not for a hive in HKEY_CURRENT_USER. This means that development must be done as an administrator.

If we now build the application we get the following error: “Failed to retrieve paths under VSTemplate for the specified registry hive.”, we must register a new registry hive for VS2008 in HKEY_LOCAL_MACHINE with the following command: VSRegEx.exe GetOrig 9.0 Exp.

For more information on the RegPkg.exe utility, see the excellent blog post at http://www.architekturaforum.hu/blogs/divedeeper/archive/2008/01/22/LearnVSXNowPart8.aspx. Don’t forget to read the rest of that blog post series.

Last step to do is changing the way VS2008 is launched when debugging the VsPackage with F5. Right-click the VsPackage project and select properties. Now remove RANU from the command line arguments box:

clip_image002[5]

Because we want to target both VS2005 and VS2008 with the VsPackage, we should also test the package on VS2005. So assuming that VS2005 is installed on the development machine as well, create an experimental hive for VS2005 using the command: VSRegEx.exe GetOrig 8.0 Exp. We don’t need to install this experimental hive if we installed the Visual Studio SDK for VS2005 as well.

To register the VsPackage for VS2005 as well and start VS2005 under the experimental hive, you can add a small batch script to your solution. Add a file TestInVS2005.bat in the root of the solution folder as a solution item. The TestInVS2005.bat file should have the following content:

"%VSSDK90Install%VisualStudioIntegration\Tools\Bin\VS2005\regpkg.exe" /root:Software\Microsoft\VisualStudio\8.0Exp /codebase %~dp0FooBar\bin\Debug\FooBar.dll

"%VS80COMNTOOLS%..\IDE\devenv.exe" /rootSuffix exp

Pause

We can now right-click on the TestInVs2005.bat file, select Open With… and browse to the TestInVs2005.bat file itself to open the file with. It then starts the batch script.

Posted by svdoever | 3 comment(s)
Filed under:

I wanted to create a simple html file in the root of my Wss3 web application, so I created an empty file test.htm. I double clicked te file and because I have SharePoint Designer installed, it is the default editor for .htm files. I put some test into the .htm file along the lines of "Hello world!", and boom: my Wss3 web application is dead. I get the following error:

Server Error in '/' Application.

Parser Error

Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.
Parser Error Message: Data at the root level is invalid. Line 1, position 1.
Source Error:

Line 1:  <browsers>
Line 2:      <browser id="Safari2" parentID="Safari1Plus">
Line 3:          <controlAdapters>

Source File: /App_Browsers/compat.browser    Line: 1


Version Information: Microsoft .NET Framework Version:2.0.50727.832; ASP.NET Version:2.0.50727.832

After some searching I found what happened:

When you open a file with SharePoint Designer, it creates all kind of FrontPage Server Extension functionality in your web application. One thing it does it that it creates a _vti_cnf folder in every folder you have in your web application. If you remove all these folders you fix your problem.

I don't know of a handy DOS command to delete all these folders recursively, but with some PowerShell I solved the problem.

Open a PowerShell prompt, set the current directory to the folder hosting your web application and execute the following command to see the "damage":

PS C:\Inetpub\wwwroot\wss\VirtualDirectories\wss3dev> get-childitem -path . -name _vti_cnf -recurse
_vti_cnf
App_Browsers\_vti_cnf
App_GlobalResources\_vti_cnf
aspnet_client\system_web\2_0_50727\CrystalReportWebFormViewer3\CSs\_vti_cnf
aspnet_client\system_web\2_0_50727\CrystalReportWebFormViewer3\html\_vti_cnf
aspnet_client\system_web\2_0_50727\CrystalReportWebFormViewer3\Images\ToolBar\_vti_cnf
aspnet_client\system_web\2_0_50727\CrystalReportWebFormViewer3\Images\Tree\_vti_cnf
aspnet_client\system_web\2_0_50727\CrystalReportWebFormViewer3\JS\_vti_cnf
wpresources\_vti_cnf
_app_bin\_vti_cnf

Now execute the following PowerShell command to kill all these folders and become a happy camper again:

PS C:\Inetpub\wwwroot\wss\VirtualDirectories\wss3dev> get-childitem -path . -name _vti_cnf -recurse | % { remove-item -Path $_ -recurse }

Posted by svdoever | 7 comment(s)
Filed under: ,

When delivering a virtual hard disk to your team to build their virtual machines on I perform the following steps to minimize the size of the virtual hard disk. It is assumed that Virtual Server 2005 R2 SP1 is installed.

  1. Make sure you merged the Undo disks, and that differencing disks are merged with their parent disks
  2. Disable undo disks
  3. Start the virtual machine to compact
  4. In the virtual machine download CCleaner on http://www.ccleaner.com . This is a great tool to clean your disk from history files, cache files etc. I run this almost daily on my virtual machines and my host system. Thanks Danny for introducing me to this great tool.
    Quote from their website:
    CCleaner is a freeware system optimization and privacy tool. It removes unused files from your system - allowing Windows to run faster and freeing up valuable hard disk space. It also cleans traces of your online activities such as your Internet history. But the best part is that it's fast (normally taking less than a second to run) and contains NO Spyware or Adware! :)

    During installation beware of the option to install the Yahoo toolbar, you often overlook this co-packaging options from Microsoft, Google and Yahoo:
    clip_image002
  5. In the virtual machine run CCleaner with the options you prefer, my options are:
    clip_image004
  6. Shut down the virtual machine
  7. Mount the virtual hard disk to compact using vhdmount (part of Virtual Server 2005 R2 SP1):
    "C:\Program Files\Microsoft Virtual Server\Vhdmount\vhdmount" /p “drive:\folder\YourVirtualHarddiskToCompress.vhd”
  8. Go to Start > My Computer; Right-click and select Manage. Now defragment the disk mounted in step 6
    clip_image006
  9. "C:\Program Files\Microsoft Virtual Server\Vhdmount\vhdmount" /u /c “drive:\folder\YourVirtualHarddiskToCompress.vhd”
  10. Now start your virtual machine, and mount the ISO image C:\Program Files\Microsoft Virtual Server\Virtual Machine Additions\Precompact.iso. I personally use VMRCPlus to mount the ISO, right-click on CD-Drive and select Attach Media Image file… as shown in the screenshot below
    clip_image008
  11. When you navigate to the drive where the ISO image is mounted, the precompaction starts. The precompaction writes zero’s in all unused space in the disk, so the disk can be compacted in the next steps.
  12. Shut down the virtual machine
  13. Now start compaction of the virtual disk. This can be done in VirtualPC 2007, in the administrative web Virtual Server 2005, or in VMRCPlus, which I use here. Navigate to Tools > Virtual Disks > Inspect Virtual Hard disk, select your vhd to compact and select disk operation Compact
    clip_image010
  14. Done! Make your virtual hard disk read only, and start creating differencing disks based on your new base disk.
Posted by svdoever | 5 comment(s)
Filed under:

I have always been so annoyed by the fact that on my laptop with 1920x1200 resolution I could only get a connection to my virtual machines at a resolution of 1600x1200, the max resolution by the emulates S3 graphics board, resulting in two 160 pixesl wide black bars on the left and right sides. But on Vista I did get a connection on higher resolutions, after some searching I found that the old Remote Desktop Connection software of XP (SP2) was the problem. Upgrade it to version 6 and you worries are over. See: http://support.microsoft.com/kb/925876/en-us. Happy virtual development!

Posted by svdoever | with no comments
Filed under:

Ronalus has created a great small utility to explore the contents of SharePoint Content Management Pages called Content Migration Package Explorer.

This tool can be used to investigate the data exported by the SharePoint Content Migration API. You can create an export either with stsadm.exe, or with custom code.

As example for this weblog I exported a simple site containing some test data using the following command:

Stsadm.exe –o export –url http://wss3dev/FlexShop -filename c:\temp\FlexShop -nofilecompression

We now have a folder containing the output files, a set XML files and other files:

clip_image002

If we fire up the Content Migration Package Explorer we get the following startup screen:

clip_image004

You can now enter the export folder and browse through the exported information using a simple to use explorer, see below for some screenshots:

clip_image006

clip_image008

clip_image010

clip_image012

clip_image014

clip_image016

Posted by svdoever | with no comments
Filed under:

I just stumbled accross a handy little utility that is really handy during SharePoint development: Show List and ViewGUIDs.

Type a Site URL, and select “Display Lists Titles and Ids”. From the list of lists you can select a list GUID, and with right-click copy it to the List ID input field.

clip_image002

After clicking “Display Views” you see the available list views. Again you can select a view guid, and with right-click copy it to the View input field.

clip_image004

Select “Display Items” to display the list items in the view.

clip_image006

With a click on “Display default List Attribute Names” de internal names of the fields in the list are displayed.

clip_image008

Very useful if you don't have tools like SharePoint Explorer or SharePoint Inspector installed, or if you find those tools too large/slow/complex to get some GUIDs and name information fast.

Posted by svdoever | 4 comment(s)
Filed under:

The SharePoint command-line utility stsadm.exe was driving me crazy for the last two days. I'm automating all kind of this from PowerShell scripts, but I got the error "Command line error" while I was absolutely sure that what I was doing was correct. I did stsadm.exe -o deletesolution foobar.wsp. And the problem was: character encoding...

First I thought it was a problem with the way I executed this command from PowerShell. When I copied over the command to a different script it worked. What!!!??? Then I copied it over to the cmd.exe shell on the command line and I got the same error.

I started searching on Google and came accross this blogpost. It said it had something to do with encoding. The blog post also pointed to this blog post where people responded in the contents with the most hillarious solutions like:

If I type STSADM.EXE it works, while STSADM.exe does not work, or that a solution file must be in the same folder as stsadm.exe. Read the comments, it is fun how far off people can get.

Another post mentioning the problem is this discussion thread.

The problem happened to be in the encoding. One way or the other it is possible to get different encodings while typing in the same command multiple times in the same cmd.exe shell. Don't ask me how.

If you have problems, type your text in an editor like Notepad++, and switch between "Encode in ANSI" and "Encode in UTF-8" (it is under the Format menu in Notepad++). You see (sometimes)the dash(-) in stsadm -o command... change from '-' to a strange little block... There is the problem. The dash is not always a dash, it is a hyphen... And stsadm then thinks that no command is specified. Remove the strange block, type a hyphen while is UTF-8 encoding, copy that and bingo!! It works.

Ok, how to repeat this:

  1. Start Notepad++, set encoding to ANSI
  2. Make sure the path to stsadm.exe is in your path environment variable (or use full path)
  3. Type stsadm -o deletesolution foobar.wsp
  4. Start cmd.exe
  5. Copy the text over and press enter: voila, Command line error.

The strange thing is that even if you remove the dash (-), and type it again, it still gives errors. I have no clue why.

This dash/hypen thing is a common problem if you search Google, for more info see for example:

Posted by svdoever | 8 comment(s)
Filed under: , ,

Now Visual Studio 2008 is released (I know, I'm blogger #100.000 to mention this) it is interesting to look at the future of one of the important building blocks on the Microsoft platform for building Software Factories: the DSL Tools.

Stuart Kent, Senior Program Manager with the Visual Studio Ecosystem team, reveals a part of the post Visual Studio 2008 roadmap for the DSL tools in its blog post DSL Tools beyond VS2008.

Some of the mentioned concepts are already available in the implementation of the Web Service Software Factory: Modeling Edition, really interesting to have a look at the code.

The next version of Visual Studio will be Rosario. Clemens Rijnders describes some of the new Rosario features with respect to DSLs in his blog post Rosario Team Architect CTP10 Preview. One promising concept is the Designer Bus, which should simplify working with multiple DSLs in the same domain that reference each other. Some support for this functionality in currently available as the DSL integration service power toy.

Posted by svdoever | with no comments
Filed under:

PowerShell has powerful exception handling, but it is badly documented and takes while to understand what the heck they actually want to do to wire up the exception handling.

I'm normally not such a link poster, this is more of a "post-to-self" item that might be useful for others as well.

Posted by svdoever | with no comments
Filed under:
More Posts Next page »