Articles tagged with: SharePoint

Jan16

How to configure vs remote debugging for SharePoint 2010

Written by // Rogério Cruzeiro Categories // How To

  1. First download the x64 bits version of the Microsoft Visual Studio 2010 Remote Debugger from Microsoft website

  2. Install it on the server and run it as Administrator

  3. Make sure the WSP package / DLL in the GAC is up to date

  4. Copy the .pdb file from your build directory to the GAC folder
    Tip #1: use command line copy command
    Tip #2: map the windows assembly folder to a network drive to easily explore the inner folders

  5. Make sure you have and account with the same name in both machines

  6. Back to Visual Studio paste the server name in the qualifier text box (something like DOMAIN\username@SERVERNAME), hit Enter and the process list should popup from the server

  7. Attach to the appropriate IIS process (w3wp.exe) or SharePoint Timer Job process (OWSTIMER.EXE) 

  8. Wait while symbol are loading and after that you should able to debug the solution and hit breaking points.
Nov22

Find closed web parts using SharePoint UI

Written by // Rogério Cruzeiro Categories // How To, Brain Dump

Web Part Maintenance Mode

How to find closed Web Parts?
Open the Web Part page in Web Part Maintenance Mode.

How?
Append ?contents=1 at the end in address bar
Example: http://contoso.com/default.aspx?contents=1

Nov20

SharePoint 2010 Event Handler Properties

Written by // Rogério Cruzeiro Categories // Brain Dump

what to use?

  • SPItemEventProperties.AfterProperties
  • SPItemEventProperties.BeforeProperties
  • SPItemEventProperties.ListItem

 

Custom list

 

AfterProperties

BeforeProperties

ListItem

ItemAdding

Changed value

Nothing

Null

ItemAdded

Changed value

Nothing

Changed value

ItemUpdating

Changed value

Nothing

Original value

ItemUpdated

Changed value

Nothing

Changed value

ItemDeleting

Nothing

Nothing

Item

ItemDeleted

Nothing

Nothing

Null

 

Library

 

AfterProperties

BeforeProperties

ListItem

ItemAdding

Nothing

Nothing

Nothing

ItemAdded

Nothing

Nothing

Changed value

ItemUpdating

Changed value

Nothing/Original value

Original value

ItemUpdated

Changed value

Nothing/Original value

Changed value

ItemDeleting

Nothing

Nothing

Item

ItemDeleted

Nothing

Nothing

Nothing

Why two values for the ItemUpdated and ItemUpdating?

When you add a new document to a document library the events fired are in this order: ItemAdding > ItemAdded. Until here nothing new. 
Well right after you add a new document the EditForm pops up in order to allow you to change any properties for the document.
The events that are fired for this Form after you press Save are: ItemUpdating > ItemUpdated.
Yet, at this moment (the moment right after you add a new document), the BeforeProperties has no usefull values like it should. In fact, it has nothing.

So, not only the Update events are fired, when your are adding a new document (because infact the document is already saved), as the BeforeProperties work diferently from the standard Update action.

Oct26

Enable / Disable Developer Dashboard using stsadm

Written by // Rogério Cruzeiro Categories // Brain Dump

Enable: stsadm -o setproperty -pn developer-dashboard -pv OnDemand (case sensitive)

Disable: stsadm -o setproperty -pn developer-dashboard -pv Off (case sensitive)

Oct26

When and what dispose

Written by // Rogério Cruzeiro Categories // Brain Dump

Avoiding memory leaks general rules:

  1. Use SPDisposeCheck utility to identify issues (very usefully on analysing 3rd party code)

  2. Dispose when:
    1. Enumeration AllWebs or Webs
    2. OpenWeb()
    3. Anytime the new command is used

  3. Don't dispose when:
    1. ParentWeb
    2. RootWeb
    3. SPContext
Oct26

AllowUnsafeUpdates set to false automatically

Written by // Rogério Cruzeiro Categories // Brain Dump

When you're persisting some property running with elevated priveligies, you have to set AllowUnsafeUpdates in order to bypass the security validation when you call the Update() method.

Bare i mind that any Exception (handled or otherwise) occur during the execution of your code, for instance: a try catch block, the AllowUnsafeUpdates property is setted back to false.

Jan06

Change SharePoint web.config to allow debug with call stack

Written by // Rogério Cruzeiro Categories // Brain Dump

Brain dump

1) Obtain the complete call stack instead of the default error page:

<SafeMode MaxControls="200" CallStack="false"/>
to
<SafeMode MaxControls="200" CallStack="true"/>

2) CustomeErrors mode value (in the system.web section) is set to Off:

<customErrors mode="On">
to
<customErrors mode="Off">