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.
Wednesday, February 17, 2010
Sunday, February 14, 2010
Enabling IntelliSense in Visual Studio to author a custom feature easily
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 + ",");
}
}
}
}
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.
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.
Subscribe to:
Posts (Atom)