Wednesday, May 23, 2012

remove user from sharepoint group

The trick is

SPUser user = web.EnsureUser(peCheckUser.Accounts[0].ToString());

                            SPGroupCollection collGroups = user.Groups;
                            if (collGroups.Count > 0)
                            {
                                foreach (SPGroup oGroup in collGroups)
                                {
                                    oGroup.RemoveUser(user);
                                }
                                strError += "User Removed Successfully...!";
                            }


thanks to author @ http://sharepoint2010tutorialnew.blogspot.com/2011/12/deleting-user-within-sharepoint-group.html


Sunday, May 20, 2012

c# , display number in thousands seperator format


 NumberFormatInfo nfi = (NumberFormatInfo)CultureInfo.InvariantCulture.NumberFormat.Clone();
            nfi.NumberGroupSeparator = ",";
            Console.WriteLine(12345.ToString("n", nfi)); // 12,345.00

for my surprise it includes the decimal poiont at last. it made my job easy....:-)

thanks to author @ http://stackoverflow.com/questions/752145/use-a-custom-thousand-separator-in-c-sharp


Tuesday, May 1, 2012

SharePoint : thread was being aborted

I was getting "Thread was being aborted" error while running my workflow. My Workflow required 5-10 mins to finish. but after 2 or 3 mins I started my workflow, it was throwing this error. which i got from my error log.

I could Identify that, the error is coming in different steps (workflow activities) everytime. It means problem is neither with data nor with the code.

then after searching for sometime. I found this article @

http://dirkvandenberghe.com/2010/01/29/sharepoint-timeout-error-thread-was-being-aborted.html

thanks to author.


the actual problem is sharepoint execution time.

The solution to the problem is
<httpRuntime executionTimeout=“200“ maxRequestLength=“51200“/>

try to find the "<httpruntime"  element in your sharepoint's web application's web.config file and include this attribute.  " executionTimeout=“2000“ "


I changed it to "2000". now the problem is solved. (at least for me)

this may help to those who overlooked this check.

Tuesday, April 17, 2012

SharePoint 2010 + ssis adapter + currency field

The currency field in SharePoint list is not updated with the value we get from the source.

After hours of "trail & error" methods, found solution.

Currency field's source data type is "Numeric"

this data type to be changed to "float" using Data Conversion component.

then it worked.




sharePoint + SSIS adapters + The content type text/html; charset=utf-8 of the response message does not match

I am getting the following lengthy error.

[SharePoint List Destination 1 [3738]] Error: System.ServiceModel.ProtocolException: The content type text/html; charset=utf-8 of the response message does not match the content type of the binding (text/xml; charset=utf-8). If using a custom encoder, be sure that the IsContentTypeSupported method is implemented properly. The first 1024 bytes of the response were: '
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns:o="urn:schemas-microsoft-com:office:office" lang="en-us" dir="ltr">
<head><meta http-equiv="X-UA-Compatible" content="IE=8" /><meta name="GENERATOR" content="Microsoft SharePoint" /><meta name="progid" content="SharePoint.WebPartPage.Document" /><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><meta http-equiv="Expires" content="0" /><title>
   
Error Page

</title><link rel="stylesheet" type="text/css" href="/_layouts/1033/styles/Themable/layouts.css?rev=aTcoNUf8p1YiDzYCg3%2FLIw%3D%3D"/>
<link rel="stylesheet" type="text/css" href="/_layouts/1033/styles/Themable/corev4.css?rev=iIikGkMuXBs8CWzKDAyjsQ%3D%3D"/>

    <script type="text/javascript">
    var _fV4UI = true;
    </script>
    <script type="text/javascript">
// <![CDATA[
document.write('<script type="text/javascript" src="/_layouts/1033/init.js?rev=BjQJs0OCQh3Zfydsdw2MYw%3D%3D"></' + 'script>');
document.write(''.

Server stack trace:
   at System.ServiceModel.Channels.HttpChannelUtilities.ValidateRequestReplyResponse(HttpWebRequest request, HttpWebResponse response, HttpChannelFactory factory, WebException responseException, ChannelBinding channelBinding)
   at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
   at System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout)
   at System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message message, TimeSpan timeout)
   at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
   at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
   at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)

