Email Aaron Blake now at webmaster@aaronblake.co.uk
or contact me

How to add web user controls to a class library project

Introduction

By default you are unable to add web forms or user controls to a Class Library project. This guide will tell you how to get around this.

IMPORTANT – Backup your project file before you make any amends to it, just in case something goes wrong.

Step 1 – Open class library project file in a text editor.

The project file is usually in the root folder and has a file extension of .vbproj or .csproj

Step 2 – Add or replace the tag

Add or replace the tag with the following:

{349c5851-65df-11da-9384-00065b846f21};{F184B08F-C81C-45F6-A57F-5ABD9991F28F}

This tag should be underneath the tag, which is within the tag.

Example:



  
    Debug
    AnyCPU
    9.0.30729
    2.0
    {42FC0FAF-C05B-4C16-AB8A-3F4698F910D8}
    {349c5851-65df-11da-9384-00065b846f21};{F184B08F-C81C-45F6-A57F-5ABD9991F28F}
    Library
    Cuyahoga.Modules.Test
    Cuyahoga.Modules.Test
    512
    WebControl
    v3.5
    On
    Binary
    Off
    On
  
  
    true
    full
    true
    true
    bin\Debug\
    Cuyahoga.Modules.Test.xml
    42016,41999,42017,42018,42019,42032,42036,42020,42021,42022
  
  
    pdbonly
    false
    true
    true
    bin\Release\
    Cuyahoga.Modules.Test.xml
    42016,41999,42017,42018,42019,42032,42036,42020,42021,42022
  
  
    
    
    
    
    
    
    
      3.5
    
    
      3.5
    
    
      3.5
    
  
  
    
    
    
    
    
    
    
    
  
  
    
    
    
      True
      Application.myapp
    
    
      True
      True
      Resources.resx
    
    
      True
      Settings.settings
      True
    
  
  
    
      VbMyResourcesResXFileCodeGenerator
      Resources.Designer.vb
      My.Resources
      Designer
    
  
  
    
      MyApplicationCodeGenerator
      Application.Designer.vb
    
    
      SettingsSingleFileGenerator
      My
      Settings.Designer.vb
    
  
  
  

Step 3 – Save file and open project up in visual studio.

Conclusion

You should now be able to add web forms and user controls from the solution explorer within visual studio.

Further reading:
http://haacked.com/archive/2006/02/07/AddingWebUserControlToAClassLibraryInVS.NET2005.aspx

Post a Comment

You must be logged in to post a comment.

Email me through this magic form.