Welcome

Sharepoint lead is a place where you can read about interesting topics related to sharepoint, and you can also post comments and suggessions.
Showing posts with label tips and tricks. Show all posts
Showing posts with label tips and tricks. Show all posts

Wednesday, April 23, 2014

ascx.g.cs Empty

Bug:
In Visual Studio 2012, when you are working with a visual web part, your user control's ascx.g.cs file becomes empty. So you get an error "The name ‘InitializeControl’ does not exist in the current context".

Root cause:
This is reported as a bug in visual studio 2012 and it generally happens when your server side mark up is having issues. This ONLY happens when you are editing your ascx file.

Suggested Solution:
You can try following:
Short way:

  • try to undo some of the last changes in ascx file.
  • Create copy of ascx file and revert it from source control. Rename g.cs to g.txt and switch to ascx and hit save. That will generate another g.cs with correct content

Long way:

  • Please check the @Register declarations against the TagPrefix and TagName that you are using.
  •  Try to comment out all controls in ascx and save it. That will generate ascx.g.cs along with content again. Now start un-commenting the controls one by one.
  • In worst cases, after trying lots of things people also switch to new web part and migrate useful code from the problematic web part step by step to resolve the error. 

Sunday, January 6, 2013

System.ArgumentException: Exception of type 'System.ArgumentException' was thrown. Parameter name: encodedValue

I was configuring one of our clients farm which required FBA on different web applications (around 5) and he wanted each web application should have separate user store. That was too tricky since you just need to set up Application property of the membership provider and you are done.
After completion of these settings, all of my applications were having a common exception either in log out or login to the web application. Here was the exception.
System.ArgumentException: Exception of type 'System.ArgumentException' was thrown.  Parameter name: encodedValue    at Microsoft.SharePoint.Administration.Claims.SPClaimEncodingManager.DecodeClaimFromFormsSuffix(String encodedValue)     at Microsoft.SharePoint.Administration.Claims.SPClaimProviderManager.GetProviderUserKey(IClaimsIdentity claimsIdentity, String encodedIdentityClaimSuffix)     at Microsoft.SharePoint.Administration.Claims.SPClaimProviderManager.GetProviderUserKey(String encodedIdentityClaimSuffix)     at Microsoft.SharePoint.Utilities.SPUtility.GetFullUserKeyFromLoginName(String loginName)     at Microsoft.SharePoint.ApplicationRuntime.SPHeaderManager.AddIsapiHeaders(HttpContext context, String encodedUrl, NameValueCollection headers)     at Microsoft.SharePoint.ApplicationRuntime.SPRequestModule.PreRequestExecuteAppHandler(Object oSender, EventArgs ea)     at System.Web.HttpApplication.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()     at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
After checking all my steps right through starting. After getting all the other exeptions cleared the above exception was the only exception that I was getting. That was resolved using "Exception of type 'System.ArgumentException' was thrown" got error when i have signout from webapplication in sharepoint 2010?.
I hope this will help to you if you are getting same error due to a silly custom property of a custom web part for registration!

Update - 5/19/2014

There are several solutions that I tried:
The same error also encountered again reported by client when he tries to enable intranet through internet explorer settings. Disabling detection of intranet from internet options solves that issue but you are forced to enter username password every first visit of the site even in intranet as well!

Update - 5/25/2014

This is a SharePoint bug also found some discussion here: https://sharepoint2013fba.codeplex.com/workitem/9 

Hope this helps

Sunday, December 30, 2012

SharePoint 2010 foundation on windows 7

If you are planning to install SharePoint 2010 foundation in your windows 7 machine, there are very good references out there in many blogs. But after I installed it I was not able to create new web applications.

I noticed, I was an administrator account with different name than administrator. I found here that we can enable in built administrator account.

I enabled administrator account and added it to managed accounts and farm administrators group.

After trying so many things from forums, finally I got everything working in SharePoint Foundation in my machine!

Friday, June 22, 2012

How to use soapUI to review ListData.svc


Introduction

​SoapUI is a free tool that can be used to test out of the box ListData.svc service provided by sharepoint. This service is available at /_vti_bin/ListData.svc for any of your sharepoint site. Here is how we can try it out using SoapUI.

Step 1: Install sopa UI and click on File > New SoapUI Project. Add some project name and check "Add REST Seervice:" like shown in following figure and then click OK



Step 2: After clicking on OK another window will open like following, just click on OK




Step3: New REST resource window will appear. In resource name enter site url and in resource path/endpoint provide list/document library name and click on "Extract params" button. Following is the screen that shows sample data.




