PASSED Exam 70-576 - PRO: Designing and Developing Microsoft SharePoint 2010 Applications

by Curia Damiano 14. May 2012 17:53

On Maj, 12th 2012 I've passed the following Microsoft exam: PRO: Designing and Developing Microsoft SharePoint 2010 Applications.

So, I got the following certification:

I've also updated the copy of the Microsoft official transcript.

Tags:

Certifications

SharePoint 2010: creating custom Service Applications

by Curia Damiano 10. May 2012 11:58

SharePoint 2010 drops the old concept of SSP (SharePoint Service Providers) and introduces the concept of Service Applications.

They are a way of exposing WCF services leveraging all the benefits of the SharePoint platform, for example load-balancing and high-availability using multiple front ends.

Here are some links:

Tags:

SharePoint

SharePoint: SPPersistedObject and hierarchical object store

by Curia Damiano 9. May 2012 12:13

SharePoint has the concept of SPPersistedObject and hierarchical object store.

The key concepts are:

  • inherit your configuration class from SPPersistedObject, give it a Guid and mark the needed fields (not properties) as Persisted;
  • hierarchical object store means that every object has a parent, so when the parent is deleted, all its children are deleted too;
  • every object has to have a unique name in the context of its parent;
  • it can be rather tricky to save collections of SPPersistedObject children, in this case the class SPAutoSerializingObject could be considered instead.

It's possible to find a very complete and detailed explanation in the article The skinny on SPPersistedObject
and the Hierarchical Object Store in SharePoint 2010
.

Tags: ,

SharePoint

SharePoint: property bags

by Curia Damiano 9. May 2012 10:45

Property bags are used in SharePoint to store configuration values in the form of hash tables (key-value) at different levels: SPFarm, SPWebApplication, SPWeb and SPList.

They are simply used in the form of <my object>.Properties.

There is no default user interface to manipulate them, but it's possible to use SharePoint Designer 2010 (via Site Options | Parameters), SharePoint Manager 2010 and the more specific SharePoint Property Bag Settings 2010, or modify them by PowerShell too.

For other articles about them:

Tags: ,

SharePoint

SharePoint 2010: the Developer Dashboard

by Curia Damiano 7. May 2012 14:31

SharePoint 2010 introduces the Developer Dashboard. It's a debugging tool used to understand what is happening during the page processing of SharePoint pages, for example for database access and web-part processing.

To activate the Developer Dashboard following the instructions shown in the article Using the Developer Dashboard, but briefly they are:

  • via stsadm:
    • stsadm -o setproperty -pn developer-dashboard -pv ondemand
  • via powershell:
    • (Get-SPFarm).PerformanceMonitor.DeveloperDashboardLevel = ”OnDemand”
  • via code:
    • SPWebService svc = ContentService.DeveloperDashboardSettings;
    • svc.DeveloperDashboardSettings.DisplayLevel = SPDeveloperDashboardLevel.OnDemand;
    • svc.DeveloperDashboardSettings.Update();

The three possible display statuses are: On, Off and OnDemand. When the status is OnDemand, it's possible to activate it from an icon in the upper right corner, but even On could be helpful, for example when the master page is corrupted.

The very intresting thing is that it's possible to extend the Developer Dashboard to show have even the custom code appear in the Developer Dashboard, and this can ben accomplished using the SPMonitor class, like in this example:

