CodersBarn.com
The ASP.NET Community Blog

Install SharePoint 2010 on Windows 2008

November 21, 2009 12:21 by agrace

Follow me on Twitter Two weeks ago I decided to prep my development VMWare Workstation in anticipation of the yet-to-be-announced SharePoint 2010 beta 2 release. After some futile attempts at installing W2K8 server, I realized that it was time to upgrade my VM software from version 6 to 7. After forking out the $99 (well worth it IMHO), I encountered the first hurdle when attempting to create the VM: my machine was not "VT enabled"... Apparently my host machine, which is a HP dt5000 desktop with 8GB of RAM and two quad cores wasn't up to the task :-O VT stands for Virtualization Technology and it's basically the processor equivalent of a V8 Dodge Challenger.

Some machines are VT-capable but are not VT-enabled when shipped. It's pretty common for laptops not to have this enabled. I called HP Support and ended up re-booting my machine and updating the BIOS to enable VT-Threading. Not so long ago, PC support technicians would respond to such a request with "do it but keep a fire extinguisher handy"...

Here are my machine specs...

Intel Core2 Quad CPU Q9450 2.66GHz 4 cores
Bios: American Megatrends 5.16 6/19/2008
Vista Ultimate 6.0.6002 SP2 Build 6002


...and the steps to perform this task - steps should be similar irrespective of the machine:

1. Turn off the PC and then again turn on the PC
2. After you get the HP logo screen immediately keep tapping the f10 key after the HP logo screen to enter in to BIOS set up screen
3. In the BIOS set up screen select the “Power” tab
4. Under the Power tab you will find the option “Virtualization Technology”
5. You need to enable it and then press f10 key on the keyboard to save and exit
6. Re-start machine


From the moment PDC09 began, the blogosphere has been alight with posts about installing this beta, so I'm not going to give overly-detailed instructions. Instead, I want to focus in on the gotchas that can make this an unpleasant experience for non-admin devs like myself. I'm also providing the links you need at the end of this post.

Developer in Admin Role As I write, I have just (successfully) re-created the install of SharePoint on my VM for the third time, in an efort to get this right. Previous attempts resulted in various errors, which though unforseen, were still my fault. One tip: I use VirtualCloneDrive to mount my ISO (DVD) images when creating VMs and it works on 64-bit. I also use ClamWin Anti-Virus for 64-bit. Create a strong password for your (admin) account with a mix of at least capital and small letter and numbers - you'll see why in a bit.

After the OS is installed, if you start getting license activation errors in the log, go to Start -> Control Panel and click on the "Change Product Key" link. When prompted, enter your valid licensed product key and the product activation will complete successfully.

You may also want to install the KB 971831 hotfix which "provides a method to support the token authentication without transport security or message encryption in WCF is available for the .NET Framework 3.5 SP1."

Now it's time to install SQL Server 2008 - 2005 will work also but involves different patches:

Script to open SQL Server ports:
http://support.microsoft.com/default.aspx/kb/968872

SQL Server 2008 SP1:
http://www.microsoft.com/downloads/details.aspx?familyid=66AB3DBB-BF3E-4F46-9559-CCC6A4F9DC19&displaylang=en

CU2 for SP1:
http://support.microsoft.com/kb/970315

Add your admin account in SSMS and grant permissions for the following roles:

* securityadmin fixed server role
* dbcreator fixed server role

Important: If you plan to run Windows PowerShell cmdlets that affect a database, this account must be a member of the db_owner fixed database role for the database.

Next, grab Powershell 2.0 and install it. The SharePoint Pre-Requisites checker failed on this for me several times because of the older version of Powershell being present.

Install Menu

Next install SharePoint 2010. When the SharePoint Server 2010 menu appears, first click on the "Install software prerequisites" link. After this successfully completes, click on the link to actually install SharePoint Server. Choose Server Farm and Complete from the wizard menu options. This is the part that catches most people. The terminology here leaves a lot to be desired and I'm surprised that it's still being used in this version - <rant>they let the marketing assholes rename almost everything else so why stop there?</rant>

Important: Do not run the Products and Technologies Configuration Wizard after the wizard completes.

Install Type

With the 2010 version we cannot automatically run everything with a local account. This is retarded because in most cases people do not want to set up AD and DC for a simple dev VM. Luckily, there is a workaround with Powershell - just follow the simple steps and use the strong password we created earlier, when prompted.

