Welcome to MSDN Blogs Sign in | Join | Help

Technical Weblog of Eric Charran

A Journal of My Technical Achievements and Challenges
HOWTO: Convert a String to a Byte Array (byte[])

Just so I don’t forget, here is how to convert a string to a byte array:

System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding();

encoding.GetBtyes(yourStringHere)

“Create Unit Tests” Screen Shows No Types in Visual Studio 2008 SP1

When trying to create a unit test in a test project, the “Create Unit Tests” screen shows no types, thus the wizard cannot continue.  The [OK] button is disabled, and the only thing the user can do is cancel the unit test wizard.  This happens on Visual Studio 2008 SP1 on x64 (for me).

Not sure why this is, but if you have a database project type [SQL Server 2005/2008], remove that project from the solution and the type window for the unit test wizard will now work and let you browse types in your project for test method creation.

INFO: Recent Technical Articles

Here are some of my most recent technical articles that I wrote (and helped write) as part of the VSTS Ranger program as well as the SharePoint Ranger program.  As you may know, the ranger programs are essentially field extensions of the product team that provide customers with expert guidance and prescriptive guidance while sending valuable feedback that improves our products to the product groups.  In this instance, we worked with Bijan Javidi, Paul Andrew, Chris Keyser and the PnP team to crystallize our ALM guidance for SharePoint custom application development.  In many instances, we consumed the PnP SharePoint guidance and attempted to model “good development behavior :)”

Here are the resources:

Solution and Authored Artifact Development Models for SharePoint
Learn to reconcile differences between artifact development and assembly development by combining components into a single version control repository, such as Visual Studio 2008 Team Foundation Server.

Using Team Foundation Server to Develop Custom SharePoint Products and Technologies Applications
Use Microsoft Visual Studio 2008 Team Foundation Server to support SharePoint application development, and provide an integrated development environment and single source code repository for process activities, integrated progress reporting, and team roles.

SharePoint Server Custom Application Development: Document Workflow Management Project
Read about the real-world design, construction, and deployment of a custom SharePoint Server 2007 application to a mid-market enterprise customer using Team Foundation Server as an ALM platform.

 

This is from the VSTS Ranger section of the SharePoint ALM Page found here:

http://msdn.microsoft.com/en-us/office/cc990283.aspx

INFO: SharePoint 2007 VM’s NLTM Authentication Failure

I usually build a Virtual Machine that consists of the following for SharePoint development:

  • Windows Server 2008
  • SQL Server 2008 SP1
  • Visual Studio 2008 SP1 with Team Explorer (and VSeWSS 1.3)
  • Office 2007 SP2
  • Domain Controller and DNS Services

I use host headers to allow the web applications I create on the VM to run on port 80.  However, recently, the ability for me to visit a web application suddenly stopped inexplicably.  What happened was that any web application seemed to prompt me for NTLM credentials three consecutive times, but then deny me each time with a blank page.  SharePoint’s access denied page was not even rendered.  Furthermore, any HTML files (images, txt, html) could not be served from the virtual directory of the web application.  I found that I could visit http://localhost:portnumber sites, but no sites that used host headers. 

It turns out that a recent security patch delivered through Windows Update caused the issue.  There is a security update that causes any “excessive” traffic on the loopback adapter to be shut down.  This means that unless you either turn off the loopback adapter security check, or place all DNS names you want to use for web application host headers under a specific registry key, host headers won’t work and you will be denied access.  See the KB here:

http://support.microsoft.com/kb/896861

And the recommended steps below:

Method 1: Specify host names
Note We recommend that you use this method.
To specify the host names that are mapped to the loopback address and can connect to Web sites on your computer, follow these steps:
  1. Click Start, click Run, type regedit, and then click OK.
  2. In Registry Editor, locate and then click the following registry key:

    HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa\MSV1_0

  3. Right-click MSV1_0, point to New, and then click Multi-String Value.
  4. Type BackConnectionHostNames, and then press ENTER.
  5. Right-click BackConnectionHostNames, and then click Modify.
  6. In the Value data box, type the host name or the host names for the sites that are on the local computer, and then click OK.
  7. Quit Registry Editor, and then restart the IISAdmin service.
