Wednesday, February 17, 2010

DLL reference issue- (Exception from HRESULT: 0x80131040)

The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

Fix:
This issue occurs when there are multiple projects referencing same DLL with different version. Do make sure same version of DLL is reffered in all the projects.

Sunday, February 14, 2010

Enabling IntelliSense in Visual Studio to author a custom feature easily

Inside the TEMPLATE directory there is a directory named XML that contains several XML schemas, including one named wss.xsd. If you associate this schema file with feature files such as feature.xml and elements.xml, Visual Studio will provide IntelliSense, which makes it much easier to author a custom feature. You may also copy these XSD files into C:\Program Files\Microsoft Visual Studio 8\Xml\Schemas\.

Programming Against the WSS Object Model

 

Another important aspect of WSS development is programming against the WSS object model. The core types provided by the WSS programming model are exposed through a standard WSS assembly named Microsoft.SharePoint.dll.

Let’s look at a simple example. Imagine you have just created a console application, and you have added a reference to Microsoft.SharePoint.dll. The WSS object model exposes an SPSite class that serves as an entry point into the WSS object model at the site collection level. Each site within a site collection is represented as an SPWeb object. Each list within a site is represented as an SPList object. Here’s a simple example using the WSS object model to access the top-level site within a target site collection and discover all its lists.

using Microsoft.SharePoint;
namespace Hello_WSS_OM {
  class Program {
    static void Main() {
      string sitePath = "http://litwareinc.com";
      // enter object model through site collection.
      SPSite siteCollection = new SPSite(sitePath);
      // obtain reference to top-level site.
      SPWeb site = siteCollection.RootWeb;
      // enumerate through lists of site
      foreach (SPList list in site.Lists) {
        Console.WriteLine(list.Title);
      }
      // clean up by calling Dispose.
      site.Dispose();
      siteCollection.Dispose();
    }
  }
}

You should observe the two calls to the Dispose method at the end of this code example. Several object types in the WSS object model, such as SPSite and SPWeb, use unmanaged resources and must be disposed of in a timely manner. If you fail to do this and simply rely on the garbage collector of the .NET Framework to reclaim memory, your code can cause problems by consuming far more memory than it needs. As a rule of thumb, when you create a disposable object, you are also responsible for calling Dispose on it. However, object references obtained through the WSS Web application’s SPContext should not be disposed.

The STSADM.EXE Command Line Utility

WSS ships with a handy command-line utility named STSADM.EXE. This utility allows you to run interactive commands from the Windows command line and to script batch files that accomplish administrative tasks such as creating, backing up, and restoring site collections. When you run this utility from the command line or from a batch file, you must pass the –o parameter followed by one of the supported operations. Here’s an example of a command line instruction to create a new site collection at a specific URL.
STSADM.EXE –o CreateSite –url http://localhost/sites/Sales
                         -ownerlogin LitwareServer\BrianC
                         -owneremail brianc@litwareinc.com
                         -sitetemplate STS#0
Note that this example has introduced line breaks between the parameters to make things more readable. However, you cannot actually use line breaks between the parameters when running the STSADM utility from the command line or from a batch file.
Keep in mind that the installation of WSS adds the STSADM.EXE utility to a WSS system directory deep within the Windows Program Files directory. If you want to be able to call this utility directly from the command line on your development workstation, you should add the following path to your configured System path.
c:\program files\common files\microsoft shared\web server extensions\12\bin\
When you write a batch file, you should also assume that it might be run on a machine that does not have the proper System path configured. Therefore, you should write batch files that explicitly specify the location of the STSADM.EXE utility.
@SET STSADM="c:\program files\common files\microsoft shared\
             web server extensions\12\bin\stsadm"

%STSADM% –o CreateSite –url http://localhost/sites/Sales
                         -ownerlogin LitwareServer\BrianC
                         -owneremail brianc@litwareinc.com
                         -sitetemplate STS#0

The WSS Decoder Ring - WSS Object Model confusion

When developers begin to use WSS, there is often confusion surrounding different terminology used between WSS and its version 1.0 predecessor SharePoint Team Services (STS). For example, the WSS term Site Collection is the equivalent of the old STS term Site. The new WSS term Site is the equivalent of the old STS term Web. The new WSS term Top-level Site is the equivalent of the old STS term Root Web.
Though the WSS team has been consistent using the new WSS terminology in the product documentation, there are still many places that use the term Web when you expect Site and that use the term Site when you expect Site Collection.
For example, the names of classes in the WSS object model are based on the old STS terms. As a result, you program against a site collection using an SPSite object, and you program against a site using a SPWeb object. An SPSite object provides a public property named RootWeb that returns an SPWeb object representing the site site. Once you understand this potential point of confusion, getting up to speed on various aspects of WSS becomes less confusing.

