Debugging Custom Event Receivers – Strange Error on custom Event Receiver SharePoint 2010. .c__DisplayClass2.b__0()Object reference not set to an instance of an object.
Debugging Custom Event Receivers.
Here’s a weird error that took some time to figure out. Generic “Object reference not set to an instance of an object.” Error on a custom SharePoint 2010 event receiver. If I went through the UI to change a field on a list, the event receiver fires fine. But, if a workflow changed the field it threw the error below. I finally found if I attached the OWSTimer process to Visual Studio, it would debug, but still not show the exact problem. The solution is to find the Log On account for OWSTimer in the Services console (services.msc) and then to grant that account permissions on the list that the event receiver is running on.
Edit -checking the permissions of the OWSTimer account is just one possible solution. What I found out was that the list was hanging on to old event receivers as well. I had to use SPManager to see how many event receivers were still active on the list.
Also, I thought the OWSTimer process may be holding onto cached dll’s, so you will need to restart the OWSTimer service in services.msc, and IIS Reset to reset the app pools in order to see new dll changes.
After starting over, checking the number of event receivers, attaching to the W3 process for UI changes, and the OWSTimer for timer based changes, I was able to get a stable debugging environment. I also reset the OWSTimer service and IIS between each debugging session.
| Message:
Object reference not set to an instance of an object. Stack Trace: at BusinessSolutions.SharePoint.EventReceivers.PricingRequestItemUpdate.PricingRequestReceiver. PricingRequestReceiver.<>c__DisplayClass2.<UpdateDashboardItem>b__0() PricingRequestReceiver.UpdateDashboardItem(SPItemEventProperties properties, Boolean bNewItem) PricingRequestReceiver.ItemUpdating(SPItemEventProperties properties) |
Missing All People Links in SharePoint 2010
We use this to delete users from the site collection. It was gone in 2010, but really just “hidden.”
Source:
http://sharepointyankee.com/2010/11/11/all-people-view-in-sharepoint-2010/
Hide Left Navigation in SharePoint 2010
Here’s a quick reusable way to hide the left navigation.
Create a text file called “HideLeftNav.txt” in a document library.
Add the following css code:
<style type=”text/css”>
/*–Hide Quick Launch –*/
#s4-leftpanel{
display:none
}
.s4-ca{
margin-left:0px
}
</style>
Edit the page you want to hide the nav on, add a content editor webpart. Then, simply reference the url to the HideLeftNav.txt file and you are done.
Creating a WCF service on a SharePoint 2010 server in Visual Studio 2010 and “Type can not be found” error
If you get the “Type cannot be found” error after installing your WCF service, go to the section about unloading your project below.
Here are the main steps to creating a WCF service and installing it on a SharePoint 2010 server:
- Open Visual Studio 2010
- Create an Empty SharePoint 2010 project to get the packaging files
- Change your namespace in the Project Properties.
- Add a new Item, WCF Service with a new file name
- Add the following lines above the class declaration that implements the “IService” file:
[BasicHttpBindingServiceMetadataExchangeEndpointAttribute]
[AspNetCompatibilityRequirementsAttribute(RequirementsMode = AspNetCompatibilityRequirementsMode.Required)]
public
class
PricingRequestService : IPricingRequestService
{
-
Add the following references to your project:
- C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\ISAPI\Microsoft.SharePoint.dll
- C:\Windows\assembly\GAC_MSIL\Microsoft.SharePoint.Client.ServerRuntime\14.0.0.0__71e9bce111e9429c\Microsoft.SharePoint.Client.ServerRuntime.dll
- Add a mapped folder to the “_Layouts” folder
- Inside the _Layouts folder create a text file with a .svc extension such as PricingRequestService.svc
Add the following sample: <%@ServiceHost
Language=”C#” Debug=”true”
Service=”PricingRequest.PricingRequestService, $SharePoint.Project.AssemblyFullName$”
Factory=”Microsoft.SharePoint.Client.Services.MultipleBaseAddressBasicHttpBindingServiceHostFactory, Microsoft.SharePoint.Client.ServerRuntime, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c”
%>
- Change the namespace and service name to your own. Leave the public key token alone as it refers to the ServerRuntime dll.
http://msdn.microsoft.com/en-us/library/ff521581(v=office.14).aspx
Gotcha from MSDN:
Make sure to Unload your project and add this to the project file:
<TokenReplacementFileExtensions>svc</TokenReplacementFileExtensions>
Just above </PropertyGroup>
Because Visual Studio 2010 by default does not process the type of tokens used in the previous .svc file, you must add an additional instruction in the project file. Save all changes in your project, right-click the RevertService project, and then click Unload Project. Right-click the RevertService node again, click Edit RevertService.csproj or Edit RevertService.vbproj, and add a <TokenReplacementFileExtensions> tag as follows to the first property group in the .csproj or .vbproj file to enable processing of tokens in .svc file types.
- Package your project to get your .wsp package
-
Run the following Powershell commands to add/install the solution
- Add-SPSolution “i:\YourPath\PricingRequestCP.wsp”
- Install-SPSolution -Identity PricingRequestCP.wsp –GACDeployment
- Verify your dll is in the GAC and your .svc file is in the _Layouts folder in a subfolder.
-
To undeploy your solution, run these Powershell commands:
- Uninstall-SPSolution -Identity PricingRequestCP.wsp -Confirm:$false
- Remove-SPSolution -Identity PricingRequestCP.wsp -Confirm:$false
How to turn off “Cannot be blank” yellow boxes on SharePoint 2010 Infopath custom list forms
Find and make a backup copy of the Core.JS file(14\template\layouts\inc)
Edit the Core.JS file(14\template\layouts\inc)
Find the function called ErrorVisualization_ShowShortMessage
Add “return;” as the first command in the function.
ErrorVisualization_ShowShortMessage(b,a,g){return;ULSrLq:;var h=g[2],d=”",e=null;if(!
Reset IIS
http://sharepointfeaturesandfailures.blogspot.com/2008/03/turn-off-hover-over-screen-tips-on.html
Metro Tiles in SharePoint 2010 and SharePoint 2013
Here’s a kind of fun web part I found on Codeplex. You can jump on the tiles bandwagon in SharePoint 2010. It’s packaged nicely in 2 wsp files and creates a list to hold the data. Built in images are very nice.
It’s called the Metro Grid webpart and they have done a nice job on the packaging and icons.
http://spmetrogrid.codeplex.com/

Notes from the Edge: SharePoint 2012 Conference, Las Vegas
Having just got home from Las Vegas, I’d like to relate some of the things I saw at the MS SharePoint 2012 conference. With over 10,000 attendees filling up the Mandalay Bay beach, I am amazed year after year of the growth. When I started working with SharePoint in 2001, who would have thought it turned into this.

Bon Jovi rocking out at Mandalay Bay for the SharePoint conference.
Cloud everything
You probably couldn’t go one sentence in any session without hearing cloud. What does this mean? You better get a strategy in place because it is coming fast. MS is “all in” on cloud according to Steve Ballmer. As a developer, or infrastructure professional things will change quickly. For developers it’s going to be about RESTful web services, JSON, javascript, jquery, cloud app model, Azure services, OAuth, OData and Azure services. For infrastructure professionals, better start planning on either a strategy that fits with the cloud, or look at datacenters as a career path. Am I being too harsh or did I drink too much Kool-Aid? Perhaps, on premise installations take many years to migrate as turning a large ship takes time. But, in my mind the writing is on the wall and IT needs to plan for it.
There was just so much content to handle in the limited time with multiple overlapping sessions. I have a to-do list a mile high on getting the slide decks from all the sessions I couldn’t make. I was turned away at the door multiple times because the rooms were full. It baffles me how some rooms have 500 empty seats and others are overbooked by 500. It seems the developer ones are always oversubscribed and they should have a better logistical forecast based on surveys. While we are on a rant, the hands on labs were down for the first 2 and a half days due to network issues. But I digress, the conference was a lot of fun and I met some very cool people.
Some questions about the future:
-Where is InfoPath? There was only 1 forms session and I couldn’t get into it as the room was full. I asked the developers at the MS Dev booth and came away with the feeling of ‘read between the lines.’ There is no InfoPath button on SharePoint 2013. There was a lot of talk on HTML 5 and javascript. Read between the lines. I would recommend serious questions about implementing any major InfoPath strategy at this time. Nintex forms looked pretty nice on their demo at the Exhibitors booth: push a button and target iPad, Win 8, Blackberry. Although I have talked to a client who says they have ran into some limitations on the Nintex forms.
Update on InfoPath: Having just reviewed the SharePoint 2013 Forms session, they said that InfoPath is still “fully supported” in SharePoint 2013. InfoPath will also be more integrated into the Visual Studio 2012 IDE. However, out of the 60 minutes on forms, they spent about 5 minutes on InfoPath. it looks like MS Access 2013 is becoming the development tool of choice to help design HTML5 forms for cloud apps. According to the presenters from MS, Access apps in 2013 are basically SharePoint apps, and the forms that are created using MS Access are available in SharePoint, iPad, etc. as they rendering is in HTML5 and javascript. Also, Visual Studio 2012 and a new technology called Typescript seems to be another new way for developing forms with a more c# feel using intellisense, etc., but creating javascript as the end result.
-Forget Sandboxed Solutions
No more sandbox, all cloud App model. Kind of funny as sandboxed solutions were just released not too long ago.
-No more SharePoint as a platform
What does this mean? SharePoint has always been a platform. Well, no more server side code. It just doesn’t fit into the Cloud model. SharePoint is moving towards being an App. All custom logic will be in cloud apps in the cloud app model. No more server side code like custom visual studio workflows, you need to realize they won’t get migrated to SharePoint online today. If you need server side code, get to know Azure. Be careful about creating a lot of custom server-side SharePoint code unless you know for sure you will stay on-premise for a long time. Are you willing to bet your job on it? As a consultant, I realize on-premise installations will be around for many, many years. One case in point is that I spoke with a person at the conference who said many of her clients are still on not just SharePoint 2007, but still SharePoint 2003.
Get to know Azure
Azure has been around for a while, but it’s growing more important as the cloud model increases. I would suspect MS’s cloud strategy is driven from a profitability model based on the recurring subscriptions. That said, it doesn’t really matter why, it’s happening very fast. Azure can host web sites, sql servers, workflows, etc. This will be very important as many on-premise SharePoint installations begin migration into the cloud and need a place to put their server side code.
Cool and important things that I made notes to get a deeper understanding on. I’ll try to fill out these topics more as time permits.
Power Pivot in Excel 2013
Power View in Excel and SharePoint 2013
_API – new API in SharePoint 2013
OData – Open Data protocol
OAuth – Open Authorization protocol for all authentication
Workflow alerts getting sent into a Messaging service into Windows 8 tiles and toast
Twilio SMS to add messaging to workflows
Dev.office.com
Azure websites, workflow engine, SQL databases.
Office 365 service description
Limitations of Office 365, SharePoint online
Jquery, Knockout, DataJS
If you were at the conference, feel free to add your comments or opinions. I’d like to hear what you have to say.