Dot Net Mafia

Group site for developer blogs dealing with (usually) Ionic, .NET, SharePoint, Office 365, Mobile Development, and other Microsoft products, as well as some discussion of general programming related concepts.

This Blog



Corey Roth [MVP]

A SharePoint MVP bringing you the latest time saving tips for Ionic, SharePoint, and Office 365.

How to: Hack a Class Library Project into a Web Application Project

Kind of a weird tip here, but I have ran into a situation where I have needed to do this.  Basically, I have had an existing class library (for SharePoint development) and for some reason, I have decided I need to add ASP.NET file types to it (i.e. User Controls, Master Pages, etc.).  A class library doesn't have these file types in the Add Item menu so you need a Web Application Project. When it comes down to it a Web Application Project really is the same thing as a class library, it just has some extra settings.  So when it comes down to it, you would either have to recreate the project and add your existing files back into it or just hack the XML of your .csproj file.  I obviously prefer the latter.

To do this, start by Unloading the Project by right clicking your project and choosing Unload Project.  Next Right click on your unloaded project and choose Edit <PrjectName>.csproj.  Paste the line below in the first ProjectGroup element.  Usually Visual Studio puts it underneath the ProjectGuid element. 


That is the only change that is required.  There are some optional settings that you can put in regarding the configuration of Cassini, but none of them are required to get you going.  You can always configure them in Visual Studio.  Once you have made the change, save the .csproj file and Reload Project.  Once the project is loaded, all of the ASP.NET file types will be present in your Add Item menu.  When you compile, it will still compile everything down to a single DLL and you can deploy it just as if it was a regular class library.



Links (2/24/2008) « Steve Pietrek’s SharePoint Stuff said:

Pingback from  Links (2/24/2008) &laquo; Steve Pietrek&#8217;s SharePoint Stuff

February 24, 2008 7:06 PM

Umit said:

I have tried this and it works. the problem is when I try to use webcontrol which is created the classlibrary anything does display on page. do you have any idea?

here is my sample code:

<%@ Page Language="C#" AutoEventWireup="false" CodeBehind="Default.aspx.cs" Inherits="WebApplication1._Default" %>

<%@ Register Assembly="ClassLibrary1" Namespace="ClassLibrary1" TagPrefix="uc1" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">

<html xmlns="" >

<head runat="server">




   <form id="form1" runat="server">


   <uc1:WebUserControl1 ID="WebUserControl11" runat="server" />

   <asp:PlaceHolder ID="ph" runat="server"></asp:PlaceHolder>





protected override void OnLoad(EventArgs e)



           ph.Controls.Add(Page.LoadControl(typeof(ClassLibrary1.WebUserControl1), null));


February 4, 2010 8:55 AM

Ali Khan said:

This really helped me for the type of solution I needed and how I am developing for SharePoint.

Thank you very much for posting this.

April 16, 2010 1:54 PM

Visual Studio Project GUIDS | Zabriskie Answers said:

Pingback from  Visual Studio Project GUIDS | Zabriskie Answers

December 13, 2014 5:06 PM

Andrew said:

That is exactly what I was looking for... Thanks a lot!

September 7, 2016 7:18 AM

Leave a Comment


About CoreyRoth

Corey Roth is an independent SharePoint consultant specializing in ECM, Apps, and Search.
2018 dotnetmafia.
Powered by Community Server (Non-Commercial Edition), by Telligent Systems