Method 2: Disable the loopback check
Follow these steps:
  1. Click Start, click Run, type regedit, and then click OK.
  2. In Registry Editor, locate and then click the following registry key:

    HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa

  3. Right-click Lsa, point to New, and then click DWORD Value.
  4. Type DisableLoopbackCheck, and then press ENTER.
  5. Right-click DisableLoopbackCheck, and then click Modify.
  6. In the Value data box, type 1, and then click OK.
  7. Quit Registry Editor, and then restart your computer.
Migrate SharePoint Workflows and Content Types

Here is a great utility to migrate SPD workflows and content types across site collections.

http://spwflmigrator.codeplex.com/

Never used it myself, but it appears quite useful.

List Lookup Columns in Content Types

This codeplex project allows developers to package list lookup columns as a feature and as part of a content type.  This gets us around a challenge where developers try to deploy a content type that has a list lookup column which is dependent on a list instance.

http://fieldlookupbuilder.codeplex.com/

It extends the work done by Chris O’Brien that made list lookup columns as a feature.

SharePoint 2007 - create lookup fields as a feature

HOWTO: Resolve “Cannot connect to the virtual machine because the authentication certificate is expired or invalid”

Great forum post on how to resolve the error “cannot connect to the virtual machine because the authentication certificate is expired or invalid”.  It all has to do with a certificate on the Hyper-V server that is only good for one year.  Al you have to do is to stop they Hyper-V Management Service, delete the old cert and restart. Any VM’s you couldn’t connect to, save their state and restart.

Thanks to Mark at http://social.technet.microsoft.com/Forums/en-US/winserverhyperv/thread/1a3e8f1b-379b-4569-9b39-bb568d2a7e3f/ for the answer below:

Here is what you need to do, there is a certificate for the Hyper-V Virtual Machine Management service that has expired. By default the certificate is a self signed certificate and is only good for one year. Here is how to resolve it:
1) Open Services.msc and go to the Hyper-V Virtual Machine Management service and stop the service.
2) Next go to Start - Run and enter MMC - Ok
3) In the MMC go to File - Add/Remove Snap-in, in the list of Available snap-ins select Certificates then Add.
4) In the next window select Service Account and Next. In the Select Computer select the default of Local Computer then Next.
5) Now under the Service Account drill down to the Hyper-V Virtual Machine Management and select it then Finish and OK.
6) Now in the left hand pane expand Certificates, vmms\Personal and highlight Certificates. In the right hand pane double click on the certificate, should show the Issued To as the host machine name.
7) On the General tab of the certificate at the bottom it should show Valid from and a starting and ending date. The problem is that the certificate has expired.
8) Now close the window for the certificate and then in the right hand pane right click and select delete.
9) Go back to the Services.msc and restart the Hyper-V Virtual Machine Management service.
10) Back to the MMC console and refresh the Personal\Certificates and you should see a new one there. Double click on it and verify the new valid dates.
11) To be able to access the VM's now you will either have to restart the VM or simply use the save state then start the VM back up.

Hope this helps.
Mark

