1

How to Debug a Visual Studio Extension

Here are a few tips for debugging Visual Studio Extensions.

Visual Studio 2008/2010

If you need to debug your Visual Studio extension, you may find that Visual Studio itself locks it. This is a real drag – to resolve this issue, add the following as a pre-build step:

if exist "$(TargetPath).locked" del "$(TargetPath).locked"
if not exist "$(TargetPath).locked" if exist "$(TargetPath)" 
move "$(TargetPath)" "$(TargetPath).locked"

This will ensure the locked file is moved out of the way first – very useful!

Visual Studio 2010

Every time I do a clean checkout of one of my projects, it seems to lose the ability to be run in the Experimental mode of visual studio. Here’s a quick tip – if you lose the ability to debug your visual studio extension, make sure you have the ‘Debug’ tab of your project set up as below:

Specifically with the external program set as visual studio and the command line arguments as /rootsuffix exp. This will run your extension in the Experimental Instance of Visual Studio.

0

Getting Source Code Metrics from SVN

Lets say that we need to find out how many lines of code exist in a branch, or how many lines are checked in by a specific user. Let’s ignore the usefulness of these metrics, just assume that they’re needed (realistically, lines of code isn’t a very useful metric, but perhaps you want to have a quick idea of how much has gone into a release). How do we do this?

TortoiseSVN statistics aren’t really enough. Here’s some alternatives:

I’d recommend taking a look at FishEye if you’re going to go to the effort of getting these statistics. Any comments on alternatives would be welcome!

0

IDataServiceMetadataProvider Entities Missing in $metadata

If you are following through the example on creating custom data service providers as on this blog:

http://blogs.msdn.com/b/alexj/archive/2010/01/08/creating-a-data-service-provider-part-3-metadata.aspx

And you notice that your entities are not showing up in the $metadata file, double check that you have added this:

public class service : MyNewDataService
    {
        // This method is called only once to initialize service-wide policies.
        public static void InitializeService(DataServiceConfiguration config)
        {
            config.SetEntitySetAccessRule("*", EntitySetRights.AllRead);
            config.DataServiceBehavior.MaxProtocolVersion = DataServiceProtocolVersion.V2;
        }
    }
Just remember to set the entity set access rules for all entities - other they won't show up!
0

Composite Data Service Framework

Today I start a new project – the Composite Data Service Framework. The Composite Data Service Framework is a project that aims to obviate some of the limitations of WCF Data Services, specifically:

  • Allowing multiple data services to be aggregated in a single data service.
  • Providing more support for Service Operations (such as auto-generation of proxies client-side).
  • Aggregating different service types (entity framework, CLR types etc)
  • Complementing OData services with traditional WCF services with a single definition of proxies client-side.

The project is in its early stages and is hosted at:

http://cdsf.codeplex.com/

More updates will follow.

0

Data Service Exception “Unauthorised” when connecting to Sharepoint OData

If you are struggling to fetch data from a Sharepoint OData service and getting an error as below:

 [DataServiceClientException: Unauthorized]
   System.Data.Services.Client.QueryResult.Execute() +436914
   System.Data.Services.Client.DataServiceRequest.Execute(DataServiceContext context, QueryComponents queryComponents) +133 

Then ensure you are setting the Credentials property of your Data Service Context, as below:

//  Create the data context.
SharepointDataContext dc = new SharepointDataContext(new Uri("http://dksp/_vti_bin/listdata.svc"));
        
//  Provide default credentials, without this authorisation will fail!
dc.Credentials = System.Net.CredentialCache.DefaultCredentials;

//  Etc...
var accounts = from a in dc.Accounts select a;

Just another issue you may come across when using Sharepoint OData services!

0

The “Name attribute is invalid” when adding a Service Reference to a Sharepoint OData Service

Well this little issue took me a while to investigate, but the skinny is this:

If you are going to add a service reference to a Sharepoint OData service (e.g. http://sharepoint/_vti_bin/listdata.svc) then make sure your Sharepoint site name does NOT begin with a number – otherwise Visual Studio will fail to add the reference.

Quick and easy, but this took quite a while for me to find, hope it helps anyone in the same situation!

0

Apex 1.2 Released

Apex 1.2 has been released, with some new features:

  • The ‘Compatibility’ namespace, which contains classes to address compatibility issues between WPF, Silverlight and WP7.
  • The ‘Asynchronous Command’ object, which provides a powerful way to use Asynchronous Commands in MVVM.
The release is at: http://apex.codeplex.com/