Sunday, December 28, 2008

How to Build a SharePoint Development Machine

There are two choices: You can build a SharePoint server that contains all your developer tools too. Or you can build your SharePoint server in a virtual machine (VM or VPC), and keep all your developer tools local. Then you can treat your virtual machine just like a physical server, and surf or demo it just as you would a production environment. This way you avoid all the inconsistencies that come with running browser session on locked-down web servers, don’t fill your server’s GAC with quite as much junk, and really get the client experience. You can use this post as a starting point to build either.
This post describes the tools you will use. There are always others, so go ahead and tell me about yours in the comments section. I’ve left off CSS and XML editors because frankly the best aren’t free. Even though a few items listed here are commercial products (e.g. Visual Studio), all have evaluation versions that last long enough for you to learn the ropes and prepare for that first big SharePoint interview.

Client Hardware

The biggest controllable factors on the speed of your SharePoint development environment are RAM and hard drive speed. If you do a lot of development, you will also want a lot of storage space to hold all those virtual machines.
The configuration described here is intended for a good laptop, which today is limited to 4Gb RAM. If you have 4Gb, give the virtual machine 2Gb. If you have 3Gb, give the virtual machine either 1.5Gb or 2Gb. If you have 2Gb or less, buy more RAM or host your virtual server elsewhere. Seriously.
If you need Exchange Server for any reason (1 to 2Gb recommended), you’ve grown out of laptop labs and should build this on a Virtual Server (or VMWare) host if you want some hair left over when you’re done. To build medium or large farms in a virtual environment, Virtual Server running on a 64-bit Windows 2003 Server R2 machine will remove your memory limitations. A 64-bit Vista machine provides the same expandability with Virtual PC or VMWare.
There are several factors to hard drive speed: keeping your VM on a different drive than your OS, drive transfer rates, and drive speed. Put another way: you want a big fast external drive. You can get a pretty big drive for around $200CAD now (I like my Seagate), and an enclosure with Firewire or eSATA (external SATA) is about $50CAD. If you don’t have Firewire or eSATA on your laptop you’ll need an adapter for that as well (also $50). Why not USB 2.0? Firewire is 33% to 70% faster than USB depending on the operation. eSATA is about five times faster than USB 2.0. While many enclosures also have a USB port, the difference is well worth it. PCMCIA (CardBus) runs at 132Mbytes per sec so an adapter for any of these will treat you fine. Note that newer laptops may have an ExpressCard slot instead of a PCMCIA slot.
Technology Transfer Rate (Mbits per second)
USB 2.0 480
Firewire 800 786
eSATA 1500 to 2400

Minimal Configurations

The assumption is that you know what you like, know what you want to do, and will download and install accordingly. That said, maybe you really do want to develop with Notepad so here goes.
On your development machine you need the .Net Framework version 3.0 and a development interface (IDE), whether it’s Visual Studio, SharePoint Designer, or a plaintext editor like Notepad. If you don’t have a physical server available, you will use either Virtual PC or VMWare to host SharePoint. Beyond these, everything is optional.
On your server, you need Windows Server, IIS, the .Net Framework version 3.0, and either WSS, MOSS Standard, or MOSS Enterprise.
Building the Client
.Net Framework 2.0. This is optional, but if you do any development beyond SharePoint you likely have clients on v2.0.
.Net Framework 3.5
WPF, WCF, and essential to SharePoint: Workflow. Note that MOSS 2007 works great with .NET 3.5, is supported by Microsoft, and there is no reason not to deploy it for all your servers.
[Update 2008-11-04] Do not install .NET 3.5 SP1 if you require Records Center, and until the cause is identified there is a risk that other features are also affected. .NET 3.5 itself remains okay, this issue is only reported with SP1.