XML node parsing code snippet

Code snippet for parsing XML document :


if (providerDocument.ProviderCount > 0)
{
foreach (XmlNode xn in providerNodeList)
{
XmlNodeList xnlGroupOwned = xn.SelectNodes("xps:GroupOwned/xps:Type[contains(.,'LEA Area')]", providerDocument.NamespaceManager);
foreach (XmlNode xnGroupOwned in xnlGroupOwned)
{
XmlNodeList xnlGroupOwnedMember = xn.SelectNodes("xps:GroupOwned/xps:Member", providerDocument.NamespaceManager);
foreach (XmlNode xnGroupOwnedMember in xnlGroupOwnedMember)
{
upins.Append(xnGroupOwnedMember.ChildNodes.Item(2).FirstChild.InnerText + ",");
upinsTradingName.Append(xnGroupOwnedMember.ChildNodes.Item(2).LastChild.InnerText + "?");
}
XmlNodeList xnlFunding = xn.SelectNodes("xps:Funding", providerDocument.NamespaceManager);
foreach (XmlNode xnFunding in xnlFunding)
{
upinsFundingEligibility.Append(xnFunding.ChildNodes.Item(1).InnerText + ",");
}
}
}
}

SharePoint Terminology

To help you familiarize yourself with the SharePoint vocabulary:

Application page. Allows the use of inline custom code. Application pages or "_layout" pages are stored on the SharePoint Web server and made available via a Microsoft Internet Information Services (IIS) virtual directory. Though application pages behave much like other ASPX pages and allow the use of inline custom code, they differ from content pages in that they cannot be used to host SharePoint features such as dynamic Web Parts and Web Part zones.

Content type. A reusable collection of settings to apply to a certain category of content such as documents and folders. Content types are designed to help users organize their SharePoint content in a more meaningful way.

Custom action. Represents a link, toolbar button, menu item, or any control that can be added to a toolbar or menu that appears in the UI. You define custom actions by using a custom action element within a feature definition file. You can bind custom actions to a list type, content type, file type, or programmatic identifier (ProgID).

Event receiver. Evaluator of an event and definer of the behavior of an application. Windows SharePoint Services 3.0 allows you to define event handlers within libraries, lists, and sites. Event receivers can be defined by using a receiver element within a feature definition file.

Feature. A package of Windows SharePoint Services elements that can be activated for a specific scope and that helps users accomplish a particular goal or task. Windows SharePoint Services 3.0 introduces this inherently portable and modular functionality, which simplifies modification of sites through site definitions.

Master page. Pages that provide a consistent layout and appearance (look and feel) for SharePoint sites. They allow you to factor out layout, structure, and interface elements such as headers, footers, navigation bars, and content placeholders. Master pages in ASP.NET 2.0 and master pages in Windows SharePoint Services work in the same way.

Module. A file or collection of file instances that define the location where the files are installed during site creation. Modules are frequently used to implement a Web Part Page in the site. You can define modules by using a module element within a feature definition file.

SharePoint site: A Web site hosted in a virtual URL. A SharePoint site is a place for collaboration, communication, or content storage. Depending on your business needs, you can create sites such as team sites, blog sites, wiki sites, and others. You can customize a site's appearance, users, user permissions, galleries, and site administration by using the Site Settings administration pages.

SharePoint site collection: A collection of SharePoint sites that share common administration pages and site settings. Site collections allow you to share content types, site columns, templates, and Web Parts within a group of SharePoint sites.

SharePoint Web farm: A group of Office SharePoint 2007 servers that share the same configuration database. All site content and all configuration data is shared for all front-end Web servers in a server farm.

Site definition. A set of files that includes a master XML configuration file that is stored on all front-end Web servers. A site definition provides the basic blueprint for how sites look, what lists they include, their default navigational structures, and so on.

Site template. A package containing a set of differences and changes from a base site definition that is created through the UI or through implementation of the object model. The site template package is stored as a .cab-based file that can be downloaded or uploaded to site collections by users with the appropriate rights. Site templates offer a measure of portability to SharePoint applications.

Solution. A file that is a bundling of all the components for extending Windows SharePoint Services in a particular way. A solution file has a .cab-based format with a .wsp extension. A solution is a deployable, reusable package that can contain a set of Features, site definitions, and assemblies that apply to sites, and that you can enable or disable individually. You can use the solution file to deploy the contents of a Web Part package, including assemblies, class resources, and other package components.