Now we can run the Products Configuration Wizard from the Start menu and use our local account when prompted for such info by the wizard. On completion, you will be presented with the Farm Configuration Wizard - take the dummies option (default) and you will be led by the reins to the complete setup of your site collection and top level home site. This is a huge improvement over the 2007 version. What's even better is that with the introduction of the new Service Application Architecture we no longer have to go through the process of creating the now deprecated Shared Services Provider (SSP).

Home Page
 

Next task will be to install VS 2010 Ultimate and SharePoint Designer 2007...

UPDATE - 12-12-2009:

I have since been re-building my machine and I would like to point out something that I missed the first time around: before manually installing Powershell 2.0, you have to uninstall the 1.0 version that comes with the OS. You can do this by clicking on the 'Remove Feature' link in Server Manager.

kick it on DotNetKicks.com


VSeWSS 1.3 March 2009 CTP

March 26, 2009 00:36 by agrace

Thanks to Paul Andrew, SharePoint Technical Product Manager at Microsoft, for the heads up on the March CTP of Visual Studio Extensions for Windows SharePoint Services (VSeWSS) 1.3. According to Paul: "we added some default permissions to the BIN deployed project templates. So you can now F5 debug the web part BIN deployed project as soon as it is created".

Installation was a snap, just be sure to uninstall any version of VSeWSS first. As always, be sure to read the release notes. Here is a snippet from said document: "VSeWSS 1.3 includes a web service that needs to run as a member of the local Administrators group. The web service is used by the Visual Studio extension to communicate with SharePoint and is restricted to local connections only. As a security precaution the installer does not add the account running the web service to the local Administrators group. You must do it".

What this means in plain English is that if you have Central Admin running under the administrator account on your dev machine, then you don't have to do anything. Just accept the defaults during the install. More details of the install process available on Kirk Evans' blog.

VSeWSS 1.3

Note that this is not an official release version so it is not supported in a production environment. This is the last CTP before the new generation of SharePoint tools arrive with VS 2010. Read more about this on Soma Segar's blog.

Be sure to watch Kirk Evans' new series of screencasts on SharePoint development using the extensions:

* SharePoint Developer Series - Part I
* Consuming SharePoint Lists via Ajax

kick it on DotNetKicks.com   vote it on Web Development Community


Tags:
Categories: SharePoint
Actions: E-mail | Permalink | Comments (2) | Comment RSSRSS comment feed

How to Install VSeWSS 1.3

January 27, 2009 17:40 by agrace

Download the 1.3 extensions to your C:/ drive from here:

https://connect.microsoft.com/Downloads/Downloads.aspx?SiteID=428

Start the msi from an elevated command prompt - that is, right click Command Prompt icon in Start menu and select 'Run as Administrator'. Issue this command:

C:\msiexec /i VSeWSSv13_x86_Build_307_CTP.msi

This will prevent the UAC from causing the VSeWSS 1.3 to "fail prematurely".

Update 02-19-20009:

sn.exe meant for 32-bit OS runs without error on 64-bit OS and incorrectly shows message indicating success.

Update 03-31-2009:

Latest release is a .exe file, so this shouldn't cause problems.


Create a Web Part with VSeWSS 1.3 - Part II

January 25, 2009 14:48 by agrace

PostIt Man This part will continue on with the new Web Part project we just created with VS 2008 and VSeWSS 1.3. The original plan was to implement a custom security access policy so that we could safely run our Web Part and read from an XML file. But like all good plans... For the purposes of this sample, we can simply up the trust level in the config file until we are confident that we have our Web Part functioning correctly. I may come back to the topic of CAS customization.

I recently created some Web Parts using version 1.2 of the extensions in combination with the command line. Typically, I would use the GAC for development. My testing cycle would then consist of building, uninstalling old version from GAC, deploying Feature, installing new version in GAC, and running IIS reset. This time around, I was unfamiliar with the extent to which 1.3 was going to automate things. For example, while creating this project, I did not have to use the command line once. The ultimate goal for this part is to actually get a Web Part working, using the new version of VSeWSS 1.3.

