Getting DLLs OUT of your non-managed code SharePoint solutions in Visual Studio 2010

Ever notice, that no matter what you package in Visual Studio 2010, even if it is a no-code solution? See the output of a build from a CustomAction below.

—— Build started: Project: Test.SharePoint.Features.MyCustomAction, Configuration: Debug Any CPU ——
  Test.SharePoint.Features.MyCustomAction -> c:\DevProjects\Test.SharePoint.Features.MyCustomAction\Test.SharePoint.Features.MyCustomAction\bin\Debug\Test.SharePoint.Features.MyCustomAction.dll
  Successfully created package at: c:\DevProjects\Test.SharePoint.Features.MyCustomAction\Test.SharePoint.Features.MyCustomAction\bin\Debug\Test.SharePoint.Features.MyCustomAction.wsp
========== Build: 1 succeeded or up-to-date, 0 failed, 0 skipped ==========

There is a simple solution to this. Click on your project within the Solution Explorer in Visual Studio. And then below, or, wherever you have your Properties window, just change Include Assembly in Package to false. Then go ahead and re-package your solution. That was easy, eh?

image

Advertisement

Create a Custom Action to Satisfy Your “All People” Needs.

image

Thanks for the intro Carl! Much obliged! Well, in your SharePoint world, your “Pale Blue Dot” view of all of the people in your site collection is the “All People” view, you know, the User Information List.

Almost two months ago, I wrote an article on how the “All People” link in SharePoint 2010 is, well, it’s gone MIA. It is easy to get to via  link. And, if you’ve got one site collection to manage, well, its as simple as adding a link somewhere, like in a link list within a management site somewhere, or, up in the handy dandy bookmarking feature, in those fancy things all the kids are using these days, “web browsers”… whatever that means…? Anyways. So, you need to get there, but, wouldn’t it be nice and simple to add in a link to say, I don’t know, the Site Settings page? Wow! That’d be cool! Then I can access it with all of the other Users and Permissions links! Right in one place?! WOW!

image

So, the question becomes, how can we get it there? (HINT: I mentioned it in the title of this article!)

Ok, so I gave it away, shame on me, I spoiled the ending. Boo hoo. Yes, Custom Actions! That’s how we’ll get it there!

So, what to do? Well, not too much actually. The creation of Custom Actions in SharePoint 2010 and with Visual Studio 2010 has become, well, easy. Extremely easy in fact due to the fine folks who created the CKS:DEV project over at Codeplex. Why? Well, because it contains item types with fancy pants wizards to allow you to click a few buttons, and create a custom action project with ease. You really do not even need to be a developer to do this, it’s quite easy, and hey, I provide screenshots and code. Go ahead, do it!

So, let’s get started, shall we? Oh, you need a glass of water first. No problem. I’ll be here waiting for you.

… 15 minutes to get a glass of water? seriously? Did you pump it from the well?

Ok, so, make sure you have VS 2010 installed, as well as CKS:DEV. NO, I am not waiting this time. You lollygagged around with getting a glass of water last time… You had your chance!

 

First, create a new project in Visual Studio 2010

image

Then, create an Empty SharePoint Project
image

Oh, guess what you’re about to witness? Yes, you in the back in the Charlie Brown polo shirt! You’ve got it. The creation of my next codeplex project for Grace-Hunt (yes, I know, it’s been a while!)

And since we do not need to elevate privileges, or any of that fancy stuff required for a server-side deployment, we’re going to create this as a Sandboxed Solution…

image

Next, once our project is loaded in the Visual Studio IDE, let’s add a new item to the project.

image

Right click on your project, go down to Add, then select  New Item.

On the next screen you are presented with, make sure you have SharePoint and 2010 selected under Installed Templates.

image

Select Custom Action, and give it a name (such as UserInfoList). Then click Add.

Now, again, thanks to the fine folks who created CKS:DEV, we have wizards!

image

On the first screen on the wizard, we have 6 settings we are going to make use of, detail from here for each of these attributes: http://msdn.microsoft.com/en-us/library/ms460194.aspx

ID

Attribute

Description

1

Id

Optional Text. Specifies a unique identifier for the custom action. The ID may be a GUID, or it may be a unique term, for example, "HtmlViewer".