Step4:That will automatically create a new request called Request 1.This request will automaticlaly detect endpoint and path to your list/document library. If it is not, just click on"-no endpoint set-" and click on add new endpoint. Enter site url in the dialog again.



Step5: Maximize "Request 1" window in soapUI. In botton left corner you will see " ... ", click on it and you will be able to provide sharepoint authentication details there.



Step6: Once you are done with authentication details you can click on execute icon at top left corner of "request 1" window (marked in above figure) to execute the request and you will be able to see response at right hand side window.

Step7: ListData.svc can also return json data in response out of the box. Just try to provide accept = application/json like shown in figure below:


Conclution:
SoapUI is a super simple too to try out and it will be really help to review xml/json data while you are planninig to consume it with jQuery. 


Monday, May 28, 2012

CAML Designer: Try it now!

When you want to design/test your caml query, most of the time uses U2U CAML Query builder. Sometimes you get problem with connection but most of the time, it was working fine for most of the needs.

Recently, I tried CAML Designer which is really nice tool to try as alternative. WPF UI experience with many additional features may impress you to switch to this new tool.

Let me know your experience while evaluating

Thursday, May 17, 2012

PowerGUI script editor: powershell debugging and intellisense

​​​In this post I am going to show you how to use PowerGUI script editor for executing powershell. There are two main advantages of using PowerGUI:
  1. Dubugging of powershell script
  2. Intellisense support
So, let's start setting up PowerGUI to use with sharepoint 2010:
  1. Download and install latest version of PowerGUI.
  2. Download PowerGUI PowerPack for sharepoint.
  3. Start PowerGUI script editor​ and go to File > Powershell Libraries
  4. Click on "Add Module" and add downloaded "PowerPack for sharepoint" library here
  5. That will add another entry "Microsoft.Sharepoint.PowerShell" into the listing. Check the library to make it enable
  6. Restart PowerGUI script editor and you are ready to get started.

Wednesday, May 16, 2012

Best Practice: Maintaining scripts in your sharepoint project


Introduction

Branding is the most important part of any sharepoint project. If you are planning to deliver branding in your release, you have to make sure your developer team is proactive to deliver quality branding from early stage of the project. In most of the branding project, jQuery and javascript becomes must-have part. Here we will discuss practices that can be followed to ensure quality deliverables.

Practice
  1. Manage script files
    From the very starting stage of your project, split your all javascript code in three files.
    1. jQuery.min.js - This will contain jQuery reference and should be reference first in order.
    2. jQuery.plugins.js - This should contain all custom plugins we used in it.
    3. ProjectName.js - This hsould contain all your custom code written to get your project pages work properly​​
  2. ​Choosing plugins for your project
    1. Download plugin bundle to your local computer
    2. Generally plugin will contain sample html files, jQuery and plugin script files.
    3. First thing to check is, jQuery version you are using in your project and the one which is used in plugin
    4. If they are different, replace their jQuery.min.js with the one we are using
    5. Properly test the sample provided in plugin in all browsers you are planning to support
    6. Once browser and version compability matches paste plugin's min.js at end of jQuery.plugins.js file.
    7. Implement plugin specific mark up wherever applicable
    8. Always use projectName.js to initialize plugin.
    9. Repeat above process when you choose to add any jQuery plugin
  3. Resolving CONFLICTS!
    Another challenging part is jQuery ready not working or custom plugin you are using is disturbing your site's css. Here are thoughts on the same
    1. Aways use _spBodyOnLoadFunctionNames.Push("yourFunctionName") to init your scripts in page load.
    2. Always use only necessary css from what plugin css has proviced and prefix class or ID in css as application. For example if a generic class .clear is used and you are calling plugin using $('#news') you should replace that with #news .clear. Do this for all css you include for the class

Final thoughts
Here I pointed out some of the best practices. Like this post? You like to add/correct something? please provide your feedback on the same.

stsadmin -o deploysolution shows access denied error for some files


Problem

After firing deploysolution, looking at system settings > farm solutions and the error looks something like "Can not overrite xxxx file, access is denied".

Cause

specified file in your error is read only in your web application directory. Most of the time this happens when you are using some source control system that is making the file read only when it is checked in. 

Solution

Go to properties of the file and uncheck read only. If you are running a farm and you got multiple application servers, you need to repeate this for each application server.

Conclusion

80% of the developers uses command line to deploy their wsp as it is the convinient way to add or upgraded the solution.

Finally...

Got the same error? Don't worry try above solution. Didn't worked? Let me know which one worked for you?