Theme. A group of files (CSS, images) that allow you to define the appearance (look and feel) of Web pages. Themes in ASP.NET 2.0 and themes in SharePoint Products and Technologies work in the same way. Themes are used to help organizations to brand their portals and team sites. Office SharePoint Server 2007 includes a set of predefined themes. However, as a developer, you can create custom themes for your company.

SharePoint Technologies Overview







Overview

SharePoint Products and Technologies provide an extensible solution platform for the professional Microsoft .NET developer, and offer a wide array of built-in features and application hosting using well-known .NET development tools and technologies. SharePoint Products and Technologies offer a manageable and scalable server platform that employs the benefits of the 2007 Microsoft Office system client for hosting applications on an internal or Internet Web site.

The.NET developer creates Web-based solutions by using the Web development platform of ASP.NET. ASP.NET allows you to build Web-based solutions by using managed code. The ASP.NET page framework also provides new Web platform capabilities, features, and enhancements such as master pages, Web part controls, and data source controls.

Marrying the advantages and power of both platforms, with the release of the 2007 Microsoft Office system, Microsoft provides products and technologies such as Windows SharePoint Services 3.0 and Microsoft Office SharePoint Server 2007 that are built on top of ASP.NET 2.0. Now you, the professional .NET developer, can use your knowledge of .NET technologies to develop on the SharePoint platform to create a new set of Web solutions.

The goal of this article is to introduce you to some of the most powerful SharePoint development features. This article walks you through key concepts, developer terms, developer components used to build enterprise solutions, and pointers to resources to help you get started learning about SharePoint development. It also explores tools you can use to create solutions by using SharePoint Products and Technologies.

Benefits Offered to .NET Developers

SharePoint Products and Technologies introduce a number of benefits that help not only developers and the solutions they build, but also individual users and organizations of all sizes.

SharePoint Products and Technologies offer additional overall benefits to .NET developers. Highlights of these benefits include the following:

A familiar development environment for .NET developers. Windows SharePoint Services 3.0 is built entirely on ASP.NET, so you use the same familiar .NET Framework and .NET languages, the same .NET Framework and ASP.NET class libraries, and the same development tools.

Built-in features that developers can extend. Windows SharePoint Services 3.0 adds foundational components that are valuable for creating Web-based applications such as a Web Part framework, data lists, document libraries, a workflow engine, and Web site templates. Office SharePoint Server 2007 adds major application features on top of Windows SharePoint Services 3.0. These include user site provisioning, business intelligence features, forms services, enterprise content management, integrated search, and social networking features. All of these features can be extended by developers to implement something as simple as a Web dashboard to a complex line-of-business (LOB) application.

The best integrated server for Office applications. If you need to store documents as part of your Web application, Office SharePoint Server 2007 is the answer. Office client applications including Word, Excel, Outlook and InfoPath can be easily used as part of an enterprise solution built on SharePoint.

The foundation for a wide variety of Intranet or Internet applications. For end users, SharePoint Products and Technologies have numerous easy-to-use and desirable features. For developers, SharePoint Products and Technologies is a platform to build on. Because when you develop on the SharePoint platform you are building on the same application foundation that SharePoint uses for end user functionality, the applications that you can create have a consistent common look, and can be managed in a consistent way. If a company already has SharePoint deployed, it is easy to add applications to the existing deployment.

What are SharePoint Products and Technologies?

SharePoint Products and Technologies provide a foundation for collaboration, business intelligence, enterprise content management, people and personalization services, Enterprise Search, integration of LOB data, and processes.

SharePoint Products and Technologies include the following:

Windows SharePoint Services 3.0. A set of services for collaboration and a foundation for building Web-based applications on Windows Server. Windows SharePoint Services 3.0 is included in Windows Server 2003 and in Windows Server 2008, and is also available separately as a download.

Microsoft Office SharePoint Server 2007. A single, integrated application that provides sites (locations) where employees can efficiently collaborate with team members, find organizational resources, search for experts and corporate information, manage content and workflow, and make use of business insight to reach better-informed decisions. Office SharePoint Server 2007 is part of the 2007 Microsoft Office system. For more information, see the Microsoft Office SharePoint Server 2007 frequently asked questions.

Microsoft Office SharePoint Designer 2007. A designer and developer tool that enables you to quickly build solutions that include both design and workflow.

Windows SharePoint Services 3.0 and Office SharePoint Server 2007 are built on top of the ASP.NET 2.0 Framework and the Microsoft .NET 3.0 Windows Workflow Foundation (WF) as shown in Figure.

Source :
http://msdn.microsoft.com/en-gb/library/cc537498.aspx#MOSSIntroToNet_Overview