2

Title

Required Text. Specifies the end-user description for this action.

3

Description

Optional Text. Specifies a longer description for the action that is exposed as a tooltip or sub-description for the action.

4

GroupId

Optional Text. Identifies an action group that contains the action, for example, "SiteManagement". If it is contained within a custom action group, the value of the GroupId attribute must equal the group ID of the CustomActionGroup element.

For a list of the default custom action group IDs that are used in Microsoft SharePoint Foundation, see Default Custom Action Locations and IDs.

5

Location

Optional Text. Specifies the location of this custom action, for example, "Microsoft.SharePoint.SiteSettings".

If the CustomAction element contains a CommandUIExtension child element, the Location must start with "CommandUI.Ribbon". For a list of default locations that are used with the Server ribbon, see Default Server Ribbon Customization Locations.

If the custom action is a menu item or toolbar button, the possible options include EditControlBlock, NewFormToolbar, DisplayFormToolbar, and EditFormToolbar.

If it is contained within a custom action group, the value of the Location attribute must equal the location of the CustomActionGroup element.

For a list of the default custom action locations that are used in SharePoint Foundation, see Default Custom Action Locations and IDs.

6

Sequence

Optional Integer. Specifies the ordering priority for actions.

 

image

On the next page, we do not actually need to set this option, however, I wanted to, to showcase this functionality. This utilizes the SPBasePermissions class to show whether this can be viewed to the user, based on the permissions they have for this object, in this case, the site collection.

image

On the last screen, and this is the important part, we need to specify the URL we want to have our CustomAction link to, this is the URLAction element. The ~sitecollection is a Token. More information on what tokens can be used in a URLAction can be found on slide #30 of my Creating Custom Actions in SharePoint presentation.

image

Now that we’ve finished defining the custom action, we just have a couple of more things to do. Since we do not our feature to be called “Feature1”, right-click on Feature1 in the Solution Explorer, and choose Rename.

image

Type it in, hit enter, all good.

Next we want to remove Feature 1 from after the title of our feature. Double click on the UserInfoList feature we just renamed, and we get a designer view of our feature (new in VS 2010).

image

In the Title field, remove Feature 1 after our feature, and add a description. Also, change the scope from Web to Site, which means we will deploy our solution to the site collection. Which also means, this link will appear for all Users and Permissions sections throughout all of the site settings pages within our site collection.

image

Now for the money! Right click on the project and select Deploy.

image

Look at the output window to see if we had success or failure…

image

And now look at your site settings page – there is our new link!

And that’s it! I will have this project published to Codeplex within the next few days, so, please keep an eye out.

Errors when writing applications for SharePoint 2010

So, you’ve opened Visual Studio 2010, say, for instance, a console application to start pecking away at writing some simple application via the API. Nothing major, maybe in fact you are just re-using code from 2007 you’ve written, but, you just want to play with the API, after you’ve finished drooling over the new UI. Great! So, you’ve written your code, you press F5 to debug run your program, and [insert failure sound from The Price is Right here] – you get an error. The error makes no sense? FileNotFoundException? You’re using the IW image from Microsoft. You know for a fact the site exists – its open in your browser on your other monitor?! And more importantly, you know this code words. You’ve muttered it out from your fingertips hundreds of times (or, have it pasted in through a code snippet – why re-invent the SPRequest object reference wheel?)

image

No need to worry – after you’ve no doubt put your hand through your nice looking but poorly made substitute-for-a-punching-bag IKEA Imon desk (its ok, they’re made that way so you don’t injure yourself! A few layers of wood putty will fix it up even better than before. Now your desk looks more “arty”. You’re hip now!), it is a simple fix. A console application by default in VS 2010 sets the platform target as x86. Not x64, not Any CPU, but x86. Which will NOT work with the 64-bit only SharePoint 2010. Set this back to Any CPU, or x64 if needed, and hit F5 again.

image

Now your cookin’ with gas! Simple, eh? A quick helpful hint – the Community Kit for SharePoint: Development Tools (CKS:DEV) project contains a project type called “SharePoint Console Application”, which sets all of this up for you, right off the bat.

%d bloggers like this: