Seany84
Seany84

Reputation: 5596

The type Facebook.FacebookClient is defined in an assembly that is not referenced

I have downloaded the latest FaceBook C# SDK and have added the FaceBook.Web.dll (net40) to my project which is also .net v4.0.

When I copied the following code from the example page:

var client2 = new FacebookClient();
var me2 = (IDictionary<string, object>)client2.Get("me");
string firstName = (string)me2["first_name"];
string lastName = (string)me2["last_name"];
string email = (string)me2["email"];

I get this error:

The type or namespace name 'FacebookClient' does not exist in the namespace 'Facebook.Web' (are you missing an assembly reference?)

So I changed:

var client2 = new Facebook.Web.FacebookClient();

to

var client2 = new Facebook.Web.FacebookWebClient();

Now I have two errors:

The type 'Facebook.FacebookClient' is defined in an assembly that is not referenced. You must add a reference to assembly 'Facebook, Version=5.4.1.0, Culture=neutral, PublicKeyToken=58cb4f2111d1e6de'.

and

'Facebook.Web.FacebookWebClient' does not contain a definition for 'Get' and no extension method 'Get' accepting a first argument of type 'Facebook.Web.FacebookWebClient' could be found (are you missing a using directive or an assembly reference?)

Before I added the FaceBook C# SDK, I upgraded my project from v3.5 to v4.0 of .NET. I was able to successfully build and run my application.

I then added the Facebook dll and could not get it working. (I have tried both the v3.5 and v4.0 version of the Facebook dll).

Thanks in advance.

Upvotes: 1

Views: 5318

Answers (4)

Ifeanyi Chukwu
Ifeanyi Chukwu

Reputation: 3337

I encountered same problem.There seems to be an assembly conflict between facebook c# sdk and facebook.helper libraries.I Uninstalled facebook.helper {version} and it worked.

Upvotes: 0

Moizes
Moizes

Reputation: 1

Try to change Specific Version of Facebook.dll to "false".

Upvotes: 0

devio
devio

Reputation: 37215

The messages try to tell you that you also need to add a reference to the Facebook.dll in the project that already references Facebook.Web.dll

Upvotes: 1

Dumbo
Dumbo

Reputation: 14112

have you added a using facebook statement in your code?

also unless it is within a method, I dont beleive you are allowed to use var keyword as a global field init

Upvotes: 0

Related Questions