CKS: Development Tools Edition

This project extends the Visual Studio 2010 SharePoint project system with advanced templates and tools. Using these extensions you will be able to find relevant information from your SharePoint environments without leaving Visual Studio. You will have greater productivity while developing SharePoint components and you will have greater deployment capabilities on your local SharePoint installation.

For all developers there are several features you will like.

Get it here.

What you need to know about developing Timer jobs for SharePoint2010

So you want to develop a custom timer job for SharePoint 2010. You looked around in several books and searched some websites.

Ypou created a custom timer job, you deploy it and it seems to be working. However, everytime you adjust the code, no mather what, the old code is run.

You did keep all rules in mind, regarding to building custom timer jobs.

You declared a featuredeactivating, you retreacted the solution.

Still, the original code is run …

The magic behind this is, that although you deactivate and retract the code, the code is still present on the SharePoint server UNTIL you restart the timer job !

So best thing to accomplish a healthy environment for building custom timer jobs is to add 2 pre-build commands.

Open the configuration of your project and add the following 2 rules as a pre-build command

 

net stop sptimerv4

net start sptimerv4

 

Now debug your solution again and see that the new code is run !

New memory leak in Sharepoint

As every developer should know m the SPSite and SPWeb objects have problem resulting in memory leaks. On the background they call “unmanaged code”. so when using SPSite objects or SPWeb objects in your code, always use ways to dispose these object (think of try-catch and using).

there is even a tool to check if you really dispose all the necessary object (link)

But today i saw an article that told me there is another memory leak problem.

Look at this article of Todd Carter to see more of it, he call’s it : SharePoint’s Sasquatch Memory Leak

programming against Userprofileproperty Choicelist

Ok, so i was aked to program against the userprofileproperty choicelist.

The choicelist is the property of a userprofileproperty, when the userprofileproperty is a choicelist (sounds logic, not ?)

First i created a user profile property of the type choicelist.
I created a piece of code to connect to the userprofiles and retrieve the specific property. After retrieving the property, i retrieved the values of the choicelist.

Unfortunately, these values are “simple” strings without any form of ID. At least, not through the api.

I had the property object, next thing > add the value(s) AND don’t forget : programmed the commit.

I ran the code, and no errors, however, also no added values.

After some debugging and digging, i found out that adding value to the choicelist is not considered a change for profileproperties.

Funny ? NOT!

Then let’s create a workaround. Before committing , i programmed some code that forces the state of the property to : changed.
That way the values where added together with the change that in fact, wasn’t a real change.
Please notice the portion regarding the description :-)

                ServerContext sc = ServerContext.GetContext(curSite);
                UserProfileManager upm = new UserProfileManager(sc);

                Property p = upm.Properties.GetPropertyByName(Propertyname);
                p.ChoiceList.Add(Value);
                string descript = p.Description;
                p.Description = "";
                p.Description = descript;
                p.Commit()

after using this addition, the values where added succesfully to the property.

Hope this might help others.

Eric

Including Codebehind Files in your WSP

Source (and copied from)  : Paul Willen

I really love the codeplex project “WSPBuilder
WSPBuilder makes life for a Sharepoint Developer a lot easier.
The last two weeks we were working on a solution to copy documents from one document library in a site to an other document library. I’ll blog about that later.
But the thing that bugged us that our codebehind page (.aspx.cs) wasn’t included in the solution which resulted in an error while opening the specific solution page.
We didn’t realise that WSPBuilder, by default, excludes these filetypes.
To change these settings you need to go to the Installation Folder of WSPBuilder. This can be found at “C:Program FilesWSPToolsWSPBuilderExtensions
There you will see a file named “WSPBuilder.exe.config”
Copy this file over to the folder where you see the 12-hive in your solution (The obj and bin folders are also in this folder).
Now you need to change the WSPBuilder.exe.config file. Open this file in Visual Studio or notepad and change the TraceLevel key to value=”5″
By changing this key you’ll receive more information what happens when building the WSP.
Move the line
<add key=”Includefiletypes” value=””> which can be found in the commented part right under the TraceLevel key
add the value “cs” for C# or “vb” for Visual Basic to this key. If you want to add multiple values make sure you seperate them with a comma.
The first part of WSPBuilder.exe.config should look like this:

<?xml version=1.0 encoding=utf-8 ?>
<
configuration
>
<
appSettings
>
<
add key=BuildDDF value=false
/>
<
add key=TraceLevel value=5
/>
<
add key=Includefiletypes value=cs
/>
<!–
Optional settings
You can set the arguments in this file or use them directly in the console.
All arguments has a defualt value. See wspbuilder -help

Save this file and now build the WSP like you normally should.
Now the codebehind file should be included into your WSP file.

To check if the codebehind file is truely included into the WSP file rename “yoursolution.wsp” to “yoursolution.cab” and doubleclick “yoursolution.cab”.

There you can see all the files included into the project.