protected void Page_Load(object sender, EventArgs e)
{
    using (SPMonitoredScope scope = new SPMonitoredScope(this.GetType().Name)
    {
        do some code here...

        // eventually use inner scopes too
        using (SPMonitoredScope scope = new SPMonitoredScope("Inner Scope"))
        {
            and do some other code here...
        }

    }

}

Tags:

SharePoint

SQL Server: delete all rows of all tables to empty a database

by Curia Damiano 4. May 2012 17:02

In SQL Server it's possible to empty a database deleting all rows of all tables with the following simple script I've found in the blog post T-SQL Trick for Deleting All Data in Your Database:

-- disable referential integrity
EXEC sp_MSForEachTable 'ALTER TABLE ? NOCHECK CONSTRAINT ALL'
GO

EXEC sp_MSForEachTable ' IF OBJECTPROPERTY(object_id(''?''), ''TableHasForeignRef'') = 1 DELETE FROM ? else TRUNCATE TABLE ? '
GO

-- enable referential integrity again
EXEC sp_MSForEachTable 'ALTER TABLE ? CHECK CONSTRAINT ALL'
GO

But if the database contains identity columns and you want to reset them, you can visit the forum topic Truncate All Tables, answer of 06/13/2007 at 11:38:52, or download directly the code from here.

Tags: , ,

SQL Server

async and await keywords in C# 5

by Curia Damiano 4. May 2012 16:18

The new version of the C# language, the version 5, introduces native support to async programming.

Async programming has always been available since the first version of .NET and C#, but now the development is really simplified, because the compiler is taking care of all the burden to deal with it.

To understand this semplification, and explain the support that the compiler is giving to the developer, we can summarize in the following points:

  • when you need to execute a lenghty operation, use the await keyword;
  • mark methods with await keywords with the async keyword;
  • logically, what the compiler will do is:
    1. generate the first part of the method up to the async call;
    2. the async call will be done passing as callback another "hidden" method,
    3. that will be defined with the remaining of the body content, and will be able to consume the output of the async call;
  • pratically, this construction makes use of the Task<T> class, where T is the type of the output of the async call;
  • one final note: in a async method, multiple await are possible.

As reference, there are the following articles:

Tags: ,

C# and .NET

Using FxCop to enforce Code Analysis

by Curia Damiano 18. April 2012 18:20

After having described StyleCop in the blog post Using StyleCop to enforce source code standardization, here I describe FxCop.

FxCop is used to do code analysis of generated dlls.

It is automatically integrated in Visual Studio Ultimate edition. In the project properties, it will be possible to find a new "Code Analysis" tab. From this tab, it is possible to enable Code Analysis on build and eventually define a file for custom rules (like for StyleCop, it is a good idea to use a shared file used by all the projects in our solution).

You can find more details in the following articles:

Tags:

Visual Studio

PASSED Exam 70-573 - TS: Microsoft SharePoint 2010, Application Development

by Curia Damiano 8. March 2012 16:27

On March, 7th 2012 I've passed the following Microsoft exam: TS: Microsoft SharePoint 2010, Application
Development
.

So, I got the following certification:

I've also updated the copy of the Microsoft official transcript.

Tags:

Certifications

Lazy class in .NET 4

by Curia Damiano 6. March 2012 22:51

The concept of lazy is simple: sometimes creating a new instance of a class could be time-consuming, and you don't always need the full initialization of the class, but only a few members of it. So here we have the conpect of lazy construction: create or object, but complete the initialization only when all the fields are needed.

In previous versions of the .NET framework you had to implement this pattern by hand, but the .NET 4 introduces the Lazy class. The concept to build a lazy instances are simple:

  • define a private property containing the real value of the property you want to save (and don't initialize it), let's suppose you call it MyPropertyPrivate;
  • define your internal Lazy<T> property (let's say: call it MyPropertyLazy);
  • initialize the previous MyPropertyLazy as new Lazy<T>(() => { give a value to MyPropertyPrivate });
  • define a public property of type T, let's say called MyProperty, with a get accessor returning MyPropertyLazy.Value.

So in the end what happens is:

  1. a user access the public property MyProperty;
  2. MyProperty returns its value from MyPropertyLazy.Value;
  3. once "touched", MyProperty.Value evaluates the lambda expression,
  4. that finally executes and gives a value to MyPropertyPrivate.

Tags:

C# and .NET

Contacts and CV

Swiss mobile: +41 76 50 40 60 2
Italian mobile: +39 348/360.25.73
skype: curia.damiano
 

About the author

Damiano Curia is an independent SharePoint and .NET architect. He is specialized on Microsoft technologies and products, in particular .NET/C#, SharePoint, SQL Server and Windows Server. To highlight his technical knowhow, since 2005 he has got 20+ Microsoft certifications. Continue here...

View my profile on LinkedIn

A passion of him is sport. He's training very hard at tennis, (trying to) play in the style of his favorite tennis players, Pete Sampras and Roger Federer.

Finally, his second hobby is photography. You can find his best shots here, he hopes you'll enjoy them!

Month List