Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Display Modes
  #1 (permalink)  
Old January 7th, 2010, 03:10 PM
Authorized User
 
Join Date: Dec 2004
Location: Chesterfield, MO, USA.
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.

Code:
Unhandled Exception: System.InvalidOperationException: Could not load file or assembly 'ApplicationEventReceiver, Version=1.0.0.0, 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
gration)
   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:

Code:
namespace ApplicationEventReceiver
{
    class ApplicationEventReceiver : SPItemEventReceiver
and my console application looks like this:
Code:
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=1.0.0.0, Culture=neutral, PublicKeyToken=6ac52d8504a20881";
            string className = "ApplicationEventReceiver.ApplicationEventReceiver";

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

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

Last edited by rvanandel; January 7th, 2010 at 03:21 PM.
  #2 (permalink)  
Old January 7th, 2010, 03:36 PM
Authorized User
 
Join Date: Dec 2004
Location: Chesterfield, MO, USA.
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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.
 


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
New to Assembly OnlyHuman925 Assembly Language 4 January 10th, 2010 06: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 12:51 PM
Assembly arv1980 .NET Framework 2.0 1 January 15th, 2006 01:12 PM
Chapter 16 - Assembly compiling crazy BOOK: Beginning ASP.NET 1.0 1 October 23rd, 2003 08:58 PM



All times are GMT -4. The time now is 02:12 AM.


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.