To modify/add a web config entry following code can be referred
// Get the SPSite object
SPSite site = new SPSite("URL");
if (site != null)
{
SPWebApplication webApp = site.WebApplication;
// Create the modification entry
SPWebConfigModification webEntry = new SPWebConfigModification("Web Config entry " ,"Entry location" );
// Add the web config entry to the collection
webApp.WebConfigModifications.Add(webEntry);
webApp.Farm.Services.GetValue().ApplyWebConfigModifications();
}
Web Config Entry could be
"SafeControl[@Assembly="MyAssembly"][@Namespace="My.Namespace"]"
+ @"[@TypeName="*"][@Safe="True"][@AllowRemoteDesigner="True"]"
Entry location could be
configuration/SharePoint/SafeControls
Thursday, 23 December 2010
Wednesday, 15 December 2010
Could not load file or assembly CustomMarshalers
Recently, I came across a weird issue while running the code in different environment.
Suddenly I started getting "Could not load file or assembly CustomMarshalers" at certain line of my code. It was difficult to understand why same code is not running in new environment. I investigated a bit and found that "CustomMarshalers" is required for compact framework which is not at all useful in my application. Ii couldn't found any solution except changing my code.
1. I had used LINQ queries at few places in my application so i had to change it to CAML query to run in all the environment
2. Wherever I was using "foreach" block and using Sharepoint object collection like SPListItemCollection, I was getting mentioned error. So I had replace all the "foreach" blocks with "for" construct.
I hope these information may help somebody....
Suddenly I started getting "Could not load file or assembly CustomMarshalers" at certain line of my code. It was difficult to understand why same code is not running in new environment. I investigated a bit and found that "CustomMarshalers" is required for compact framework which is not at all useful in my application. Ii couldn't found any solution except changing my code.
1. I had used LINQ queries at few places in my application so i had to change it to CAML query to run in all the environment
2. Wherever I was using "foreach" block and using Sharepoint object collection like SPListItemCollection, I was getting mentioned error. So I had replace all the "foreach" blocks with "for" construct.
I hope these information may help somebody....
Backup and restore using powershell command
Backup
backup-spsite -identity "site-collection-path" -path "backup-location"
where
site-collection-path : http://machinename:port/sites/sitecollectionname
backup-location : D:/backup/site.bak
Restore
restore-spsite -identity "site-collection-path" -path "backup-location" -Force
Note: You can not restore more than one site collection in a web application so you have to create a new database. Below command can be used to overcome this issue.
restore-spsite -identity "site-collection-path" -path "backup-location" -Force -DatabaseName "DBNAME"
To Create a new Database follow below instruction
Goto Central Administration---> Manage Content Databases-->Add New Content Database
backup-spsite -identity "site-collection-path" -path "backup-location"
where
site-collection-path : http://machinename:port/sites/sitecollectionname
backup-location : D:/backup/site.bak
Restore
restore-spsite -identity "site-collection-path" -path "backup-location" -Force
Note: You can not restore more than one site collection in a web application so you have to create a new database. Below command can be used to overcome this issue.
restore-spsite -identity "site-collection-path" -path "backup-location" -Force -DatabaseName "DBNAME"
To Create a new Database follow below instruction
Goto Central Administration---> Manage Content Databases-->Add New Content Database
Subscribe to:
Posts (Atom)
Query List/Document Library in Specific Folder
To query SharePoint List or Document Library in specific Folder “ FolderServerRelativeUrl ” as part of the CAML Query Code Snippet ...
-
#Add a sharepoint group using power shell #Create a sharepoint custom permission using Power shell $web = get-SPWeb "http://sitecollect...
-
I am very sure that most of the Sharepoint developers must have used _spBodyOnLoadFunctionNames to inject javascript methods on the sharepo...
-
This issue occurs when you do backup restore of the site/site collection. Due to this you can not see the page in design mode due to some re...