Exception rethrown at [0]:
   at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
   at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
   at Microsoft.Samples.SqlServer.SSIS.SharePointUtility.ListsService.ListsSoap.UpdateListItems(UpdateListItemsRequest request)
   at Microsoft.Samples.SqlServer.SSIS.SharePointUtility.ListsService.ListsSoapClient.ListsService_ListsSoap_UpdateListItems(UpdateListItemsRequest request)
   at Microsoft.Samples.SqlServer.SSIS.SharePointUtility.ListsService.ListsSoapClient.UpdateListItems(String listName, XElement updates)
   at Microsoft.Samples.SqlServer.SSIS.SharePointUtility.Adapter.ListsAdapter.ExecuteSharePointUpdateBatch(String listName, String viewId, XElement batchXml, Int16 batchSize)
   at Microsoft.Samples.SqlServer.SSIS.SharePointUtility.ListServiceUtility.UpdateListItems(Uri sharepointUri, NetworkCredential credentials, String listName, String viewName, IEnumerable`1 fieldValueList, Int16 batchSize)
   at Microsoft.Samples.SqlServer.SSIS.SharePointListAdapters.SharePointListDestination.ProcessInput(Int32 inputID, PipelineBuffer buffer)
   at Microsoft.SqlServer.Dts.Pipeline.ManagedComponentHost.HostProcessInput(IDTSManagedComponentWrapper100 wrapper, Int32 inputID, IDTSBuffer100 pDTSBuffer, IntPtr bufferWirePacket)






I got this error while updating data to my sharepoint list. After struggling a lot found the solution.

the problem is,  SharePoint Event Receivers ,  I have some event receivers on this list, while updating those items, it throws the error. ultimately SSIS adapter is throwing error like above.

So i deactivated the feature which contains the event receivers temporarily and executed the SSIS package.

voila  "IT'S WORKING"


This may help those who overlooks the event receivers

Thursday, February 16, 2012

Error occurred in deployment step 'Recycle IIS Application Pool': Provider load failure

I got this error while deploying my application in SharePoint Foundation.

I tried Reset IIS,
Restart SP 2010 Administration servce
Restart SP 2010 Timer servce
close & re-open Visual Studio.......

nothing made my solution deploy 

finally I did

restart the WMI Performance Adapter service on the machine in services. Worked for me.

Sunday, February 12, 2012

Your backup is from a different version of Microsoft SharePoint Foundation

I got this error while restoring a backup taken from my Dev server onto QA server.

The error was "Your backup is from a different version of Microsoft SharePoint Foundation and cannot be restored to a server running the current version. The backup file should be restored to a server with version ’14.0.0.4762′ or later"

After googling for many hours found some solutions

1. In Central Admin, go to "Upgrade and Migration".  Click on "Check product and patch installation status".  Scroll down the page of results and see if there are any links to updates that have been installed on the original server that are not on the new server, or vice-versa.
If you find different versions then update the hotfix on the other server. after updating make sure both server's versions are same.

Then I tried to restore again.
 This time I got "Your backup is from a different version of Microsoft SharePoint Foundation and cannot be restored to a server running the current version. The backup file should be restored to a server with version '4.0.145.0' or later.""

Then again googled found this article

http://rahi2sharpoint.blogspot.com/2011/12/your-backup-is-from-different-version.html#!/2011/12/your-backup-is-from-different-version.html

Thanks to author

the reason is, though foundation is update to date, content database is still not upgraded to new version. To ensure follow these steps

  1. Check The DB schema
  2. Get-SPContentDatabase <DB name>| Format-List *
    In this check the SchemaVersionXML if it is "4.0.145.0" then you have to run the below powershell script
  3. Upgrade-SPContentDatabse –Identity <DB Name>

Then I tried taking a fresh backup and restoring. This time its SUCCESSFUL . I Used STSADM to do this
This one helped me to resolve the problem which I faced.


For your info:- To ensure the versions in both servers.  Open the target application's content database in both servers then find a table called "VERSIONS". Then query the table and find the versions that web application using. it shows both versions of Foundation as well as content databse version. DO NOT try to change anything here.
 
have a look at this URL. It may help you.
http://moustafa-arafa.blogspot.com/2011/11/sharepoint-restore-error-your-backup-is.html