Tuesday, August 14, 2012

c# + System.Diagnostics.Process.Star + Access denied

I am getting the "Access denied" error while executing my exe which is internally executing one batch file.

Its working fine in my dev server, but receiving the above error in Prod server.

After searching a while found this atricle @ http://blogsandip.wordpress.com/2011/08/06/resolved-access-denied-error-on-system-diagnostics-process-start/


thanks to author


The trick is 


p.StartInfo.UseShellExecute = false;
p.Start();
p.WaitForExit();

Monday, August 6, 2012

File not found + site settings + sharepoint

Hi,

I am facing "File Not found" error when I click on Site settings.

After searching in internet I found out that,

this problem may occur when we play with AAM (alternate access mapping)

so try to keep the actual URL and change the settings and again change the URL as you desired.

Wednesday, July 25, 2012

SharePoint Timer Job targeted at specific web application

I have a work around for this.

If any one knows the solution please update me @  rajesh.chennupati@gmail.com


basically features defined with some scope will appear in all the scope specific area

I means ( scope with web, will be visible in all site features
                scope with site, will be visible in all site collection features.......)

(we can avoid this by changing the feature's Hidden property to TRUE)


in the same way timerjobs' scope may be web application. So the same feature appears in all webapplications.

The problem is :- if feature's scope is webapplication/Farm then by default the feature is activated THOUGH YOU SELECT "NO ACTIVATION" in project properties.

It means the feature is activated when you deploy the sharepoint solution, ultimately the timerjob feature is activated and is called from all the webapplications in the farm.

This is not the required result.

So we have to deactivate the feature from the remaining webapplications apart from the required one.

If you have many web applications in your farm then it's tedious to deactivate.

The solution is:- Goto the feature where timerjob is registered with scope web application->  then goto properties (click F4 when you open the feature). Then set "Activate On Default" property to False.


This work around solved my problem.



powershell + The Feature is not a Farm level feature

I got the below error while deploying a feature using powershell.

Error:- The Feature is not a Farm level feature and is not found in a site level defined by the url ........


my powershell command is :- Enable-sPFeature -identity "XXX EventReceivers" -force -confirm:$false -url $WebURL

"XXX EventReceivers" is the feature name in my application.

But When I see in "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\FEATURES" path the feature name is "ABC_XXX EventReceivers" . Where as "ABC" is my project name.


The working command is :- Enable-sPFeature -identity "ABC_XXX EventReceivers" -force -confirm:$false -url $WebURL

So dont overlook at the feature name.


Happy coding

Wednesday, July 11, 2012

SharePoint + SSRS Reports + Current User

How to pass current user's login name as parameter to a RDL . (SSRS integration with sharepoint)

Thanks to author @ 
http://social.msdn.microsoft.com/Forums/en-US/sqlreportingservices/thread/751a3733-2e2b-49f8-8de5-8e692433091b/


 The important point hers is setting the "=User!UserID " value to parameter 

Goto parameters section and select the parameter which passes current user name as value,

right click on it, then select "parameter properties" .

Goto default valus tab, select "Specify values" Radio Button.

and in value field at bottom  paste

[&UserID]   OR   =User!UserID
   
It passes the value as "domain\firstName.LastName"

in sharepoint list, the people or group field shows by default as "Name (with presence) " 

change the type to "Account" for the field.

It should work fine



happy coding
 

Tuesday, June 12, 2012

workflow's tasks deleted in sharepoint when deploy

when we deploy sharepoint solutions, the tasks which are created by workflows are deleted.

But if want those tasks then......


thanks to Ashish Mishra31



The solution is here


  1. You need to first go to the list where previous WF is attached and in its setting click No New Instance.
  2. Then deploy your new WF with new name.



Thursday, May 31, 2012

VS 2010 RDLC Report Fixed header

Im creating one rdlc report in VS 2010.

I am using tablix.

I wanted fixed header.

After struggling sometime, I could  find the solution.

here is the way.

After you design the report, see bottom of your report. You can find "Row Groups" & "Column Groups"
section.

 for column groups there will be a down arrow button. click the button. You will get "Advanced Mode"  menu.

then you can see the two rows in "row groups" section.

first one (static) is header section. second one(details) is details section.

select the static row and click F4. it opens properties window.

then set FixedData to TRUE.







Wednesday, May 30, 2012

Get currency value from a string contains $

Here is a quick way to get the currency value from a string which contains "$" and ",".

Some  may struggle to remove the "$" and  ","

but here is the way

Double pdblValue = Double.Parse("$96,000.00", NumberStyles.Any);


it needs a reference to "System.Globalization"  namespace

A Web Part with this ID has already been added to this page

Recently I was playing with adding webparts programatically.

Then I got this error "A Web Part with this ID has already been added to this page"

tried to use contents=1, but no use . it says page could not found

finally found the below link

http://dpruna.blogspot.com/2011/11/web-part-with-this-id-has-already-been.html

Thanks to author.


using the following procedure we can find out the webparts added to the given page.

Note:- it contains webparts added by all the users. (Not only you)

it gives you list of webparts added to that page (problamatic duplicate webparts aswell). Then you know what to do.

delete the webpart wisely

if it is dev server then may be less issues, but if it is Production server.........be careful

Here is the procedure.

Note:- My list exists in subsite ("ABC"). So I had to use @DocDirName = N'ABC/Lists/Raportari',


declare @DocDirName nvarchar(255),
        @DocLeafName nvarchar(255),
        @SiteId uniqueidentifier,
        @DocId uniqueidentifier,
        @DocParentId uniqueidentifier,
        @Level int
 
select  @SiteId = '88501D83-5339-4745-827F-0C7454F9B7BD',
        @DocDirName = N'Lists/Raportari',
        @DocLeafName = N'EditForm.aspx',
        @Level = 1
 
SELECT TOP 1  
    @DocParentId = ParentId,  
    @DocId = Id  
FROM  
    TVF_Docs_NoLock_Url(@SiteId, @DocDirName, @DocLeafName) AS Docs  
 
SELECT  
    WP.tp_ID,  
    WP.tp_WebPartTypeId,  
    WP.tp_Assembly,  
    WP.tp_Class,
    WP.tp_SolutionId,  
    WP.tp_AllUsersProperties,    
    WP.tp_WebPartIdProperty,
    WP.tp_Version,  
    WP.tp_Cache,  
    (N'{' + CAST(WP.tp_ListId AS nvarchar(36)) + N'}') AS tp_ListId,  
    WP.tp_Type,  
    WP.tp_Source,  
    WP.tp_BaseViewID,  
    WP.tp_View,  
    WP.tp_CreationTime  
FROM  
    AllWebParts AS WP WITH (INDEX=PageUrlID_FK)
WHERE  
    tp_SiteId = @SiteId AND  
    tp_IsCurrentVersion = CONVERT(bit, 1) AND  
    tp_PageUrlID = @DocId AND  
    tp_PageVersion = 0 AND  
    tp_Level = @Level

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