⭐ If you would like to buy me a coffee, well thank you very much that is mega kind! : https://www.buymeacoffee.com/honeyvig Hire a web Developer and Designer to upgrade and boost your online presence with cutting edge Technologies
Showing posts with label exception. Show all posts
Showing posts with label exception. Show all posts

Sunday, July 22, 2012

How to fix "System.NullReferenceException: Object reference not set to an instance of an object. at Microsoft.SharePoint.SPField.GetTypeOrBaseTypeIfTypeIsInvalid" ?

What?

I suddenly started to see an exception "An unexpected error has occurred" in our SharePoint 2010 site when I tried to access the site's landing page.








After digging through the logs, the exception actually is:

"System.NullReferenceException: Object reference not set to an instance of an object. at Microsoft.SharePoint.SPField.GetTypeOrBaseTypeIfTypeIsInvalid"
Google has returned no results for this unique exception.

The same exception has shown up on every page in the root site. All the sub-sites were doing fine.

Why?

It is obvious that this exception is specific to one site's pages library. All the pages in other sub-sites are working fine.

How?

I went into the pages library settings and then found that there are number of invalid fields.

I have also seen a strange link that appeared next to each invalid field that says "Delete this invalid field".

I went ahead and deleted all the invalid fields and woohoo all the pages in the root site are back and working properly.

Tuesday, January 24, 2012

SharePoint (Beginner) : FileNotFoundException

For a beginner developer in SharePoint 2010 (with no experience with older version of SharePoint), you might be coding some simple “Hello World!” as your first SharePoint application. You might create a new Windows Console Application Project from Visual Studio and copy some sample codes from somewhere and try to run it. So you hit the magical F5 button and your project compiles successfully. However, when the program tries to run, Visual Studio throws you an FileNotFoundException, like the image below.
SharePoint 2010: FileNotFoundException
SharePoint 2010: FileNotFoundException
You then might be searching for codes error, is the SharePoint service running, & etc and found out that everything is running fine. So what’s the error?
The solution to this is to check your project platform target. By default, Visual Studio platform target is 32-bit (x86). Note that SharePoint 2010 ONLY runs on a 64-bit (x64) platform. So, you couldn’t run a 32-bit program on a 64-bit SharePoint Server. Now, to change your project platform to 64-bit, follow the steps below:
  1. Right-click on your Project in the Solution Explorer pane in Visual Studio and select Propertise
  2. Go to the Build tab and select x64 OR Any CPU
  3. Save changes, rebuild and run your program again.
SharePoint 2010: FileNotFoundException - 2