Anybody has any ideas what exactly spWeb.Features.Add does? - sharepoint

anybody know what exactly below code does?
SPWeb.Features.Add(Guid, bool)
Does it use the .xmls in Template\Features\<-myFeature-> to install the feature and activate it? Or just activate it? Or something else?
Thanks!

The method you specified activates feature with specified id on specified SPWeb object. It does not install it. Here is MSDN link.
It actually uses xml files in "Template\Features\<-myFeature->" folder when you activate feature.
But if you change file in this folder you won't see any effect momentary because this files are cached. After changing files in feature folder you need to do iisreset and then activate feature in order to see the difference.

Related

Newly created dependency property is not recognized from another solution

I have a question regarding Dependency Properties in WPF.
I am working on a project which uses controls from another package. I modified one of the controls by adding new dependency properties to it. However, when I try to access them in xaml that is in my project, I get error stating that there's no such property in my control. At the same time when I set the values of those properties in style for this control in a file that is located in the same package as the control, everything works. Also, the old dependency properties work fine.
I'm not sure what code to include to illustrate this, please give a hint.
Could anybody at least hint what is going on?
Thank you in advance.
The problem was that I didn't include in Build-Events of my first solution where the controls reside the path where to copy the respective dll so that the second solution could detect the changes.

How to fix SPFeatureDefinition does not contain a definition for RootDirectory

I'm very new to SharePoint development, and I'm just trying to add an XML file to a Feature to reference the XML file content in the feature Event Receiver.
It seems that the general recommendation is to use do so like in this SO question:
How to retrieve data from an XML file in a Sharepoint 2010 Feature Event Receiver?
However, my code does not compile when I reference the RootDirectory property. The error I see is below
'Microsoft.SharePoint.Administration.SPFeatureDefinition' does not contain a definition for 'RootDirectory' and no extension method 'RootDirectory' accepting a first argument of type 'Microsoft.SharePoint.Administration.SPFeatureDefinition' could be found (are you missing a using directive or an assembly reference?
Now, the weird part is that while debugging, I am able to evaluate the RootDirectory property correctly in the Quick Debug window.
Am I missing something obvious? Like I said, I'm completely new to SharePoint.
My feature is scoped to the Web level, and I do have a reference to Microsoft.Sharepoint.Administration in my using statements.
Any help is greatly appreciated, thanks.
It was indeed something very basic.
The solution/project was set as Sandboxed. Just going to the properties of the project (not the property pages but hitting F4 while the project is selected on Solution Explorer) and setting Sandboxed to false will let you compile when you're accessing the RootDirectory solution in code.
Also, a few other properties/method not show up when the solution is Sandboxed instead of marked as a Farm solution.

Changing vista file permissions programmatically

I want to add some files to C:\windows\XXX (windows protected folder, in Vista), under the "TrustedInstaller" for my application. I do not want to replace any file so no issues on Windows Resource(formerly file) protection.
I have the code to change "ownership" to the current logged in admin, however, I'm don't have any clue how to set its file permissions programmatically. I'm using VC++/MFC for development.
Thanks
I not 100% sure what you actually want (as do you want it to look like TrustedInstaller installed the files?) but look at this example of using SetNamedSecurityInfo. You generally need to constuct a Discretionary Access Control List (DACL) for your file, however you can "borrow" one off another file with the permissions you want to clone using GetNamedSecurityInfo as building a DACL from scratch is considerably more annoying.
An easy way to do it is to just use the system function to run icacls with whichever parameters you need. Note that it's found in cstdlib (#include <cstdlib>)
system("icacls <params>");

SharePoint: "Failed to extract the cab file in the solution"

I'm receiving a "Failed to extract the cab file in the solution" error when I try to deploy my wsp using stsadm -o addsolution -filename...
I've open the wsp as a cab and checked that there are no duplicate files in there as I understand that can sometimes cause this issue.
The issue only started when I tried to include a custom field type as part of my solution, to do this I added the following to the ddf
..\CustomFields\ShortMonth\ShortMonthControl.ascx ..\CONTROLTEMPLATES\ShortMonthControl.ascx
..\CustomFields\ShortMonth\fldtypes_shortmonth.xml ..\XML\fldtypes_shortmonth.xml
and
<TemplateFiles>
<TemplateFile Location="CONTROLTEMPLATES\ShortMonthControl.ascx"/>
<TemplateFile Location="XML\fldtypes_shortmonth.xml"/>
</TemplateFiles>
to the manifest.
I've tried taking it back to just references to the ascx in both but it doesn't see to help.
Any ideas?
Check that you don't have any special characters in your files. They might have sneaked in as a result of copy-paste. For example, the way your code sample renders on this page, it has the (`), which shouldn't be there.
Do you need the "..\" in your DDF?
The issue is more likely due to invalid names for files you are deploying on SharePoint 14 hive folder. If you are using parenthesis ‘(‘, ‘)’ in file names or special characters like # in file names, this issue will occur.
Remove it and issue should vanish.
I just know I have had the same issues and I think I made a note of it at work somewhere (I´ll check that tomorrow and post back here if I find something). I just can´t remember how I fixed it right now (maybe it was a slash the wrong way / vs. \..hmm).
I did a search for it on google (which I think you have also done). Found this (check it out):
http://www.codeplex.com/wspbuilder/WorkItem/View.aspx?WorkItemId=7385
The List Instance Name I had was "MyListInstance (List Instance)". I removed the brackets from the name and it deployed without issues.
Check the .ddf file for a line that could have been accidentally duplicated. Apparently sharepoint doesn't like that!
A reboot solved my 'Failed to extract cab file' problem. There were some updates installed and an reboot was required. Was not clear that this was related but it helped.
Something would have gone wrong during the build of WSP.
Re build the WSP and Deploy- it should work fine.

Launch Infopath form with parameter

Opening an Infopath form with parameter can be done like this:
System.Diagnostics.Process.Start(PathToInfopath + "infopath.exe", "Template.xsn /InputParameters Id=123");
But that requires I know the path to Infopath.exe which changes with each version of Office. Is there a way to simply launch the template and pass a parameter? Or is there a standard way to find where Infopath.exe resides?
Play around with System.Diagnostics.ProcessStartInfo which allows you to specify a file you wish to open and also allows you to specify arguments.
You can then use Process.Start(ProcessStartInfo) to kick off the process. The framework will determine which application to run based on the file specified in the ProcessStartInfo.
I don't have Infopath installed so I unfortunately can't try it out. But hopefully it helps you out a little.
Here's an article about finding the install path for Office Apps:
http://support.microsoft.com/kb/234788
Try using browser based form and querystring instead

Resources