Tuesday 15 February 2011

WSP builder doesn't add all dll's to the wsp package

I have had tremendous problems trying to get WSP Builder build correctly and include all dll's in the WSP package (and SafeControl settings in the manifest.xml).

Now it finally seem that I have found a solution:

  1. Delete old assemblies from the GAC first
  2. Clean solution
  3. Rebuild solution
  4. Build WSP

This seems to work every time now. :-)

Thursday 20 January 2011

Update your WCF service proxy class

I have had a hard time updating  a WCF service (adding a new method to it) I used in a SharePoint/Silverlight project (the Silverlight application uses the WCF service to get data from SharePoint).

I found a solution. However it is rather strange and doesn't make much sense.
Anyway here it goes...

My setup:
  • WCF Service Library on the server.
  • SharePoint project with a .svc file pointing to the WCF Service Library.
  • The Silverlight application connects to service (the .svc files url).

Solution (short version):
  1. Implement the new method in the WCF Service Library (remember to do this in the interface/contract as well as the implementation of the interface).
  2. Deploy the SharePoint project (I think its strange that this step is nessesarry!)
  3. Start the WCF test client in Visual Studio
  4. Update the proxy class (I used the slsvcutil.exe tool).

WCF test client in Visual Studio - copy the mex address of the service


Use the slsvcutil.exe to generate the WCF service proxy class (for Silverlight)
There is also a svcutil.exe tool, which is used in normal .net applications

Create a new web application

From time to time you need to create a new web applikation in SharePoint.
I do this every time I start a new project in order to keep my projects thoroughly seperated.

Go to Central Administration
Under Application Management choose "Manage web applications"


Central Administration

Choose "new" in the ribbon. The box below will popup.
Change IIS website name (thereby you can tell your webapplications apart).
Create New Web Application (1/2)


Scroll down and change also
  • the "Application pool name"
  • choose a predefined security account
  • the database name
Click "OK" and waiiiiiiiiiiiit.. It takes a while for the new web application to be generated.

Create New Web Application (2/2)




Once it finishes you need to create a site collection and a root web for you web application.
Click the "Create Site Collection" link in the box that appears.
Web Application Created


Give your root web a title and a description.
And chose a template for it to be based on.

Create Site Collection and Root Web (1/2)



Scroll down and choose a primary site colection administrator user (i have chosen my own user).
Click "OK".
And wait... wait a little more.... and......
Create Site Collection and Root Web (2/2)



...... now the root web is created -  and you have created your web application with its root site collection and root web. :-)

Friday 7 January 2011

Assembly generation failed -- Referenced assembly 'MyProjectName' does not have a strong name

This error occurs when your project doesn't have a strong name, and you try to deploy it to the Global Assembly Cache (GAC).


Here's how it's done

Double click properties in the solution explorer for the project you want to give a strong name.
Choose the "Signing" tab.


Check the checkbox "Sign the assembly"
In the drop down box choose "<new>".

A box for creating the key file will now pop up.
Give your key a name - feel free to be creative here. I'm not, so I'll just call it "key"
Choose not to use password protection.
Click ok.



That was it! :-D

Tip
Visual Studio now created a file called "key.snk" and placed it in the root of your projects folder.
If you later have to sign other projects in the same solution (or other solutions for that matter), you can reuse this key-file you just created.
Instead of selecting "<new>" in the drop down box, select "<browse>" and browse your way to your existing key-file.


.