Articles tagged with: development

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.
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

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.