SharePoint - EventReceiver not working

Asked By Nik
17-Nov-09 03:23 PM
Using Visual Studio 2008, with VSeWSS3, I have created a new empty SharePoint
project (to GAC), then added new item > event receiver to Survey list type.

then added to the ItemAdding the following line of code:

SPUtility.SendEmail(SPContext.Current.Web, false, false,
result of the event ItemAdding firing on the survey");

Built and deployed the solution from the menu. I was expecting this to work,
but it is not firing, and in the logs I get:

Error loading and running event receiver
ISFeedbackSurvey.ISFeedbackSurveyEvtItemEventReceiver in ISFeedbackSurvey,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=97efffa28708eee2. Additional
information is below.  : Object reference not set to an instance of an object.

and

Event manager error: Could not load file or assembly 'SurveyNotification,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=4884dab2ea11612f' or one of
its dependencies. The system cannot find the file specified.

I have checked the GAC, the dll is there, the SafeControls entry is in the
web.config...

What am I missing?

Funny enough, the coding in ItemDeleting is firing just fine.
SPContext.Current.Web
(1)
SPUtility.SendEmail
(1)
SPUtility.SendEmail.
(1)
SPUtility
(1)
Visual Studio 2008
(1)
SharePoint
(1)
ISFeedbackSurvey
(1)
PublicKeyToken
(1)
  Nik replied to Nik
18-Nov-09 08:38 AM
Did some more investigation, if I put something as simple as

properties.ErrorMessage = "Hitting ItemAdding event override...";
properties.Cancel = true;

it works just fine. Those errors are in fact thrown by SPUtility.SendEmail...

how do I go about using SPUtility? What else needs to be deployed with my
feature?
  Nik replied to Nik
25-Nov-09 09:14 AM
Solved it by using System.Net.Mail instead. Will go back to SPUtility at a
later time to investigate.
Create New Account
help
SPControl.GetContextweb v. SPContext.Current.Web SharePoint Can someone tell me when one is better to use than the other? Thanks, Jay Sharepoint Windows Services Discussions SPContext (1) SPControl (1) SPContext.Current.Web is faster and is the preferred way now in 3.0. Regards, James keywords: SPControl GetContextweb, v., SPContext.Current.Web description: Can someone tell me when one is better to use than the other
the account name, how do i get the Display Name in C#? SharePoint Development Discussions SPContext.Current.Web.EnsureUser (1) SPContext.Current.Web (1) SPUser (1) SPWeb (1) List.Fields.GetFieldByInternalName (1) UserDisplayName (1) Hi liukx Can you do i get the "Display Name" of that user in C#? Hi Ok string userDisplayName = SPContext.Current.Web.EnsureUser["domain \ account"].Name; Explanation: From the current SPWeb you can get a SPUser
delete or edit member information. / / The user logged in as a group owner string loginName = SPContext.Current.Web.CurrentUser.LoginName; SPUser spuser = SPContext.Current.Web.Users[loginName]; SPGroupCollection spgroups = spuser.OwnedGroups; then how can I get his members? I'm struggling with this. Any help? SharePoint Portal Server Dev Discussions SPContext.Current.Web.CurrentUser.OwnedGroups (1) SPContext.Current.Web.CurrentUser.LoginName (1) SPContext.Current.Web.Users (1