What’s your Social Networking IQ?

 

    What is the best way to judge social networking IQ?  In my mind its not necessarily your knowledge of social networking from an academic perspective, nor is it your knowledge of the technical implementation and networks of social networking that are out there.  However, I define social networking IQ has a person’s ability to effectively participate, benefit from and manage their social networking footprint amongst a variety of social networking networks and implementations.  Whether it be technical networks like such as Facebook, Live Spaces, My Space, etc. or simply an email distribution list within your organization, an individual’s membership should be symbiotic.  This means that members should give to the network like a community as well as receive. Today, most social networks are facilitated by software, so we’ll focus on those.  Also, the term IQ isn’t entirely accurate as it is a measure of your social networking footprint rather than some numerical scheme that judges your worthiness in terms of your memberships.  Thus, to get things started, here is my social networking footprint at work and at home:

    • Work

      • SharePoint My Site

        • Actively use the colleague tracker and monitor as well as presence to see who relates to who and what changes are happening to people on my team or close to me.

        • I also post various documents and presentations to share and other types of information that are valuable to others (like a corporate Live Sky Drive)

      • Internal Microsoft Blog

        • I maintain an internal Microsoft blog as a result of selecting to create one from my My Site

        • I also post to the internal SharePoint Rangers blog and some other regional knowledge sharing blogs

      • MSDN Blog

        • I also maintain an external facing MSDN blog on blogs.msdn.com which serves as a knowledge and “gotcha” repository for challenges I face in the field and in the office.

      • Email Distribution Lists

        • I am a member of over 30 (and that’s trimmed down) internal email distribution lists

          • These lists provide a place for individuals to post general or esoteric technical questions and receive answers right in Outlook

          • These lists are tracked by the colleague tracker and published to others when they look at my profile in SharePoint

      • Office Communicator

        • The SharePoint colleague tracker also mines my IM conversations and contact lists to see who I relate to most frequently as well as my email.

        • The colleague tracker forms recommendations based on these and other elements (like AD reporting relationships)

    • Non-Work

      • Facebook

        • I have a Facebook account which I am quite active on and have integrated with other social networking and IM tools

          • Messenger, Twitter, etc.

      • Twitter

        • I also have a twitter account and use a utility (Witty Twitter) to both create my tweets and have the tweet set automatically as my Facebook status

      • Windows Live Profile

        • I have an active Windows Live profile and have it linked to my Facebook status.

        • This means that when I update Witty Twitter, my tweet is sent to Twitter, and it also is reflected in Facebook and in Windows Live.

      • Windows Live Space

        • I also maintain a Windows Live Space that was and still is my personal interest blog.

      • Flickr

        • Flickr houses my family’s entire photo library (I am a paying member so I have no upload limits).  I tag photos from Windows Live Photo Gallery and use them to upload to Flickr.

        • This means that my photo stream is tagged with the same metadata as my local photos and I can browse the tag cloud using Flickr.

        There are some essential tools that I use to make my life a little easier.  These tools are mostly thick client tools that don’t force me to open a browser every time I want to do something.

        • Groove

          • I use Groove to sync my My Site at work so I have offline access on multiple computers to the content on my My Site.

          • I also use it to sync files between firewalls so clients and customers can easily get large binaries without worrying about ftp, etc.

        • Windows Live Photo Gallery

          • With the latest beta, I upload to Flickr and Facebook right after tagging. 

          • I apply tags as well as facial tags which nicely integrates into Facebook.

          • This allows me to go from camera to Windows Home Server for storage, to Facebook in a few seconds.

        • Witty Twitter

          • A smart client WPF utility that allows me to create, monitor and update Tweets from myself and others

          • I also configured Facebook to monitor my tweets and make them my status updates on Facebook and Windows Live.

        • Windows Live Writer

          • A great utility for thick-client publishing, editing and re-publishing of blog posts. 

          • Allows posting and cross posting between SharePoint, Community Server, Windows Live Spaces and a ton of other blog-ware.

        INFO: What I’m Running

        Every now and then I like to update folks on what I’m running on my hardware.  Below you’ll find information on what my hardware is and what I choose to run on it.

        Here is my newest rig info:

        • Hardware
          • Lenovo T61P
          • 4 GB of RAM
          • SATA Optical Bay Adapter with 160 GB laptop hard drive
        • Software
          • Windows Server 2008 x64 Enterprise Edition with Hyper-V
          • Office 2007 SP1
            • Including Visio 2007, Project 2007 and SharePoint Designer 2007
          • Windows Live Essentials
          • Live Mesh
            • Forced install by downloading mesh.exe and running it from a command prompt with /force
          • Paint.NET
          • Office Communication Server Communicator with full VOIP and Unified Messaging
            • My computer is my phone and instant conference bridge
          • Visual Studio 2008 SP1
            • I thought long and hard about putting this on since I do everything in a virtual (now Hyper-V) machine
          • SQL Server 2008 (client install only)
            • I thought long and hard about putting this on since I do everything in a virtual (now Hyper-V) machine
          • Daemon Tools
            • Careful installing this now as there is a bunch of bloatware in the installer, but a rock solid virtual optical drive emulator

        The biggest change is obviously making the jump to running Windows Server 2008 x64.  The great thing is that it runs like a dream.  Visit http://www.win2008workstation.com/wordpress/ for more in formation, screen shots and tutorials for information on how to do this.  Prepare for an afternoon of researching and installing drivers for your machine.  In my experience on having done this on a Toshiba M700 and the Lenovo T61P, all Vista drivers worked on Windows Server 2008.  Also, you will have to download some tools mentioned on the site above to find out exactly what type of hardware you have so you can get their drivers.  If the manufacturer has their act together, the drivers will be a breeze to find (Lenovo).  Otherwise, you’ll be pulling them off of download sites from around the net (Toshiba).

        I have the desktop experience on and it looks and smells like Vista.  Hyper-V turns off power management (it was designed as a server product feature after all).  This means that the power button is just a power button (on/off) and standby/hibernate is gone.  For me that was OK as I wasn’t a standby/hibernate guy anyway. 

        Hyper-V ROCKS.  It is so superior to VPC.  On 4 GB of RAM I can now run 3 VM’s (Allocated with 1024 MB of RAM) simultaneously while running Outlook.  It does get a bit dicey when I try to make a phone call with communicator, but the VM’s stay responsive and Communicator struggles (which would by my preference).  All in all, a positive experience.  Once last note, Tablet PC users will miss most tablet PC functionality (TIP) as I don’t think anyone has gotten it to work on Windows Server 2008 yet.

        HOWTO: Grant users Logon as Terminal Service Right

        Because I am running Windows Server Enterprise 2008 on my Laptop with Hyper-V enabled, I continuously Remote Desktop to my Virtual Machine.  Even for a domain admin in the guest, you have to have group policy configured to allow the Remote Desktop Users group to allow logon through terminal services.  Here is where you do it:

      • Click Start, point to Run, type mmc, and then click OK.

      • On the File menu, click Add/Remove Snap-in.

      • In Add/Remove Snap-in, click Add, and then, in Add Standalone Snap-in, double-click Group Policy Object Editor.

      • In Select Group Policy Object, click Browse, browse to the Group Policy object (GPO) that you want to modify, click OK, and then click Finish.

      • Click Close, and then click OK.

      • In the console tree, click User Rights Assignment.

        Where?

        • GroupPolicyObject [ComputerName] Policy
        • Computer Configuration
        • Windows Settings
        • Security Settings
        • Local Policies
        • User Rights Assignment

      • HOWTO: Enable Visual Studio 2008 Remote Debugging

        See this link for methods to enable Remote Debugging:

        http://msdn.microsoft.com/en-us/library/bt727f1t.aspx

        HOWTO: How Document Collaboration Works at Microsoft

        While the title of this post might indicate that there is a sweeping document collaboration strategy that all teams and people use, that’s not the case necessarily.  We are big at dogfooding which is a made up verb indicating that we love to try out our own software and tools in our everyday jobs just the way our customers do. 

        To that end, this post will describe a successful multi-national document collaboration effort surrounding the recent publication of the Office SharePoint Server 2007 and Team Foundation Server 2008 guidance that was recently published on MSDN.

        The guidance for this heavily anticipated documentation will be released in phases over the next few weeks and appear in a developer center located under the SharePoint developer center. 

        Here is the portal link which describes the focus of the guidance as well as links/placeholders to all the content as it gets published:

        Team Foundation Server Resource Center

        And here is the link to the first published article:

        Using Team Foundation Server to Develop Custom SharePoint Products and Technologies Applications

        Based on the guidance, and the descriptions in the above resource center, we have a total of five white paper documents that were collaborated on by over 50 people in several countries, including India, Germany, Ireland, Turkey and the Netherlands.  This also included domestic resources such as product group folks and rangers around the country and in Redmond, WA.  Here are some stats about the effort:

        Collaboration Platform:  Office SharePoint Server 2007 and Groove 2007 with Word 2007, Visio 2007 and OneNote 2007 (all latest Service Packs and hotfixes)

        Team Size:  Over 50 contributors and tester/reviewers actively marking up and editing the same set of documents over a 4 month period including Microsoft Services Consultants, Product Group team members (SharePoint and Visual Studio Team System) and external MVP’s

        Deliverables:  5 white papers consisting of procedural and contextual guidance including screen shots, artwork, Visio diagrams for developers writing custom MOSS applications and using Team Foundation Server

        How we did it:

        I was fortunate enough to be at the hub of this activity and led the effort to work with all the talented authors, contributors and reviewers.  What we did is to establish a SharePoint team site in on a our internally hosted Microsoft SharePoint 2007 Server collaboration farm.  Using the Shared Documents library, I then created a Groove 2007 workspace and added the SharePoint Files tool. 

        SharePoint and Groove in Sync Together:

        The SharePoint Files tool will connect to a designated SharePoint site at a level in its folder hierarchy specified by the user.  In my case, I linked the tool to the Shared Documents folder.  I then in Groove, created a folder hierarchy which the rest of the team would use to store documents and resource files related to those documents.  The folder hierarchy synchronized back to SharePoint, thereby mirroring the workspace and the files therein.

        From a collaboration standpoint, this was critical as a most of our authors and reviewers were at one point or another not connected to our internal-only corporate SharePoint collaboration environment.  Thus, by making Groove the primary collaboration point, Groove workspace members could interact with the virtual team and the shared documents while at an airport, on the train, or anywhere with internet access.

        How We Managed Changes to Documents:

        Whenever anyone updated a document, the changes came streaming back from their workspace to everyone else’s copy.  For me, I was the designated SharePoint synchronizer.  My workspace was the first workspace that I invited everyone to, so it was the only workspace that synchronized back to the SharePoint team site.  When my workspace received updates and reported unsynchronized changes in the tool, I simply synchronized back to the SharePoint site and all the changes went into the SharePoint “cloud”.  This gave me, and everyone else a comfort level that our documents were preserved not only in each other’s workspace, but versioned in SharePoint as well which was backed up by Microsoft’s enterprise backup. 

        Collaboration Stipulations:

        While the this arrangement gave us the flexibility to support collaborators accessing a document both in Groove and in SharePoint, I did not want to get into a situation where a single document had conflicting changes coming from both environments.  Thus each paper’s collaboration team was required to choose their collaboration environment (SharePoint or Groove).  Because of the benefits of Groove (only an internet connection required to collaborate) all of our team chose this approach.  This left it to me to manually (if I chose) check out and in documents before synchronizing. 

        In addition, to avoid collisions of people editing documents at the same time in the workspace, what we did was to copy our standard MSDN template Word 2007 xml file for each contributor.  This assured that they would be able to contribute freely without worrying about who else was in the document when they were.  Once completed, I was responsible for editing and merging the documents back into a master composite copy (using Word 2007’s merge document feature). 

        For editing and commenting from our tech reviewers, we did the same thing.  We made copies of the composite document which they could freely edit and mark up which I merged in and applied their edits to the master copy.  All the while, I was synchronizing with the SharePoint site.  We also had .one files in the folders for each white paper so we could share hand drawn or text notes on the topic.

        Great Collaboration Experience:

        It was really one of those great collaboration experiences where the technology worked like it was supposed to.  Quietly, reliably and without issue.  No document collisions, or burned documents or uh-oh moments. One great benefit is that I saved the workspace invitation within the workspace itself.  Thus, any member of the the workspace or visitor to the SharePoint site could join the workspace themselves or forward it on to others.  The popularity of this project inside Microsoft reached fever pitch when at one point we had over 75 active workspace members.

        HOWTO: Complete a WF Workflow if a Task Replicator Activity’s Tasks Haven’t Been Completed Yet

        Scenario:

        A Visual Studio Workflow Foundation Workflow needs to terminate with approval given the following circumstances:

        1. At least one task has been completed out of the many tasks that were assigned via the workflow to approvers

        2. A field on the current item the workflow is executing on has been edited/updated/changed

        Thus the behavior would be that the users could modify the workflow by adding approvers, completing tasks, etc. and if the monitored field on the current list item hadn’t been updated, the workflow would remain open. As soon as the workflow received notification that the current item’s field had been updated and that it matched an internal comparison value, the workflow would evaluate if at least one task had been approved and conclude the workflow (including closing/completing all outstanding tasks).

        Implementation:

        Instead of using a Parallel Activity, a Condition Activity Group (CAG) was used. It included the 2 event handling scopes. The first contained the an activity that handled the update to the current item. The second contained a task replicator. The task replicator was responsible for creating the tasks as/per the add approver workflow modification data. The CAG was then given a declarative rule condition to monitor 2 Booleans (isAtleastOneTaskComplete and isItemUpdated) which are public Booleans set by each activity when a task completes or the item was updated. If those evaluate to true, the CAG terminates the task replicator and closes the workflow successfully.

        Adding Approvers:

        Once the CAG was implemented, the ability to modify the task replicator and add approvers was lost. This is because the replicator in the workflow (this.taskReplicator1) is not actually executing. The CAG creates a child instance of the task replicator and runs that one. Thus, when the first child is created, we capture that activities parent from its event args which resolves to the active (cloned) task replicator (not its template). When adding approvers, we add to that replicator’s children and not the template (non-executing one).

        Clean Up:

        However, while the CAG terminated the replicator, it still leaves the tasks. Using the MOSS API with a code activity, we got the task list from the workflow properties and found all tasks relating to the workflow instance running and closed them using the MOSS API. This allowed the tasks to be complete and the workflow to finish.

        HOWTO: Get the field text from a SPFieldChoice

        The SPFieldChoice usually holds the Int32 part of a choice field that is comprised of 2 values (the ID of the choice and the text of the field that is displayed).  Take the example of a workflow status column.  The ID 2 corresponds to the field value “In Progress”.  Programmatically, this will yield the value of “2”.

        sharePointList[“Workflow Status Field”].ToString();

        However, if you wanted to do a comparison against the text “In Progress” (for example to take action in your code against the value of a workflow status) you would have to do this:

        string workflowProgressStatus = ((SPFieldChoice)sharePointList.Fields[“Workflow Status Field”]).GetFieldValueAsText(sharePointList[“Workflow Status Field”]);

        This would yield the string “In Progress” to the workflowProgressStatus variable.

        Taking a Virtual Machine from Virtual Server/VPC to Hyper-V

        One trick is that you have to follow the steps outlined here:

        http://support.microsoft.com/kb/954282

        Even if you install the Integration Components for Hyper-V, the VM will not update because the VMBus device will not start (This device cannot start. (code 10)).  What you have to do if you are trying to move is the following:

        RESOLUTION

        To resolve this issue, follow these steps:

        1.  Start the virtual machine.

        2.  Click Start, click Run, type Msconfig.exe, and then click OK.

        3.  In the System Configuration dialog box, click the Boot tab, and then click Advanced Options.

        4.  In the BOOT Advanced Options dialog box, click to select the Detect HAL check box, and then click OK.

        5.  Click Yes to restart the virtual machine.

        6.  After the virtual machine is restarted, open Device Manager, and then verify that all Integration Services devices are installed.

        7.  In Device Manager, expand Computer, and then verify that ACPI x86-based PC is listed as the HAL.

        Note You can clear the Detect HAL check box that you selected in step 4. If the Detect HAL check box is selected, the virtual machine takes a slightly longer time to start.

        More Posts Next page »
        Page view tracker