Although not necessary for the purposes of this tutorial, it helps to understand the development cycle of Web Part created as a Feature. If you were doing this manually, you would typically build it, deploy (copy) it, install it, activate the feature, and recycle the application pool. When updating code and redeploying, don't forget to deactivate the Feature first. Note also, that when we deactivate and uninstall a Feature, files such as CSS, images and the like, still remain on the file system. If you need to make changes to these with version 1.2, you may need to hand copy them. There is a config attribute for overwriting a file if it already exists, but I could never get this to work.

Back to business. Take a look at the XML below. Add the Addresses.xml file to the TestWebPart folder in Solution Explorer. We want to display some of this data in our Custom Web Part.

<addresses>
  <address>
    <name>John Doe</name>
    <street>123 Some Street</street>
    <city>Some City</city>
    <state>CA</state>
    <zip>12345</zip>
  </address>

  <address>
    <name>Jane Doe</name>
    <street>456 Another Street</street>
    <city>Some Other City</city>
    <state>CA</state>
    <zip>56789</zip>
  </address>
 
</addresses>


Here's the complete code from my Web Part. Note the use of the RunWithElevatedPrivileges delegate here. Without this, the code would run under the current user's permissions. This allows the code to run with the same permissions as SHAREPOINT\System.I also hand copied the Addresses xml file to the wpresources folder in my virtual directory as I had difficulty in correctly configuring my Feature to do this for me. Does anyone know the proper way to do this?

using System;
using System.Data;
using System.Runtime.InteropServices;
using System.Text;
using System.Web.UI.WebControls;

using Microsoft.SharePoint;
using Microsoft.SharePoint.Administration;

namespace TestWebPart
{
    [Guid("5bc61f3f-62cf-49b5-8ffb-0f6081f87e64")]
    public class TestWebPart : System.Web.UI.WebControls.WebParts.WebPart
    {
        DataSet ds;
        Label testLabel;

        public TestWebPart()
        {
        }

        protected override void CreateChildControls()
        {
            Controls.Clear();
            base.CreateChildControls();

            // This following anonymous method allows a specified block of
            // code to run in the context of the SharePoint System Account
            SPSecurity.RunWithElevatedPrivileges(delegate()
            {
                // You must create a new SPSite object inside the delegate
                // because SPSite objects created outside do not have Full
                // Control even when referenced inside the delegate.
                using (SPSite site = new SPSite("http://" + System.Environment.MachineName))
                {
                    string sUri
                        = site.WebApplication.IisSettings[SPUrlZone.Default].Path.FullName
                            + "\\wpresources\\Addresses.xml";
                    ds = new DataSet();
                    ds.ReadXml(sUri);

                    StringBuilder sb = new StringBuilder();
                    sb.Append(ds.Tables[0].Rows[0]["name"].ToString() + "," + "<br />");
                    sb.Append(ds.Tables[0].Rows[0]["street"].ToString() + "," + "<br />");
                    sb.Append(ds.Tables[0].Rows[0]["city"].ToString() + "," + "<br />");
                    sb.Append(ds.Tables[0].Rows[0]["state"].ToString()
                        + " " + ds.Tables[0].Rows[0]["zip"].ToString() + ".");

                    testLabel = new Label();
                    testLabel.Text = sb.ToString();
                }
            });

            this.Controls.Add(testLabel);
        }
    }
}


VS 2008 Tip: If like me, you often end up with a list of 'using' statements as long as your arm, try the following: Highlight all your 'using' statements, then, select Edit -> Intellisense -> Organize Usings -> Remove and Sort :-)

When you have your Web Part building successfully, do the following:

* Select Build -> Package Solution
* If you have already deployed, select Build -> Retract Solution
* Deploy Web Part

You may get the following error:

Security Error Message

To get around this, you need to open your AssemblyInfo.cs file (in the Properties folder) and add a System.Security.AllowPartiallyTrustedCallers assembly attribute. The framework will not by default allow an assembly that is not fully trusted to call another assembly that is not fully trusted. However, by adding this attribute we are telling the framework that it is okay to call other assemblies from this one. See below.

[assembly: AssemblyTitle("TestWebPart")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("TestWebPart")]
[assembly: AssemblyCopyright("Copyright © 2009")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: System.Security.AllowPartiallyTrustedCallers]


Add Web Part

Upon redeployment, you may get the unexpected error page. If you check the event viewer Windows application log file, it should contain the following:

Request for the permission of type 'Microsoft.SharePoint.Security.SharePointPermission, Microsoft.SharePoint.Security, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c' failed.

