4

I recieve this exception when I try to run the sample application for WP7 that comes with the Facebook C# SDK:

File or assembly name 'Microsoft.Contracts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=736440C9B414EA16', or one of its dependencies, was not found.

It occurs at this part in code:

// Constructor
    public MainPage()
    {
        InitializeComponent();
        _fbClient = new FacebookClient();
        FacebookLoginBrowser.Loaded += new RoutedEventHandler(FacebookLoginBrowser_Loaded);
    }

Not sure what this means, as this is the first time I recieve this error. And I can't find "Microsoft.Contracts". I tried rebuilding and everything works nicely, but when I run I recieve the exception.

Can someone explain whats going on and maybe how to fix it?

EDIT: It occurs specifcly when a new instance of the FacebookClient is created in the MainPage Constructor.

Edward
  • 7,346
  • 8
  • 62
  • 123

1 Answers1

4

It appears that Microsoft Code Contracts are not available for Windows Phone 7. The developer of the library you are using included a reference to this assembly and it is not available for the Windows Phone platform.

To fix this you would need to obtain a version of the .NET assembly (DLL) that does not have a reference to Microsoft.Contracts.dll.

Brian Lyttle
  • 14,558
  • 15
  • 68
  • 104
  • 2
    Exactly. I just got the source files for the SDK (Microsoft.Contracts dll was included) and just manually added it to the sample project (which didn't include it) and it worked perfectly. Thanks for the answer. – Edward Mar 22 '11 at 03:06