Wrox Programmer Forums
BOOK: Professional SharePoint 2007 Development ISBN: 978-0-470-11756-9
This is the forum to discuss the Wrox book Professional SharePoint 2007 Development by John Holliday, John Alexander, Jeff Julian, Eli Robillard, Brendon Schwartz, Matt Ranlett, J. Dan Attis, Adam Buenz, Tom Rizzo; ISBN: 9780470117569
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional SharePoint 2007 Development ISBN: 978-0-470-11756-9 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old January 7th, 2010, 04:10 PM
Authorized User
Join Date: Dec 2004
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Question Chapter 6 - assembly name

I followed the steps to create the ApplicationEventReceiver and the console application to deploy the solution, but the console app is throwing an exception. I am guessing it's the way I'm referring to my assembly.

Unhandled Exception: System.InvalidOperationException: Could not load file or assembly 'ApplicationEventReceiver, Version=, Culture=neutral' or one of its dependencies. The system cannot find the file specified.
   at Microsoft.SharePoint.SPEventReceiverDefinition.ValidAssembly()
   at Microsoft.SharePoint.SPEventReceiverDefinition.ValidReceiverFields()
   at Microsoft.SharePoint.SPEventReceiverDefinition.UpdateInternal(Boolean isMi
   at Microsoft.SharePoint.SPEventReceiverDefinition.Update()
   at Microsoft.SharePoint.SPEventReceiverDefinitionCollection.Add(SPEventReceiv
erType receiverType, String assembly, String className)
   at ConsoleApplication3.Program.Main(String[] args) in C:\Documents and Settings\robbert.vanandel\My Documents\Visual Studio 2008\Projects\ConsoleApplication3\Program.cs:line 20
How do I refer the console application to my ApplicationEventReceiver. I have the applicationeventreceiver inside the ApplicationEventReceiver namespace:

namespace ApplicationEventReceiver
    class ApplicationEventReceiver : SPItemEventReceiver
and my console application looks like this:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.SharePoint;

namespace ConsoleApplication3
    class Program
        static void Main(string[] args)
            SPSite site = new SPSite("http://oriontest/hiringmanagement/");
            SPWeb web = site.OpenWeb();
            SPList list = web.Lists["Applicant"];

            string assemblyName = "ApplicationEventReceiver, Version=, Culture=neutral, PublicKeyToken=6ac52d8504a20881";
            string className = "ApplicationEventReceiver.ApplicationEventReceiver";

            list.EventReceivers.Add(SPEventReceiverType.ItemAdded, assemblyName, className);

            Console.WriteLine(" - Registered - ");
Your help is appreciated.

Last edited by rvanandel; January 7th, 2010 at 04:21 PM..
Old January 7th, 2010, 04:36 PM
Authorized User
Join Date: Dec 2004
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts

Found the answer. Even though the deployment section implies that the console application will deploy the assembly to the GAC, that is not the case. I deployed my code to the GAC and then ran the console application to resolve this issue.

Similar Threads
Thread Thread Starter Forum Replies Last Post
New to Assembly OnlyHuman925 Assembly Language 4 January 10th, 2010 07:28 AM
Unable to emit assembly: Referenced assembly 'AxInterop.MSCommLib' does not have a s sanderson Visual Basic 2008 Essentials 1 July 16th, 2009 09:20 AM
Converting .NET 2.0 Assembly to .Net 1.x Assembly pskaushik .NET Framework 2.0 1 November 25th, 2006 01:51 PM
Assembly arv1980 .NET Framework 2.0 1 January 15th, 2006 02:12 PM
Chapter 16 - Assembly compiling crazy BOOK: Beginning ASP.NET 1.0 1 October 23rd, 2003 08:58 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.