If you check the web.config file located in $Drive:\inetpub\wwwroot\wss\VirtualDirectories\80, and you will notice that VSeWSS had indeed added a safe entry for the Web Part:

</SafeControls>
  ...
  <SafeControl Assembly="TestWebPart, Version=1.0.0.0, Culture=neutral,     PublicKeyToken=6bbd0bdca0a0fd9e" Namespace="TestWebPart"       TypeName="TestWebPart" Safe="True" />
</SafeControls>


It seems that when opting to deploy to the bin folder when creating the project, VSeWSS does just that and nothing more. VSeWSS still leaves the security options to us, which is the correct behaviour one would expect. By default, SharePoint Web applications are only allowed to run with a very restrictive trust level of WSS_Minimal. If we want to have our Web Part deployed to the bin folder, then in order for it to run we must do one of two things: either set the trust level to WSS_Medium or WSS_Full in the web.config, or create a custom CAS policy that will allow this assembly's managed code to run. We will up the level to WSS_Full here. In a production environment, you will need to make an informed decision on this yourself.

With the trust level updated, bear in mind that there may be other errors waiting for us. To view meaningful error messages in the browser rather than the unhelpful 'unexpected error' page, update the following in the web.config file:

* customErrors=off
* Enable Stack Traces by adding CallStack=”true” to the SafeMode tag
* Set the compilation debug attribute to "true"

You should now be able to view the Web Part. If you can't, I take no responsibility ;-)

Custom Web Part

If you decide to implement your own code access security policy, then this should be of help.

Update - 06-19-2007:
The following code from above does not play nice when deployed to a different machine:

using (SPSite site = new SPSite("http://" + System.Environment.MachineName))
{ ... }

Change it to the following:

using (SPSite site = new SPSite("http://" + HttpContext.Current.Server.MachineName.Trim().ToLower())) { ... }

kick it on DotNetKicks.com   vote it on Web Development Community   411ASP.NET


Tags:
Categories: SharePoint
Actions: E-mail | Permalink | Comments (4) | Comment RSSRSS comment feed

Create a Web Part with VSeWSS 1.3 - Part I

January 21, 2009 23:24 by agrace

Well, I'm back... they finally coughed up the ransom! Truthfully, I've been busy and have wanted to put this particular post together for some time. Since It's still a work in progress, I decided to divide it up into a series. That way I can't procrastinate any further! I have limited experience with SharePoint development in general. I have never created a custom CAS policy and I am using the 1.3 version of the VS extensions for the first time, so it should be interesting.

VSeWSS 1.3

Many developers are overwhelmed by the plethora of tools out there right now for creating and deploying simple components in SharePoint. My personal favorite so far has been STSDEV although I had some problems with the most recent version. At the end of the day, I decided to either hand-roll my Web Parts and deploy with STSADM, or use the Visual Studio Extensions. The reason a lot of people have used tools other than VSeWSS is because the the extensions have been considered pretty limited up to now. But that seems to be changing and version 1.3 has some really cool features.

VSeWSS 1.3

You can download the extensions, both 32 bit and 64 bit, as well as the pre-release notes. Uninstall version 1.2 first, if you already have it installed.

We're going to take the new 1.3 CTP of Visual Studio Extensions for VS 2008 for a test drive. We will create a custom Web Part which will display some data from an XML file. We will deploy our Web Part to the bin folder rather than than to the Global Assembly Cache (GAC); deploying to the GAC involves resetting IIS which is impractical if you have a production environment with a single Web Front End (WFE) server. In order to run this code from the bin folder, we will create a custom code access security (CAS) policy.

VSeWSS 1.3

When you opt to create a new Web Part project, you will be presented with the New Project dialog box. Opt to deploy to the bin folder. Your Solution Explorer window and WSP View should now resemble those in the diagrams shown.

VSeWSS 1.3

In the next part, we'll take a look at the architecture of Features in general; the aim is to keep this as simple as possible and get something up and running. The most common problems people are having are security-related. We will look at this more closely and set out the steps necessary to enable your code to run in a secure environment. In the meantime, you can study up on the use of Features.

kick it on DotNetKicks.com   vote it on Web Development Community   411ASP.NET


Tags:
Categories: SharePoint
Actions: E-mail | Permalink | Comments (3) | Comment RSSRSS comment feed