I'm hoping there's someone out there with much more experience with this stuff than I

. My conundrum is, I'm trying to create a content type (just so I can simply see it in Site Settings/Content Types). Using the book code, I start out with the content type wrapper file GenericContentTypeWrapperClass.cs as follows:
using System;
using Microsoft.SharePoint;
namespace ProSharePoint2007
{
/// <summary>
/// A utility class for manipulating SharePoint content types.
/// </summary>
public class ContentType
{
SPContentType m_contentType = null;
/// <summary>
/// Default constructor.
/// </summary>
public ContentType()
{
}
/// <summary>
/// Creates a wrapper for an existing content type instance.
/// </summary>
/// <param name="contentType"></param>
public ContentType(SPContentType contentType)
{
m_contentType = contentType;
}
/// <summary>
/// Adds a content type to a SharePoint list.
/// </summary>
public static void AddToList(SPList list, SPContentType contentType)
{
list.ContentTypesEnabled = true;
list.ContentTypes.Add(contentType);
list.Update();
}
/// <summary>
/// Removes a content type from a SharePoint list.
/// </summary>
public static void RemoveFromList(SPList list, string contentTypeName)
{
foreach (SPContentType type in list.ContentTypes)
{
if (type.Name == contentTypeName)
{
list.ContentTypes.Delete(type.Id);
list.Update();
break;
}
}
}
/// <summary>
/// Loads a pre-existing content type.
/// </summary>
public virtual SPContentType Create(SPWeb web, string typeName)
{
try
{
m_contentType = web.AvailableContentTypes[typeName];
}
catch
{
}
return m_contentType;
}
/// <summary>
/// Creates a new content type.
/// </summary>
public virtual SPContentType Create(SPWeb web, string typeName,
string baseTypeName,
string description)
{
try
{
SPContentType baseType = (baseTypeName == null
|| baseTypeName.Length == 0) ?
web.AvailableContentTypes[SPContentTypeId.Empty] :
web.AvailableContentTypes[baseTypeName];
m_contentType = new SPContentType(
baseType, web.ContentTypes, typeName);
m_contentType.Description = description;
web.ContentTypes.Add(m_contentType);
}
catch
{
}
return m_contentType;
}
/// <summary>
/// Conversion operator to access the underlying SPContentType instance.
/// </summary>
public static implicit operator SPContentType(ContentType t)
{
return t.m_contentType;
}
#region Field Methods
/// <summary>
/// Adds a new field having a specified name and type.
/// </summary>
public SPField AddField(string fieldDisplayName,
SPFieldType fieldType, bool bRequired)
{
SPField field = null;
try
{
// get the parent web
using (SPWeb web = m_contentType.ParentWeb)
{
// create the field within the target web
string fieldName =
web.Fields.Add(fieldDisplayName,
fieldType, bRequired);
field = web.Fields[fieldName];
// add a field link to the content type
m_contentType.FieldLinks.Add(
new SPFieldLink(field));
m_contentType.Update(false);
}
}
catch
{
}
return field;
}
/// <summary>
/// Adds a new field based on an existing field in the parent web.
/// </summary>
public SPField AddField(string fieldName)
{
using (SPWeb web = m_contentType.ParentWeb)
{
SPField field = web.AvailableFields[fieldName];
try
{
if (field != null)
{
m_contentType.FieldLinks.Add(
new SPFieldLink(field));
m_contentType.Update(false);
}
}
catch
{
}
return field;
}
#endregion
}
}
}
Next, I'm creating the ProjectProposal Content Type with the following ProjectProposalCT.cs file also using the book code:
namespace ProSharePoint2007
{
/// <summary>
/// A helper class that encapsulates the ProjectProposal content type.
/// </summary>
class ProjectProposalType : ContentType
{
/// <summary>
/// Creates the type using the XML content type definition.
/// </summary>
public SPContentType Create(SPWeb web)
{
return this.Create(web, "Project Proposal");
}
/// <summary>
/// Creates the type using the SharePoint object model.
/// </summary>
public override SPContentType Create(SPWeb web, string typeName,
string baseTypeName,
string description)
{
// Call the base method to create the new type.
SPContentType tProposal = base.Create(web, typeName,
baseTypeName, description);
// Create the fields programmatically.
if (tProposal != null)
{
// just use built-in fields for now
AddField("Author");
AddField("Subject");
AddField("StartDate");
AddField("EndDate");
AddField("Status");
AddField("Comments");
AddField("Keywords");
// custom fields
//AddField(Strings.Field_ProposalType);
//AddField(Strings._Field_EstimatedCost);
//AddField(Strings._Field_BidAmount);
//AddField(Strings._Field_EstimatedHours);
//AddField(Strings._Field_HourlyRate);
}
return tProposal;
}
}
}
Now I build successfully, and move the resulting dll into the GAC and then iisreset.
The content type does not show up in the Content Types list. Isn't it supposed to simply show up there, since I'm not using the "featureactivated" event in a feature receiver, or do I have to take another step? The book code shows how to use an event receiver to use this content type and build a document library off it.
I just want it firstly to show up in the content Type list!!
Thanks
Help