Microsoft Office SharePoint Server 2007 SDK [Read it online]
The MOSS SDK includes the Enterprise Content Management (ECM) Starter Kit, a BDC definition editor, an Excel UDF sample, great workflow samples, and lots more.
Windows SharePoint Services (WSS) 3.0 Software Development Kit (SDK) [Read it online]
The MOSS SDK contains this so you don't need both. If you only do WSS development, then you only need the WSS SDK.
Red Gate .NET Reflector (was Lutz Roeder's Reflector)
One of the best .NET tools ever, and the way you'll browse object models and cut the class-assembly strings you'll need to paste into your manifests and web.config. “Reflector is a class browser, explorer, analyzer and documentation viewer for .NET. Reflector allows you to view, navigate, search, decompile and analyze .NET assemblies in C#, Visual Basic and IL.”

SharePoint Manager 2007

The best SharePoint management tool there is. Browse the complete object model, deactivate features, and even update object properties. You do need to be careful with this one, but wow it's powerful.
Office System Professional Plus Edition
Grab your disc, MSDN, or get the evaluation version. The Professional Plus edition includes Word, Excel, Outlook and PowerPoint plus: Access, Publisher and InfoPath. There is also an Enterprise edition which also includes OneNote and Groove.

SharePoint Designer (SPD)

Grab your disc, MSDN, or get the evaluation version.
Visual Studio 2005 or 2008
Grab your disc, MSDN, or get the evaluation version. I prefer either VS Professional or VSTS Developer Edition.
Visual Studio 2005 Extensions for .NET Framework 3.0 (Workflow Foundation)
Not required with VS 2008 where these features are baked-in. Design Windows Workflow Foundation solutions for SharePoint and other .NET applications.
Visual Studio 2005 Tools for the 2007 Microsoft Office System (VSTO)
VSTO is used to build: Office System (Word, Excel, etc.) Add-ins and Ribbon elements, Outlook forms, and InfoPath templates.
Other Visual Studio Extensions. Optional extensions are available unrelated to SharePoint, though you should know they exist if you do other .NET development.

Virtual PC 2007

This is where you will build all those beautiful webs! VMWare is a popular alternative.
SQL Server Express Edition
You may want SQL Express if you develop more than SharePoint and need a local data store. If not, it is built into the SharePoint standalone install so you do not need to download or install it locally.

Optional
Fiddler HTTP Debugger
Optional and strongly recommended. Inspect and manipulate HTTP traffic between your browser and the server, great for debugging forms and web services, determining whether Kerberos tokens are being generated, and more.
Internet Explorer Developer Toolbar
The IE Developer Toolbar is optional, but recommended. Inspect HTML source, style usage, IFRAME content, image locations, and more.
PowerShell (formerly Monad). [SharePoint Provider] [Script Repository]
PowerShell is optional, but recommended. Write scripts to automate administration and configuration tasks. Colin Byrne has posts to get you started: PowerShell and SharePoint, Build Me A Portal, and Upload a Directory in 4 Lines.
BDC Metadata Manager
Generate BDC XML from SQL data sources. The commercial version also builds definitions for web services. An alternative is baked into the MOSS SDK, but BDC Metaman will continue to be the gold standard.
Visual Studio 2005 Extensions for Windows SharePoint Services 3.0 (VSeWSS)
Not recommended. VSeWSS contains nothing to help you deploy features on anything but the machine running VS, does not support x64, and is required to open projects that it creates. So if you create a project today on a 32-bit machine, you will be unable to open it in a year when you're building on 64-bit. This is bad. The one good feature included is the SharePoint Solution Generator (SPSolGen) which converts lists and sites “Saved as Template” into list and site definitions. [Learn more here] [Registry hack to install VSeWSS to a machine that is not the server]

Required to create a private LAN between the client and server

Microsoft Loopback Adapter
a. Click Start, Control Panel, and open the Add Hardware wizard.
b. Click Next. Wait a moment while the wizard scans for hardware.
c. Select: Yes, I have already connected the hardware, click Next.
d. Scroll to the bottom of the list and select Add a new hardware device. Click Next.
e. Select: Install the hardware that I manually select from a list (Advanced). Click Next.
f. Select: Network adapters. Select: Microsoft. Select: Microsoft Loopback Adapter.
g. Click Next. Click Next again. Wait a moment. Click Finish.
Configure the Loopback Adapter
h. Click Start, Control Panel, and open the Network Connections utility.
i. Right-click the Microsoft Loopback Adapter connection and select Properties.
j. Double-click Internet Protocol (TCP/IP).
k. Now configure an address for this adapter.
Select: Use the following address
IP Address: 10.50.50.1
Subnet mask: 255.255.255.0
Default gateway:
You can ignore DNS. Click OK. Click OK again.

Building the Server: Articles
Bob Fox explains step-by-step how to install Windows 2003 to Virtual PC and VMWare (up to the point where you install the OS).
Bob Fox explains good habits on re-using your base image for several implementations, and why you might need to add servers to the farm (e.g. for Exchange).
How to Create a MOSS 2007 VPC Image. This step-by-step series with screenshots by Tony Zink is as complete as complete can be and starts with configuration of IIS. Note that he puts SPD and Office on the server, while the goal of this post is to keep your server clean of client apps.
Microsoft Guidance on Standalone and Farm configurations.
Kevin Hoffman explains how to build a Standalone SharePoint server. He installs Visual Studio to the server, you can skip that step and run it locally on your development machine.
Jonathan Bradshaw explains how to build a Small Farm configuration with SQL and AD on a separate machine. His “OfficeDev” machine looks the most like our local development machine. One day someone will write an article with configuration steps, until then this is a good start.
Building the Server: Step-by-Step

Step 1: Install the Operating System

Windows 2003 Server R2. Grab your disc, MSDN, or get the evaluation version. Bring the machine up-to-date with Windows Update. Note that this process can last several hours.

Step 2: Configure Networking

R. Aaron Zupancic describes how to configure an IP address and host file entry so you can surf your virtual SharePoint sites from your development machine.
Simon Guest describes how to get all the machines in a virtual farm to talk to each other. In this configuration, while your virtual machines will see each other, your local machine will not be able to surf or debug the virtual machines.
Note that if you can join your virtual machine to your company’s domain and create domain accounts there (but different accounts than you will use for testing or production), it will simplify configuration and debugging, and you won’t need to make this or any machine in your development farm an Active Directory domain controller (DC). The drawback is that you need to be connected to the domain to get any work done.

Step 3: Install the .NET Framework

.Net Framework 3.0
WPF, WCF, and essential to SharePoint: Workflow.
Once activated and configured, Shut Down and back up your base server image. In the next steps you’ll prepare this machine for a specific purpose.

Step 4: Install Active Directory and DNS.

If this is going to be a Standalone configuration, you need a domain controller (DC). The Configure Your Server Wizard (Start, Administrative Tools) is a great way to assign roles to a server. Start with Domain Controller (Active Directory) and DNS.
If this is going to be a Small Farm, copy your base server image from the last step, and start building a second machine to host Active Directory and SQL Server. Note that after you install SharePoint you will not be able to make the machine a domain controller (unless you’re prepared for a world of hurt).

Step 5: Install Internet Information Server (IIS)

Once again, the Configure Your Server Wizard (Start, Administrative Tools) is an easy way to add the Application Server role to your VM.
Once IIS is installed, you will need to Allow ASP.NET 2.0.* in the Web Server Extensions section of the IIS Manager. If this option is not available, you may need to run the ASP.NET 2.0 setup and Repair your installation, which also sets the Allow flag.

Step 6: Install SQL Server

SQL Server Developer Edition
This is optional. If you don’t install it, Express Edition will be installed when you install SharePoint. However, Developer Edition includes the excellent SQL Server Management Studio, so if you have MSDN you may prefer it. For a production environment you will need to license SQL Server Standard or Enterprise Edition.

Step 7: Install SharePoint (WSS or MOSS)
Windows SharePoint Services (WSS) 3.0
WSS is a free extension to Windows Server. If your installation didn’t include WSS as an option, you can download now. If installing MOSS, then you do not need to separately install WSS. Also remember that you can upgrade a server, but you cannot downgrade from MOSS back to WSS. If you’re evaluating SharePoint you may want to start with WSS.
If you installed SQL Server Developer Edition, choose Advanced Installation to select your database.

Install the WSS Service Pack.

Microsoft Office SharePoint Server (MOSS) 2007
Grab your disc or MSDN, or get the evaluation version. Standard and Enterprise editions exist, so again keep in mind that you can upgrade but not downgrade. Enterprise includes Forms Server and the BDC.
Install the Office SharePoint Server Service Pack. [SP1]
Shut down and back up your virtual machine image(s).

Step 8: Configure SharePoint

Create a domain group for SharePoint Administrators, assign rights to it rather than any single account. The exception will be configuring SQL Server, where rights buried inside groups aren't always resolved and you need to assign permissions per-account.
Create an account to use as your SharePoint Service account (e.g. SPService). Configure this to be your Application Pool identity (you'll need to search what rights are required until I complete this section).
Create a content crawler account (you'll need to search what rights are required until I complete this section).
Create a developer account with the same name as the account you use on your development machine (and it better not be Administrator). Add your developer account to the Administrators group (Global Administrators if this is a DC, local Administrators if not) and Debugger Users group.
Create a typical end-user account for testing. Make it a member of Domain Users.

Step 9: Configure the server for Development

If you must develop on the server, install Visual Studio now. On one side, developing locally is simpler than developing remotely. On the other side, it’s so handy to keep all your code in one place and you won’t ever wonder where the most recent version of x is residing. If you really can’t get the hang of remote debugging, you can always install VS later.
Open up File Explorer on the server and Add to Favorites your frequently-used paths including the 12 hive and the default web root.
C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\
C:\inetpub\wwwroot\
Backup the 12 hive into a zip file marked as read-only, and named “[Drive]:\Backups\12Hive-Out-of-Box-DoNotUpdate.zip”. You get the idea. When you accidentally edit a default ONET.XML file with WordPad and kill your site you will be glad you did.
And finally, make a text file on your desktop with Joubin’s SharePoint paths.

Step 10: Configure remote debugging.

Once SharePoint is installed, share the folder with SharePoint’s assemblies (*.DLL). You may also want to copy the assemblies to your development machine:
C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\ISAPI
Share the server’s web root and enable Read/Write.
C:\inetpub\wwwroot\
Install the Visual Studio 2005 Debugging Components to the server. You want Full Remote Debugging, not Native Remote Debugging.
Follow Ross Dargan’s instructions on configuring remote debugging. You’ve just completed his step 1 and if you created your developer account as specified then you’ve also done 2 and 3.
Take a look at Andrew Noon’s document on Remote Debugging SharePoint Web Parts. He has additional steps for enabling error messages in web.config and screen shots that show what debugging looks like in action.
Read: Setup Remote Debugging
Read: Debugging SharePoint Web Parts

Acknowledgements
Thanks to the MOSS MVPs for suggesting ways to improve this post.
Thomas Lloyd was one of the first people to build minimal servers, and he’s always got great new gadgets like eSATA drives.

Wednesday, December 24, 2008

Modifiers - Abstract, Sealed, Static

C# provides many modifiers for use with types and type members. Of these, three can be used with classes: abstract, sealed and static.

Abstract
Indicates that a class is to be used only as a base class for other classes. This means that you cannot create an instance of the class directly. Any class derived from it must implement all of its abstract methods and accessors. Despite its name, an abstract class can possess non-abstract methods and properties.

Sealed
Specifies that a class cannot be inherited (used as a base class). Note that .NET does not permit a class to be both abstract and sealed.

Static
Specifies that a class contains only static members (.NET 2.0).

Structs vs classes in C#

Structs may seem similar to classes, but there are important differences that you should be aware of. First of all, classes are reference types and structs are value types. By using structs, you can create objects that behave like the built-in types and enjoy their benefits as well.
• When you call the New operator on a class, it will be allocated on the heap. However, when you instantiate a struct, it gets created on the stack. This will yield performance gains. Also, you will not be dealing with references to an instance of a struct as you would with classes. You will be working directly with the struct instance. Because of this, when passing a struct to a method, it's passed by value instead of as a reference.
• Structs can declare constructors, but they must take parameters. It is an error to declare a default (parameterless) constructor for a struct. Struct members cannot have initializers. A default constructor is always provided to initialize the struct members to their default values.

• When you create a struct object using the New operator, it gets created and the appropriate constructor is called. Unlike classes, structs can be instantiated without using the New operator. If you do not use New, the fields will remain unassigned and the object cannot be used until all the fields are initialized.
• There is no inheritance for structs as there is for classes. A struct cannot inherit from another struct or class, and it cannot be the base of a class. Structs, however, inherit from the base class object. A struct can implement interfaces, and it does that exactly as classes do,
• Structs are simple to use and can prove to be useful at times. Just keep in mind that they're created on the stack and that you're not dealing with references to them but dealing directly with them. Whenever you have a need for a type that will be used often and is mostly just a piece of data, structs might be a good option.

OOPS - Access Specifiers

“The ability to define a class and create instances of classes is one of the most important capabilities of any Object Oriented Language”

Q: How will you define a CLASS ?
A: All classes in Visual Basic. NET are defined in a .VB file (as oppose to .CLS file in vb6), Also .VB file may contain one or more classes. The basic syntax of a class is as follows:

Class ClassName

End Class

PublicProtectedFriendProtected FriendPrivate Class Vehicle

End Class

Q: List All Class Access Specifiers?
A: There are five access specifiers in Visual Basic .NET defined as follows:

Public – Applied at the class level and is the most common specifier. Public Classes are classes that are intended to be used by any consumer.

Public Class PubClass
End Class

Protected - can only be applied to Nested Classes. Are only accessible within the class and within the child classes.

Public Class HasProtected
Protected Class ProtectedClass

End Class
End Class

Friend – Are accessible only within the program in which they are defined. If you add the Friend access specifier to a class definition, instance of that class can only be created from within th same program.

Friend Class FriendClass
Public Shared Sub PublicMethod()
MsgBox("FriendClass.PublicMethod")
End Sub
End Class

Protected Friend - Represents a union of the Protected and Friend Specifiers. Protected class must be nested class, thus Protected Friend class must be nested too.

Public Class HasProtectedFriend
Protected Friend Class ProtectedFriend
Public Shared Sub Test()
MsgBox("test")
End Sub
End Class
End Class

Private – Can only be applied to a nested class. A Private nested class represents implementation details of the class. When you have complex problem that requires more problem solving horsepower then simple methods can provided, defining a nested private class that implements the abstraction.
Public Class HasPrivate
Private Class PrivateClass
End Class
End Class

Q: What is a Field?
A: Field is a Data Member of a class. Fields can be ValueType members, like Integer or Dates, or can be aggregate types, like structures or classes.

Q: What is a Property?
A: A Property is a special member constructor that is used like a field, but acts like a method. Properties are special kind of methods that generally are used to provide constrained access to Field.

Q: What are the Indexed Properties?
A: Indexed Properties are simply property methods that have a mandatory parameter. The mendatory parameter is semantically treated like an index Index properties has an argument between the parentheses. This argument doesn't represent the field value; rather, it represents an index to an underlying field value. The fundamental idea behind indexed properties is that you can wrap arrays and other kind of collections of data safely behind property methods.

Public Class Indexed
Private FStrings() As String = {"One", "Two", "Three"}

Public Property Strings(ByVal index As Integer) As String
Get
Return FStrings(index)
End Get
Set(ByVal value As String)
FStrings(index) = value
End Set
End Property
End Class

'//useage
'Msgbox(objIndex.Strings(1))

Q: Explain Default Properties?
A: Default Properties must be indexed properties, you can have only one default property per class and you can invoke property setter and getter methods on a default property using the verbos or shorthand form.

Public Class Indexed
Private FStrings() As String = {"One", "Two", "Three"}

Default Public Property Strings(ByVal index As Integer) As String
Get
Return FStrings(index)
End Get
Set(ByVal value As String)
FStrings(index) = value
End Set
End Property
End Class

'//useage
'Msgbox(objIndex.Strings(1))
'Msgbox(objIndex(1)

Q: What are ReadOnly, WriteOnly and Shared Properties?
A: Read Only property is a property that can be used as an r- value only. That's why a property statement that includes a read only modifier will generate a getter block only and users can evaluate this property but can not modify it.

Public ReadOnly Property Strings(ByVal index As Integer) As String
Get
Return FStrings(index)
End Get
End Property

Write Only – is a property that a consumer can modify but can't view. This implements a property setter only.

Public WriteOnly Property Strings(ByVal index As Integer) As String
Set(ByVal value As String)
FStrings(index) = value
End Set
End Property

Shared Property – is a property that a shared members can also be invoked using instances.

Public Property Strings(ByVal index As Integer) As String
Get
Return FStrings(index)
End Get
End Property

Q: What is Constructor and Destructor ?
A: A constructor is called to Initialize a class. A destructor is called to Finalize the class. Visual Basic.NET implements the constructor as Sub New and Destructor as protected method Sub Finalize().

Q: what is MyBase and MyClass?
A: MyBase allows you to invoke methods in your class's Base Class that may be overloaded in your class, resolving any name ambiguity.

MyClass is roughly equivalent to the Me reference to self.

Q: what is Method Overloading?
A: Method Overloading means to have two or more methods in the same class with different signature. The benefit of method overloading is that it allows you to implement methods that supports the same semantic operation but differ by argument number or type.
Public Overloads Sub GetCustomer(ByVal strCustomerName As String)
End Sub

Public Overloads Sub GetCustomer(ByVal iCustomerID As Integer)
End Sub

Q: what is Method OverRiding?
A: Method Overriding changing the behavior of a method in a base class. Use keyword Overrides.

Q: what are Overridable, MustOverride and NotOverridable modifiers?
A: Overridable – modifier indicates that a method can be overriden.
NotOverridable- modifier indicates that you can not override a method.
MustOverride- modifier indicates that a method is abstract, and child class must implement the MustOverride method in a parent class.

Q: what Shadows modifier?
A: Shadows – if you want a child class to use a name previously used in a parent class, use the Shadows keyword to do so. Shadows keyword simply allows you to reintroduce a previously used name in the child class without a compiler error.


Partial Classes Concept in Asp.Net 2.0One of the language enhancements in .NET 2.0 - available to both VB2005 and C# 2.0 programmersis support for partial classes. In a nutshell,

Partial classes mean that your class definition can be split into multiple physical files. Logically, partial classes do not make any difference to the compiler. During compile time, it simply groups all the various partial classes and treats them as a single entity.

Benefits of Partial Classes One of the greatest benefits of partial classes is that they allow a clean separation of business logic and the user interface (in particular, the code that is generated by the Visual Studio Designer). Using partial classes, the UI code can be hidden from the developer, who usually has no need to access it anyway. Partial classes also make debugging easier, as the code is partitioned into separate files. This feature also helps members of large development teams work on their pieces of a project in separate physical files.

Tuesday, January 29, 2008

Guide to Setting up SharePoint Virtual Dev Environment

Setup
This assumes that you’ll be using a virtual server type of software (Virtual PC, Virtual Server, or VMWare). Makes no difference but I prefer Virtual PC for now as I can drag and drop files from my desktop into it. Virtual PC and Virtual Server images are compatible so you can build in VPC and use it in Virtual Server if you want. I generally give the VM 1–2GB of RAM as its going to be running everything (Windows Server, SQL, SharePoint, Visual Studio, etc.) so it’ll need it (1GB when I run on my laptop which has a max of 2GB, and 2GB to the VM when I run on my desktop which has a max of 4GB).

I generally don’t keep source code in my VM (or it’s very temporary, say for demos) so I keep it generally on an external drive. This drive is shared to the VM as the Z:. Also keep your VHD files (Virtual Hard disk, or whatever VMWare uses) on an external drive. Mucho better performanco.

Also this a workgroup install rather than a domain controller. Some people like having a DC running with SharePoint but I like to keep it separate. You can also spin up a domain controller VM and connect the machine to the domain through the local network later.

Installing
Okay, here’s the rundown of what gets installed. Some things can be shifted around in order of preference, but obviously you can’t install SharePoint before you install SQL Server. Again, feel free to move things around as you see fit.

No detailed instructions for installing most of this (but feel free to ask for clarification on anything, as some of it might not make much sense). Just follow the wizards entering whatever information is needed and you can generally accept the defaults. Really, it’s not that complicated. Also I make things easy for development like creating a single user for everything and just giving them admin rights to the box. In a real setup you would have domain accounts and only grant them the rights they need in SQL Server. I just find having as few things possible make it easier for development (and we’ll worry about configuration later in the test/production environment).

Windows Setup

Install Windows Server 2003 Standard Edition. Any edition will do, but this one works fine.
Install Windows Server 2003 Service Pack 1
Create local spadmin account on the machine. Add to the Local Administrators group. This will be used for all portal functions.
Create local spuser account on the machine. You can use this as a reader or contributor on your sites for testing (and feel free to create more, but I find two is enough)
Setup IIS. Just the basic options are needed here.

Remove event tracker shutdown dialog. What a PITA this thing is for development.
I prefer to browse to http://machinename rather than http://localhost. Add machinename to trusted sites in IE for this to work. This will eliminate the NT challenge/response dialog when you browse to the site, and all urls will be better formed.
Edit the command prompt to add QuickEdit. Just handy when copying/pasting things like wp part packs in the command window.
Mail Server

Install hMailServer. This is a free (open source) SMTP/POP3 server that I use instead of Exchange. Lightweight and free. Alternately you can install Exchange if you really want to.
Add a catch all account to the mail server – admin@yourdomain.com. This will be used for any mail to/from the Portal or WSS sites.
Add user account – username@yourdomain.com. This is attached to the user account for the portal (or you can use admin for everything)

SQL Server

Install SQL 2000. Standard OOTB install, configure it to run in mixed mode. I use SQL instead of the built in MSDE so I do testing with full text searches.
Install SQL 2000 SP4.

SharePoint Install

Install SharePoint Portal Server 2003 without the database engine. We’ll connect it to SQL during setup phase.
Configure and create the initial portal. Name it whatever you want like “Development Portal”, “My Little Pony”, “Big Man Hands”, whatever.
Use the spadmin account name you created above for all operations.
Use localhost for the mail server.
Give spadmin email address of admin@yourdomain.com.
Add machinename\spuser (spuser@yourdomain.com) as reader to the portal.
Install WSS SP2. Have to install this before we install SPS SP2.
Install SPS SP2.
Add shortcut to 60 HIVE directory on desktop or QuickLaunch. I just find it a pain to navigate down the ugly tree anytime I need to hit the directory in Explorer so having a folder that goes directly there is handy.
Add STSADM dir to path in command prompt. I find this very handy so I can open up a command prompt and just start typing STSADM rather than the full path. Optionally you can install STSADMWin or whatever. I’m just a command prompt kinda guy

IIS Configuration

Change WSS_Minimal in web.config to Full. This is required to set debugging=true and makes life easier.
Set debug=true in compilation section of web.config for debugging Web Parts

Visual Studio Setup

Install and Configure Visual Studio 2003. I just select the default which includes C# and VB.NET but you do whatever works for you.
Copy keyboard shortcuts (so ReSharper can install, if you’re installing it)\
Install Web Part Templates for Visual Studio .NET. These are the templates for creating new Web Part Library projects.
Install ReSharper. Set the persistence to use the local drive (this is for performance of local files vs. remote). I prefer ReSharper but some like CodeRush, Refactor Pro!, and other tools.
Install GhostDoc. I use this for creating stub documents for APIs and Web Parts that I’ll be sharing.
Install TestDriven.NET. Killer app for TDD and running unit tests. Also includes NCover now.

SharePoint Tools

Copy InstallAssemblies (from the Web Part Toolkit) to server and add to QuickLaunch. You just need the EXE and I like having it on the QuickLaunch taskbar as I can just click on it and install a web part quickly.
Install SharePoint Explorer. Best tool for looking at what you have.
Install SmartPart (if you’re planning to do development via User Controls)
Office 2003

Install Office 2003
Install FrontPage 2003
Install Other Tools

TopStyle : I use this for editing CSS files but feel free to use Visual Studio (blech) or your own CSS editor (Notepad anyone?)
XmlSpy : This comes with a cost, but it’s worth it for Xml editing. There are some less expensive packages and then there’s always… Notepad!
IE Dev Toolbar : Very handy for debugging pages and poking around in SharePoint sites.
Notepad++/Notepad2. I prefer these over the standard Notepad.
Paint.Net if you plan on making your own icons or graphics. Free and written in .NET!
SysInternals BGInfo. I have this in my startup for the server as it shows me what the server name is, IP, and other info that is handy when you’re flipping around between machines.
Plus any other tools you like. Scott Hanselman’s list here is a great resource.

Testing

Create a new web part using the template (Hello World or something)
Install using InstallAssemblies. This will add it to the bin dir and create the SafeControl entries in web.config so the web part will work correctly.
Add the web part to a page somewhere.
Run Web Part project in Visual Studio with debugging to make sure debugging works
Create an alert, open up Outlook Express and configure it to use your local mail server (if you installed it). You should receive an alert.

Security and Source Code

When working in a VM you generally do NOT want your source code to be in the VM (just in case it turfs and you can’t recover it) so I keep all my source on an external drive (rather than say the host drive as I move from place to place). I also only have it set to use Local networking meaning it can’t see out and I can’t see in (which is why I prefer Virtual PC so I can drag/drop files to the VM). This allows me to have a domain controller on the local network if I need it.

With Virtual PC you can share this drive as a network drive letter inside the VM (my external drive is always Z:. In order to open files and not get the dreaded “the project location is not fully trusted” you need to fix security policy if you want to open files from a network drive. Google "the project location is not fully trusted" and you’ll get a ton of answers. Problem is that none of these work for a drive that is mapped into a VM. A drive shared shows up in the Intranet Zone. Bizzare huh? Means you have to trust the entire internet zone. Not a good thing. Can’t use z:\\, have to use file:// but there is no file:// for a mapped drive (because there is no server name).

James Kovacs says to use ZoneStripper but I really don’t want to do this with each project so the technique below works well:

Open the ".NET Framework Configuration" utility
Expand "Runtime Security Policy->Machine->Code Groups"
Right click "All Code", and then select the "New..." item
Type a name in the "Name" textbox (like “VS Projects on Z:“ or something), and then click the "Next" button
Set the condition type to "URL" and type the following string to the "URL:" textbox: “file://Z:/*”
Click the "Next" button and assign the "FullTrust" permission set to this Code Group.
This will trust all code on Z: and not display the dialog. You can also use file://servername/* but since we’re working with a drive letter here, we don’t have a server name.

I also run regular scheduled backups of my external drive to whatever host it’s connected with using SyncToy so I generally always have 3 copies around (1 on laptop, 1 on desktop, 1 on drive) and do make weekly DVD backups of the source and CVS trees.

Tips and the Afterlife

After your environment is setup, all the tools are running, and you’re happy with what you have created SAVE IT! Snapshot that puppy so you can come back to it. Some people might prefer to use undo disks but again, I find these sometimes have issues so I just copy the whole dang VHD file as an archive in case the worst happens.
Setup a Development Area in the Portal. Two things I do as a final step in getting things up and running on the portal. If I installed SPS then I create an area called Development. This is just a collection of sub-areas for various projects, spike web parts, whatever. It leaves the rest of the default portal setup intact as I don’t need to build a taxonomy that represents a production site or anything. If I need something like that (for example to demo what a sample navigation structure might look like) I’ll just create a new Virtual Server in IIS and create a portal off it. I keep the main portal on port 80 for general development.
Another thing I do is copy the STS definition and create a new STSDEV site def from this. Not much is changed in the definitions but I do go in and add a top and bottom zone to the default.aspx page. This lets me a) screw around with any list definitions without touching the default STS one and b) have some extra zones to mess with in case I want them. I also setup 10 pages in the default module which are copied at creation time. These are placeholder pages (copied from default.aspx) which I can use instead of web part pages and are ghosted so I don’t worry about them showing up in something like Ghost Hunter. Finally I create a new site called Sandbox using this config and add it to my Development section in SPS as a listing to quickly get to it. For most web parts, I develop them so they work in both a SPS area and a WSS site (unless it has SPS specific stuff).
Okay, now go start using your portal for development. It’s complete, self-sufficient, and have fun

Sunday, January 27, 2008

Setting Up SharePoint To Use MSSQL Server

This post gives you information on how to install Microsoft Windows SharePoint Services on your Windows 2003 web servers.

According to Microsoft, Windows SharePoint Services technology "is an integrated portfolio of collaboration and communication services designed to connect people, information, processes, and systems both within and beyond the organizational firewall. SharePoint sites provide a central repository for documents, information, and ideas, and enable users to work interactively with these items."

Currently we support Windows SharePoint Services v2 with Service Pack 2. Support for later versions is coming soon.

Pre-Installation Requirements
SharePoint Installation and Configuration
Install MSSQL Server
Select Authentication Mode for SQL Server
Install SharePoint
Configure H-Sphere to use SharePointB

Pre-Installation Requirements
Before you install Microsoft Windows SharePoint Services on your Web server, make sure that you have installed the required hardware and software.

Required Details
Important: SharedPoint and MSSQL should be installed on one and same physical server.
Server Hardware Intel Pentium III (and later) compatible processor
CPU/550 MHZ 1 CPU (2 recommended)
512 MB RAM

Operation System Microsoft Windows Server 2003:
Standard Edition
Enterprise Edition
Datacenter Edition

Server Software
(Web application server) NTFS file system
Microsoft ASP.NET
Internet Information Services in IIS 6.0 worker process isolation mode with the SMTP service

Server Databases* Microsoft SQL Server 2000 Service Pack 3 or later**
Microsoft SQL Server 2005

Browser Client Microsoft Internet Explorer 5.01 or later
Microsoft Internet Explorer 5.5 or later
Netscape Navigator version 6.2 or later
Mozilla 1.4 or later


* Microsoft Windows SharePoint Services SQL Server 2000 Desktop Engine (WMSDE) is not supported by H-Sphere


SharePoint Installation and Configuration
To install and configure SharePoint Services, follow the procedure:

Step 1: Install MSSQL Server
Prior to installing SharePoint, you need to install MSSQL Server. You can chose between:

MSSQL Server 2000
MSSQL Server 2005
Step 2: Select Authentication Mode for SQL Server
In order to allow Windows SharePoint Services to connect to your SQL Server database, it is recommended that you configure the SQL Server database to use Windows authentication.

For SQL Server 2000:

On your server computer, go to Start -> All Programs -> Microsoft SQL Server -> Enterprise Manager.
In Enterprise Manager, click the plus sign (+) next to Microsoft SQL Servers.
Click the plus sign (+) next to the SQL ServerGroup.
Right-click the SQL Server name, and go to Properties.
In the Properties dialog box, click the Security tab.
In the Authentication section:
If you want use the MSSQL Server only for Microsoft Windows SharePoint Services, select only Windows Authentication mode.
If you want use the MSSQL Server both for Microsoft Windows SharePoint Services and hosting, select SQL Server and Windows Authentication mode.
Click OK.
Note: If you have used a domain account that does not already have database creation rights in SQL Server, you can give the account this access using Enterprise Manager in SQL Server 2000, as a temporary solution.

For SQL Server 2005

On your server computer, go to Start -> All Programs -> Microsoft SQL Server 2005 -> SQL Server Management Studio.
On the Connect to Server screen, select the name of the local server from the Server name drop-down list.
On the Server Properties - Server name screen, click Security in the Select a page section.
In the Server Authentication section:
If you want use the MSSQL Server only for Microsoft Windows SharePoint Services, select only Windows Authentication mode.
If you want use the MSSQL Server both for Microsoft Windows SharePoint Services and hosting, select SQL Server and Windows Authentication mode.
Click OK.
Note: If you have used a domain account that does not already have database creation rights in SQL Server, you can give the account this access using SQL Server Management Studio, as a temporary solution.

Step 3: Install SharePoint
By default, when you install Windows SharePoint Services, the Setup program installs WMSDE (Microsoft Windows SharePoint Services SQL Server Desktop Engine).
H-Sphere doesn't support WMSDE. To use SharePoint with SQL Server, run Setup with the Server Farm option. Server Farm option allows supporting a larger set of Web sites.

Download and install SharePoint

WARNING:
During SharePoint setup, you may get the error when connecting to http://localhost:SharePointPort/. To solve it, you should remove the string from
C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\60\template\admin\1033\web.config.

Also please check the Authentication Methods for SharePoint Central Administration WebSite in IIS. And if Basic authentication is disabled, enable it.

Go to SharePoint Central Administration:
Start/Settings/Control Panel/Administrative Tools/SharePoint Central Administration
Configure Administrative Virtual Server in the Server Configuration tab:
Select Use an existing application pool and chose StsAdminAppPool
Go to Security Configuration and select NTLM
Click OK
Configure Database Server in the Server Configuration tab:
Select Database Server and enter your MSSQL Server IP or MSSQL instance
In SQL Server database name enter your SharePoint Main DB NAME
Set Windows authentication
In Active Directory Account Creation chose Users already have domain accounts. Do not create active directory accounts.
Click OK
Step 4: Configure H-Sphere to use SharePoint
If you installed Microsoft Windows SharePoint Services after H-Sphere is updated, run the H-Sphere updater again.
Open HSphere.config file usually located in the {disk}\Hsphere.Net\bin\ directory and make sure the correct name of your MSSQL server was set in the SharePoint resource setting during H-Sphere update.
Restart H-Sphere service
net stop hsphere
net start hsphere

Links for more resource

Category Online Location Windows SharePoint Services 3.0 Overview
http://office.microsoft.com/sharepointtechnology

Windows SharePoint Services TechCenter
http://www.microsoft.com/technet/windowsserver/sharepoint/default.mspx

Office SharePoint Server 2007
http://office.microsoft.com/sharepointserver

Office SharePoint Designer 2007
http://office.microsoft.com/sharepointdesigner

Friday, January 25, 2008

Composite UI Application Block

This application block is a reusable, source code–based component based on the Microsoft .NET Framework 2.0. It provides proven practices to build complex smart client user interfaces based on well known design patterns such as the Composite pattern, in which simple user interface parts can be combined to create complex solutions, but at the same time allowing these parts to be independently developed, tested, and deployed.

The Composite UI Application Block is designed to help you build these complex, enterprise-ready Windows Forms–based solutions. It provides a proven architecture and implementation that helps you to build applications using the common patterns found in line-of-business front-end applications.

Common Scenarios

The application block is designed to support the development of smart client line-of-business applications such as the ones found in the following scenarios:

* Online transaction processing (OLTP) front-ends, in areas such as stock distribution centers or data entry applications
* Rich client portals to back-end services, such as portals to government services or bank teller applications
* UI intensive information-worker standalone applications, such as those used by call center staff, IT support desks, or stock traders

All these scenarios require rich user interaction, a shell architecture that can host the user interface and business logic "parts," and varying degrees of centralized control of the functionality and behavior that the application exposes to its users.

The Composite UI Application Block facilitates the design and implementation of your client applications in three areas:

* It allows your application to be based on the concept of modules or plug-ins.
* It allows developers with shell expertise to build components that hide user interface complexity from the business logic development.
* It facilitates development using patterns for loose coupling between modules.

Design Goals

The design of the Composite UI Application Block is based around three main areas:

* Finding and loading modules at application initialization to dynamically build a solution
* Separating development requiring user interface and shell expertise from pure business logic development
* Achieving re-use and modularity of your code by helping with common techniques used for loose coupling


Finding and Loading Modules

A key goal of the Composite UI Application Block is to support the development of applications through the use of independent, but collaborating, modules. This is achieved by:
* An implementation of a catalog that specifies which modules to load.
* A module loader that actually loads and initializes the modules that comprise your application.

These implementations can be customized for your own needs without changing the provided core Composite UI Application Block implementation because all of the main subsystems work as plug-ins. For example, your application could obtain the list of modules to be loaded for a particular user of the application from a centrally managed Web service instead of reading them from a file.

Consolidating User Interface and Shell Expertise

Seldom does every developer of an application have both knowledge of the business logic requirements and deep expertise in user interface or shell development. In large projects, productivity and consistency can be achieved if the developers with expertise in building shells can build reusable components encapsulating that knowledge.

The Composite UI Application Block provides an architecture around these components and an implementation based on Windows Forms. It includes:
* A consistent way of showing and hiding controls using Workspaces. A shell developer can consistently introduce visual effects, layout strategies, or other behaviors without affecting the business logic components.
* A common way of adding and using UIElements into the shell, such as menu items, status bars, so that the developer of an individual piece of business logic does not need to know how or where that element will be shown.
* A Command architecture that allows a business logic developer to separately define actions a user can take and how they are displayed in a specific shell.

Achieving Modular Design of Your Business Logic

The functionality that focuses on helping you achieve loose coupling between your modules includes:

* WorkItems that provide an easy way to scope which collaborating components participate in a use case, share state, events, and common services.
* An Event Broker that provides a many-to-many, loosely coupled event system mechanism between objects in your application.
* Placeholders for sharing State where multiple components can place or retrieve information.

Inherent Extensibility

Internally, the design is based on concepts of services (components that provide an implementation of functionality) and containers (components that hold references to your objects containing business logic, controls, and services). The Composite UI Application Block's extensibility mechanism allows you to add and extend it with your own behaviors and services in the same way it implements its functionality.

Getting Started

The Composite UI Application Block has been developed as a result of analyzing common enterprise development challenges and successful solutions to these challenges. However, because each application is unique, you will have to analyze whether this application block is suitable for your particular needs. To evaluate this application block and determine its applicability to your projects, it is suggested that you dedicate at least half of a day to explore the application block. The following is a suggested evaluation approach:

* Download the code and documentation in the language of your preference.
here is the link to download http://www.microsoft.com/downloads/details.aspx?FamilyId=7B9BA1A7-DD6D-4144-8AC6-DF88223AEE19&displaylang=en
* Install the Composite UI Application Block and compile it.
* Read the "Introduction" and "Scenarios and Goals" sections of the documentation.
* Compile and run the QuickStart samples.
* Start with the "Walkthrough - Designing and Building a CAB Application" QuickStart and read the related documentation.

In next article i will consentrate diffrent types of blocks and their utilities. Keep have a lok on the blog to find some thing interesting :)