14 noviembre 2008

Tunning a development virtual machine for Sharepoint

One of the rules I have set up in my team when developing Sharepoint
projects is to use Virtual Machines. We may use VMWare or Virtual PC,
depending on the machine pattern we take at the beginning of the project.
Though our hardware is usually a high-profiled Dell laptop, it sometimes
becomes a quite slow environment to work.

Four tips to run Sharepoint virtual machines faster I have found so far are:
- Running the machine in an external disk.
- Assigning at least 2 Gb of RAM Memory.
- Stoping search service (when not needed).
- Defragmenting the virtual machine. If you use VMWare you can do it from
the disk tools, in machine settings, which is much more faster.

Hope this helps to anyone working in a similar way...

07 noviembre 2008

Troubleshooting Excel Web Service and Visual Studio 2008

After some hours developing with Excel Web Service and Visual Studio 2008 I have discovered that an only single consideration can save you a lot of time.

When you add the Excel Web Service in Visual Studio 2008 operations will have a different signature compared to MSDN samples, and if you try for example to set a range you may experience some problems with an object of type ArrayOfAnyType.

However all these issues and differences can be avoided with one simple configuration change:

1. Add the Excel Web Service.

2. Click the Visual Studio button to Show All Files, in Solution Explorer.

3. The Web Service will appear as a folder. You can click on it and some files appear.

4. You will see a file called Reference.svcmap. Open it.

5. In element: ReferenceGroup

a. In ClientOptions

i. In Serializer: Change Auto to XmlSerializer:

And everything will work fine!

In the link below there is a comment that explains what we have done. By default Visual Studio uses a DataContractSerializer, but an XmlSerializer should be used instead.


The requested range is not a valid sheet location

I tried the example in MSDN for setting a range of an Excel by using the Excel Web Service. A simplified way of this example is calling the web service in this way:

object[] o1 = new object[1];

object[] o2 = new object[1];

o1[0] = 1;

o2[1] = o1;

excel.SetRangeA1(sessionId, "Hoja1", "c2:c2", o1);

Notice that the last parameter must be an array with an array in each position (a jagged array).

If you add a reference in Visual Studio 2008 this does not work as the last parameter must be of type of ArrayOfAnyType. If you try the following:

ArrayOfAnyType aoat = new ArrayOfAnyType();

aoat.Add(1); // we add an object

excel.SetRangeA1(sessionId, "Hoja1", "c2:c2", aoat);object[] o1 = new object[1];

This will generate an exception: The requested range is not a valid sheet location. The solution is it needs the second dimension:

ArrayOfAnyType aoat = new ArrayOfAnyType();

ArrayOfAnyType aoat2 = new ArrayOfAnyType();



excel.SetRangeA1(sessionId, "Hoja1", "c2:c2", aoat);

This code will work fine.