I have a class like this:
namespace SharePointSocialNetworking
{
public class FeatureToEnableJob : SPFeatureReceiver
{
public override void FeatureActivated(SPFeatureReceiverProperties properties)
{
SPSite site = properties.Feature.Parent as SPSite;
// Make sure the job isn't already registered.
foreach (SPJobDefinition job in site.WebApplication.JobDefinitions)
{
if (job.Name == "SPFacebookJob")
job.Delete();
}
// Install the job.
Facebook fbJob = new Facebook();
SPMinuteSchedule schedule = new SPMinuteSchedule();
schedule.BeginSecond = 0;
schedule.EndSecond = 59;
schedule.Interval = 2;
fbJob.Schedule = schedule;
fbJob.Update();
}
...
}
}
And this is my feature XML:
<?xml version="1.0" encoding="utf-8"?>
<Feature xmlns="http://schemas.microsoft.com/sharepoint/"
Id="b9e40341-32ab-410a-a20f-282cf13fb54b"
ReceiverAssembly="SharePointSocialNetworking, Version=1.0.0.0, Culture=neutral, PublicKeyToken=6264b0911592ad29"
ReceiverClass="SharePointSocialNetworking.FeatureToEnableJob"
Scope="Farm"
Title="SharePoint Social Networking Job">
</Feature>
My assembly is called SharePointSocialNetworking. Am I doing anything wrong here?
I've done all the appropriate setup but when I run this command:
stsadm -o installfeature -name SharePointSocialNetworking
I get the error:
Object reference not set to an instance of an object.
your feature parent is not a site but the farm, you should not cast it to SPSite
Related
I've bumped into a following problem with Azure Diagnostic Monitor:
When I create a new AppDomain in OnStart() event in WorkerRole entry point the diagnostics works only in the parent AppDomain. I've tried initializing Diagnostics Monitor in the child AppDomain but it doesn't help. (Traces are collected only from the parent domain)
Example repro code:
public class WorkerRole : RoleEntryPoint
{
public override void Run()
{
// This is a sample worker implementation. Replace with your logic.
InitializeDiagnostics();
Trace.TraceInformation("WorkerRole1 entry point called", "Information");
while (true)
{
Thread.Sleep(10000);
Trace.TraceInformation("Parent domain working", "Information");
}
}
public override bool OnStart()
{
// Set the maximum number of concurrent connections
ServicePointManager.DefaultConnectionLimit = 12;
InitializeDiagnostics();
var setup = new AppDomainSetup();
setup.ApplicationBase = AppDomain.CurrentDomain.BaseDirectory;
setup.ConfigurationFile = AppDomain.CurrentDomain.SetupInformation.ConfigurationFile;
var newDomain = System.AppDomain.CreateDomain("NewApplicationDomain",null, setup);
foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies().Where(x => !x.GlobalAssemblyCache))
{
newDomain.Load(assembly.GetName());
}
newDomain.Load(typeof (Worker).Assembly.FullName);
var worker = newDomain.CreateInstanceAndUnwrap(this.GetType().Assembly.FullName, typeof (Worker).FullName) as Worker;
worker.DoWork();
return base.OnStart();
}
public void InitializeDiagnostics()
{
var roleInstanceDiagnosticManager = new RoleInstanceDiagnosticManager(RoleEnvironment.GetConfigurationSettingValue("Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString"),
RoleEnvironment.DeploymentId,
RoleEnvironment.CurrentRoleInstance
.Role.Name,
RoleEnvironment.CurrentRoleInstance.Id);
var dmc = roleInstanceDiagnosticManager.GetCurrentConfiguration();
var dictionaryConfiguration = new DirectoryConfiguration();
DiagnosticMonitor.Start("Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString", dmc);
}
}
public class Worker : MarshalByRefObject
{
public void DoWork()
{
new Task(() =>
{
while (true)
{
Thread.Sleep(1000);
Trace.TraceInformation(AppDomain.CurrentDomain.FriendlyName + " Worker working...", "Information");
}
}).Start();
}
}
}
App config:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.diagnostics>
<trace>
<listeners>
<add type="Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener, Microsoft.WindowsAzure.Diagnostics, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
name="AzureDiagnostics">
<filter type="" />
</add>
</listeners>
</trace>
</system.diagnostics>
</configuration>
Expected output:
Lots of logged messages:
"{Domain Name} Wokrer working..."
Some
"Parent domain working"
Actual output:
"Parent domain working"
I'm using Azure SDK 2.0. Have any of you came across a similar issue ?
Ok, finally solved it. Upgrading Azure SDK to 2.3 did the thing... It's interesting that messages still doesn't appear in Compute emulator console, but after upgrade they are correctly logged to WADLog table.
I am trying to create a custom workflow activity which gives me the list of recipients that I am storing in list. But once I deploy and start the workflow nothing is happening, not even log messages are coming. So i tried to debug the code but breakpoints are not set and I am getting the error "The Breakpoint will not currently be hit. No symbols have been loaded for this document." Can anyone please help me to deal with this issue.
Below are the steps I have followed in creating this activity.
1. created a workflow activity library.
(please find my code file attached)
added .dll to GAC
updated web.config and WSS.actions files.
Now I see the action in designer, so i have created a workflow using designer.
strted the workflow manually on an item.
Here nothing is happening, not even an error. Please let me know if you need any further information.
Please find the code below.
using System;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Collections;
using System.Drawing;
using System.Linq;
using System.Workflow.ComponentModel.Compiler;
using System.Workflow.ComponentModel.Serialization;
using System.Workflow.ComponentModel;
using System.Workflow.ComponentModel.Design;
using System.Workflow.Runtime;
using System.Workflow.Activities;
using System.Workflow.Activities.Rules;
using Microsoft.SharePoint;
using System.Diagnostics;
using Microsoft.SharePoint.Workflow;
using Microsoft.SharePoint.WorkflowActions;
namespace CustomWorkflowActivityLibrary
{
public partial class CustomWorkflowActivity: SequenceActivity
{
SPList _list;
private EventLog _log;
SPFieldUserValueCollection objUserFieldValueCol;
string semailsettingKeyword1;
string semailsettingKeyword2;
public CustomWorkflowActivity()
{
InitializeComponent();
}
public static DependencyProperty __ContextProperty = DependencyProperty.Register("__Context", typeof(WorkflowContext), typeof(CustomWorkflowActivity));
[DescriptionAttribute("__Context")]
[BrowsableAttribute(true)]
[DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Visible)]
public WorkflowContext __Context
{
get { return ((WorkflowContext)(base.GetValue(CustomWorkflowActivity.__ContextProperty))); }
set { base.SetValue(CustomWorkflowActivity.__ContextProperty, value); }
}
public static DependencyProperty ListIdProperty = DependencyProperty.Register("ListId", typeof(string), typeof(CustomWorkflowActivity));
[DescriptionAttribute("ListId")]
[BrowsableAttribute(true)]
[DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Visible)]
public string ListId
{
get { return ((string)(base.GetValue(CustomWorkflowActivity.ListIdProperty))); }
set { base.SetValue(CustomWorkflowActivity.ListIdProperty, value); }
}
public static DependencyProperty ListItemProperty = DependencyProperty.Register("ListItem", typeof(int), typeof(CustomWorkflowActivity));
[DescriptionAttribute("ListItem")]
[BrowsableAttribute(true)]
[DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Visible)]
public int ListItem
{
get { return ((int)(base.GetValue(CustomWorkflowActivity.ListItemProperty))); }
set { base.SetValue(CustomWorkflowActivity.ListItemProperty, value); }
}
private void codeActivity1_ExecuteCode(object sender, EventArgs e)
{
}
protected override ActivityExecutionStatus Execute(ActivityExecutionContext executionContext)
{
_log = new EventLog("Add Description");
_log.Source = "Share Point Workflows";
try
{
//Execute method as a elevated method
SPSecurity.CodeToRunElevated elevatedExecuteMethod = new SPSecurity.CodeToRunElevated(ExecuteMethod);
SPSecurity.RunWithElevatedPrivileges(elevatedExecuteMethod);
}
catch (Exception ex)
{
_log.WriteEntry("Error" + ex.Message.ToString(), EventLogEntryType.Error);
}
return ActivityExecutionStatus.Closed;
}
private void ExecuteMethod()
{
try
{
//retrieveing the Site object
SPSite _site = new SPSite(__Context.Site.Url);
//retrieveing the Web object
SPWeb _web = (SPWeb)(__Context.Web);
//retrieveing the list object
_list = _web.Lists[new Guid(this.ListId)];
//retrieveing the list item object
SPListItem _listItem = _list.GetItemById(this.ListItem);
_site.AllowUnsafeUpdates = true;
_web.AllowUnsafeUpdates = true;
string semailsubject = _listItem["E-Mail Subject"].ToString();
string semailfrom = _listItem["emailfrom"].ToString();
_log = new EventLog("get vendor info");
_log.WriteEntry("semailsubject");
_log.WriteEntry("semailfrom");
/* _listItem.Update();
_list.Update();
_site.AllowUnsafeUpdates = false;
_web.AllowUnsafeUpdates = false;*/
using (SPSite mysite = new SPSite("http://dlglobaltest.dl.com/Admin/IT/Application%20Development%20Group/LibraryEmailDistribution"))
{
using (SPWeb myweb = mysite.OpenWeb())
{
SPList settingsList = myweb.Lists["EmailDistributionSettings"];
SPQuery oQuery = new SPQuery();
oQuery.Query = "<Where><Eq><FieldRef Name='Sender' /><Value Type='Text'>" + semailfrom + "</Value></Eq></Where>";
SPListItemCollection ColListItems = settingsList.GetItems(oQuery);
foreach (SPListItem oListItem in ColListItems)
{
semailsettingKeyword1 = oListItem["Keyword1"].ToString();
semailsettingKeyword2 = oListItem["Keyword2"].ToString();
//SPFieldUserValue objUserFieldValue = new SPFieldUserValue(myweb, oListItem["Recipients"].ToString());
if ((semailsubject.Contains(semailsettingKeyword1)) || (semailsubject.Contains(semailsettingKeyword2)))
{
objUserFieldValueCol = new SPFieldUserValueCollection(myweb, oListItem["Recipients"].ToString());
_log = new EventLog(objUserFieldValueCol.ToString());
}
}
}
}
}
catch (Exception ex)
{ }
}
}
}
Web.Config:
<authorizedType Assembly="CustomWorkflowActivityLibrary, Version=1.0.0.0, Culture=neutral, PublicKeyToken=a95e146fc1062337" Namespace="CustomWorkflowActivityLibrary" TypeName="*" Authorized="True" />
WSS.Actions:
<Action Name="Get Recipients"
ClassName="CustomWorkflowActivityLibrary.CustomWorkflowActivity"
Assembly="CustomWorkflowActivityLibrary, Version=1.0.0.0, Culture=neutral, PublicKeyToken=a95e146fc1062337"
AppliesTo="all" Category="Custom">
<RuleDesigner Sentence="Get Recipients for %1 ">
<FieldBind Field="ListId,ListItem" Text="this list" Id="1" DesignerType="ChooseListItem" />
</RuleDesigner>
<Parameters>
<Parameter Name="__Context" Type="Microsoft.SharePoint.WorkflowActions.WorkflowContext" Direction="In" />
<Parameter Name="ListId" Type="System.String, mscorlib" Direction="In" />
<Parameter Name="ListItem" Type="System.Int32, mscorlib" Direction="In" />
</Parameters>
</Action>
Thanks,
I am not sure if this will help but you could try changing the following line in your code from this:
SPSecurity.RunWithElevatedPrivileges(elevatedExecuteMethod);
To this:
SPSecurity.RunWithElevatedPrivileges(delegate(){
ExecuteMethod();
});
Another shot-in-the-dark reply:
Try changing the class you're inheriting ( http://msdn.microsoft.com/en-us/library/ms173149(v=VS.80).aspx ) from SequenceActivity to Activity (SequenceActivity inherits from CompositeActivity, which itself inherits from Activity. See: http://msdn.microsoft.com/en-us/library/system.workflow.activities.sequenceactivity(v=VS.90).aspx )
If that doesn't work, try removing your constructor entirely. You should be able to use the base (Sequence)Activity constructor (since you're inheriting the class, not implementing it)
Hope that helps...
I created a new content type for a wiki page library. I added this content type to library by code (the interface did not allow this). Next, I added an event receiver to this content type (on ItemAdded and ItemAdding). My problem is that no event is trrigered.
If I add this events directly to the wiki page library all works fine.
Is there a limitation/bug/trick ?
I looked at the content type attached to the library with SharePoint Manager and in his schema the part for event receiver is missing...I know that there should be something like:
<XmlDocuments>
<XmlDocument NamespaceURI="http://schemas.microsoft.com/sharepoint/events">
<spe:Receivers xmlns:spe="http://schemas.microsoft.com/sharepoint/events">
<Receiver>
<Name>
</Name>
<Type>1</Type>
<SequenceNumber>10000</SequenceNumber>
<Assembly>RssFeedWP, Version=1.0.0.0, Culture=neutral, PublicKeyToken=f6722cbeba696def</Assembly>
<Class>RssFeedWP.ItemEventReceiver</Class>
<Data>
</Data>
<Filter>
</Filter>
</Receiver>
<Receiver>
<Name>
</Name>
<Type>10001</Type>
<SequenceNumber>10000</SequenceNumber>
<Assembly>RssFeedWP, Version=1.0.0.0, Culture=neutral, PublicKeyToken=f6722cbeba696def</Assembly>
<Class>RssFeedWP.ItemEventReceiver</Class>
<Data>
</Data>
<Filter>
</Filter>
</Receiver>
</spe:Receivers>
</XmlDocument>
If I look with SPM to the content type added to site I see this part into schema.
Here is my code:
public override void FeatureActivated(SPFeatureReceiverProperties properties)
{
using (SPWeb web = (SPWeb)properties.Feature.Parent)
{
// create RssWiki content type
SPContentType rssFeedContentType = new SPContentType(web.AvailableContentTypes["Wiki Page"],
web.ContentTypes, "RssFeed Wiki Page");
// add rssfeed url field to the new content type
AddFieldToContentType(web, rssFeedContentType, "RssFeed Url", SPFieldType.Note);
// add use xslt check box field to the new content type
AddFieldToContentType(web, rssFeedContentType, "Use Xslt", SPFieldType.Boolean);
// add xslt url field to the new content type
AddFieldToContentType(web, rssFeedContentType, "Xslt Url", SPFieldType.Note);
web.ContentTypes.Add(rssFeedContentType);
rssFeedContentType.Update();
web.Update();
AddContentTypeToList(web, rssFeedContentType);
AddEventReceiversToCT(rssFeedContentType);
//AddEventReceiverToList(web);
}
}
private void AddFieldToContentType(SPWeb web, SPContentType ct, string fieldName, SPFieldType fieldType)
{
SPField rssUrlField = null;
try
{
rssUrlField = web.Fields.GetField(fieldName);
}
catch (Exception ex)
{
if (rssUrlField == null)
{
web.Fields.Add(fieldName, fieldType, false);
}
}
SPFieldLink rssUrlFieldLink = new SPFieldLink(web.Fields[fieldName]);
ct.FieldLinks.Add(rssUrlFieldLink);
}
private static void AddContentTypeToList(SPWeb web, SPContentType ct)
{
SPList wikiList = web.Lists[listName];
wikiList.ContentTypesEnabled = true;
wikiList.ContentTypes.Add(ct);
wikiList.Update();
}
private static void AddEventReceiversToCT(SPContentType ct)
{
//add event receivers
string assemblyName = System.Reflection.Assembly.GetExecutingAssembly().FullName;
string ctReceiverName = "RssFeedWP.ItemEventReceiver";
ct.EventReceivers.Add(SPEventReceiverType.ItemAdding, assemblyName, ctReceiverName);
ct.EventReceivers.Add(SPEventReceiverType.ItemAdded, assemblyName, ctReceiverName);
ct.Update();
}
Thx !
I'm not sure, but could you try to add the event receiver to the content type before you add the content type to the list.
I think the event receiver has to be added before because when adding a content type to a list the content type is not added directly to the list, rather a copy of it is added to the list. So when you add your content type to the list, there is no event receiver yet.
I have a custom site definition, in an ONET.XML file.
Can I get the URL and/or the Site name of the site that is being created and use it as a parameter/moniker in the onet.xml file?
Something like this:
<Modules>
<Module Name="Default" Url="" Path="">
<File Url="default.aspx" NavBarHome="True">
<AllUsersWebPart WebPartZoneID="Right" WebPartOrder="1">
<![CDATA[
<WebPart xmlns="http://schemas.microsoft.com/WebPart/v2" xmlns:iwp="http://schemas.microsoft.com/WebPart/v2/Image">
<Assembly>Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c</Assembly>
<TypeName>Microsoft.SharePoint.WebPartPages.ImageWebPart</TypeName>
<FrameType>None</FrameType>
<Title>[NAME OF MY SITE] or [URL]</Title>
Not to the best of my knowledge.
I have used a solution where I add the webparts programmatically via the WebPartManager and then to set properties on that WebPart I use reflection.
An example to add the WP to a page:
public static void AddWebPart<T>(string webPartZone, SPFile page)
{
Type wpType = typeof(T);
AspNet.WebPart webPart =
(AspNet.WebPart)wpType.GetConstructor(new Type[0]).Invoke(new object[0]);
try
{
page.CheckOut();
SPLimitedWebPartManager wpManager =
page.GetLimitedWebPartManager(AspNet.PersonalizationScope.Shared);
wpManager.AddWebPart(webPart, "WP Zone Name", 0);
page.CheckIn("Added web part", SPCheckinType.MajorCheckIn);
and here is how to set proprties on webparts:
public static void SetWebPartProperties<T>(Dictionary<string, string> properties,
SPFile page)
{
Type wpType = typeof(T);
SPLimitedWebPartManager wpManager =
page.GetLimitedWebPartManager(AspNet.PersonalizationScope.Shared);
foreach (AspNet.WebPart wp in wpManager.WebParts)
{
if (wp.GetType() == wpType)
{
foreach (KeyValuePair<string, string> kvp in properties)
{
System.Reflection.PropertyInfo pi = wpType.GetProperty(kvp.Key);
if (pi.PropertyType == typeof(int))
pi.SetValue(wp, int.Parse(kvp.Value, CultureInfo.InvariantCulture), null);
else if (pi.PropertyType == typeof(bool))
pi.SetValue(wp, bool.Parse(kvp.Value), null);
pi.SetValue(wp, kvp.Value, null);
}
wpManager.SaveChanges(wp);
}
}
page.CheckIn("Changed properties of webpart", SPCheckinType.MajorCheckIn);
}
I don't know of any way to do this with ONET.XML.
I'd recommend using a feature to add the web part. You can use feature stapling to associate the feature with a site definition. This way, when a site is created based on your site definition your feature is automatically activated.
In your feature you can write code to programmatically add your web part and you'll be able to access properties of the SPWeb (i.e. the site) and get its URL or site name as required.
Does anyone know how to customize the master page (i.e. default.master) for a WSS 3.0 site? Actually, I already know how to customize the master page (i.e. via SharePoint Designer, or a text editor), I'm more interested in learning how to tell WSS 3.0 to use my customized master page.
I've renamed the default.master with my customized version and that works, but that sets it for all WSS sites. I want to be able to use version A of a master page for site collection A, and a separate master page for other site collections.
Note, I'm NOT referring to MOSS 2007. I already know how to set the master page for MOSS 2007. I can't seem to figure out how to do it for WSS 3.0 though.
Thanks.
WSS pages use Master Pages just like regular web apps. However, the value if the MasterPageFile attribute is a token, and is set to "~default.master". This token gets replaced with the actual reference to the master page in the page's PreInit method.
You can change the value of ~default.master to anything you like. But a better solution is to do the same type of thing that SharePoint does.
I added an HttpHandler to my SharePoint site. The handler attaches to the PreRequestHandlerExecute method, and changes the value of the master page file attribute before SharePoint starts rendering the page.
Add a line to the httpModules section of the web.config that looks like this:
Then create a class like this:
namespace MyClassLibrary.Utility
{
public class MasterPageHttpModule : IHttpModule
{
public void Init(HttpApplication context)
{
context.PreRequestHandlerExecute += new EventHandler(context_PreRequestHandlerExecute);
}
void context_PreRequestHandlerExecute(object sender, EventArgs e)
{
bool useCustomMasterPages = Convert.ToBoolean(ConfigurationManager.AppSettings["ShowCustomMasterPages"].ToString());
if (useCustomMasterPages)
{
Page page = HttpContext.Current.CurrentHandler as Page;
if (page != null)
{
page.PreInit += new EventHandler(page_PreInit);
}
}
}
void page_PreInit(object sender, EventArgs e)
{
bool useThreeColumnMaster = Convert.ToBoolean(ConfigurationManager.AppSettings["UseThreeColumnMasterOnDefaultPage"].ToString());
try
{
Page page = sender as Page;
if (page != null && SPContext.Current != null)
{
string url = page.Request.Url.AbsolutePath.ToLower();
if (url.IndexOf("/public/") > -1)
{
if (url.IndexOf("sitemap.aspx") == -1)
{
page.MasterPageFile = "~/_catalogs/masterpage/edge_con.master";
}
else
{
page.MasterPageFile = "";
}
}
else if (url.IndexOf("default.aspx") > -1)
{
if (useThreeColumnMaster)
{
page.MasterPageFile = "~/_catalogs/masterpage/edge_con.master";
}
else
{
page.MasterPageFile = "~/_catalogs/masterpage/edge.master";
}
}
else if (url.IndexOf("sitemap.aspx") > -1)
{
//
// Sitemap pages should not have a master page
//
page.MasterPageFile = "";
page.Controls.Clear();
}
else if (url.IndexOf("/admin/") > -1)
{
page.MasterPageFile = "~/_catalogs/masterpage/edge.master";
}
else if (url.IndexOf("/member/") > -1)
{
page.MasterPageFile = "~/_catalogs/masterpage/edge.master";
}
else if (url.IndexOf("/supplier/") > -1)
{
page.MasterPageFile = "~/_catalogs/masterpage/edge.master";
}
else if (page.MasterPageFile == "~masterurl/default.master")
{
page.MasterPageFile = "~/_catalogs/masterpage/edge.master";
}
}
}
catch (Exception exception)
{
LogWriter logWriter = new LogWriter();
logWriter.WriteToLog("Could not set master page: " + exception.Message, LogType.MasterPage, DateTime.Now);
}
}
public void Dispose()
{
}
}
}
Now you are dynamically choosing a mater page.
You need to change the MasterUrl property on the SPWeb object representing the site. A good way to do this is to create a SharePoint feature that when activated sets the property, and when deactivated restores the original value. The Feature.xml could look like this:
<?xml version="1.0" encoding="utf-8"?>
<Feature Id="8651CC66-FEB1-4255-B7E9-0DFE24367DAB"
Title="My Master Page"
Scope="Web"
SolutionId="06D3B01F-0C26-457a-BFA5-A1B0BC8D4225"
ReceiverAssembly="MyAssembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=9e95445247029289"
ReceiverClass="MyFeatureReceiver"
xmlns="http://schemas.microsoft.com/sharepoint/">
<ElementManifests>
<ElementManifest Location="Masterpage.xml"/>
<ElementFile Location="my.master"/>
</ElementManifests>
<Properties>
<Property Key="MyMaster" Value="my.master" />
</Properties>
</Feature>
The file Masterpage.xml uploads your master page to the gallery:
<?xml version="1.0" encoding="utf-8" ?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<Module Name="UploadMaster" Url="_catalogs/masterpage" >
<File Url="my.master" Type="GhostableInLibrary" IgnoreIfAlreadyExists="True"/>
</Module>
</Elements>
Include this feature in a WSP solution along with the MyAssembly.dll containing the MyFeatureReceiver class, which goes like this:
public class MyFeatureReceiver : SPFeatureReceiver
{
public override void FeatureActivated(SPFeatureReceiverProperties properties)
{
SPWeb web = (SPWeb)properties.Feature.Parent;
web.MasterUrl = properties.Definition.Properties["MyMaster"].Value;
web.Update();
}
public override void FeatureDeactivating(SPFeatureReceiverProperties properties)
{
SPWeb web = (SPWeb)properties.Feature.Parent;
web.MasterUrl = "default.master";
web.Update();
}
public override void FeatureInstalled(SPFeatureReceiverProperties properties)
{
}
public override void FeatureUninstalling(SPFeatureReceiverProperties properties)
{
}
}
Finally, deploy the solution and activate the feature on your site(s).