Musings on SharePoint, Adobe CQ, ECM, and more…

Developing FB App Using Facebook C# SDK – Errors and Gotcha’s

To utilize some of my vacation time in a more productive manner I started building a Facebook App (details and source code will be posted soon) using Facebook C# SDK. Here is a list of some error and gotcha’s I have encounter during the initial development and setup. I will try to update this page with additional information as I make some progress.

The type initializer for ‘Facebook.FacebookApplication’ threw an exception

I encountered this error when I moved my application from local machine to an external hosting. The error message above is a very generic one and doesn’t provide much information. However things start making sense once you check the “Inner Exception”. Here is an inner exception message:

Request for ConfigurationPermission failed while attempting to access configuration section ‘system.web/machineKey’. To allow all callers to access the data for this section, set section attribute ‘requirePermission’ equal ‘false’ in the configuration file where this section is declared.

This issue is related to the trust level. During development on my local machine, application was running under Full trust level. However most of the shared hosting providers set the trust level to “Medium” by default. Setting the trust level to Full in web.config file solved the issue for me.

<trust level=”Full” />


If you don’t want to run your application in full trust than you should explicitly set the trust level to “Medium” during development to avoid any surprises later.

HTTP Error 405.0 – Method not allowed

Here is a full error message:
HTTP Error 405.0 – Method Not Allowed The page you are looking for cannot be displayed because an invalid method (HTTP verb) is being used.

This error occured because I was doing a POST to a static HTML page which does not support POST method. To verify my Facebook configuration I created a test HTML page and hence this error.
This is a known issue and solution is available on Microsoft support site.

Praveen Modi

Praveen works at Razorfish which is one of the largest digital advertising agency in the world. His mantra for life is "You are never too old to set another goal or to dream a new dream". He lives in sunny Austin, TX with his beautiful wife Nidhi and son Aariv.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.