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.
Sunday, December 28, 2008
How to Build a SharePoint Development Machine
Posted by
sivashiva
at
5:35 AM
11
comments
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).
Posted by
sivashiva
at
3:33 AM
1 comments
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.
Posted by
sivashiva
at
3:10 AM
0
comments
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.
Posted by
sivashiva
at
2:11 AM
16
comments