web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Visual Studio 2012 missing reference for plugin

(0) ShareShare
ReportReport
Posted on by

I'm trying to develop my fist plugin. When I create a new project I get the following code...

 

namespace Update_Lead_Company_Name_Plugin

 {

     using System;

     using System.ServiceModel;

     using Microsoft.Xrm.Sdk;

       public class PreLeadCreate: Plugin

     {

         public PreLeadCreate()

             : base(typeof(PreLeadCreate))

         {

 base.RegisteredEvents.Add(new Tuple<int, string, string, Action<LocalPluginContext>>(20, "Create", "lead", new Action<LocalPluginContext>(ExecutePreLeadCreate)));

         }

         protected void ExecutePreLeadCreate(LocalPluginContext localContext)

         {

            if (localContext == null)

             {

                 throw new ArgumentNullException("localContext");

             }

             // TODO: Implement your custom Plug-in business logic.

         }

    }

 }

And I'm receiving the following error, without adding even a single line to the code...

Error 2 The type or namespace name 'Plugin' could not be found (are you missing a using directive or an assembly reference?) \\SERVER\UserShares\GaryMonk\Dynamics CRM Projects\Update Lead Company Name\Update Lead Company Name Plugin\PreLeadCreate.cs 20 33 Update Lead Company Name Plugin

Thank you for the help!!

Gary

 

*This post is locked for comments

I have the same question (0)
  • jlattimer Profile Picture
    24,562 on at

    Try implementing the IPlugin interface in the PreLeadCreate class.

    public class PreLeadCreate: IPlugin

  • Community Member Profile Picture
    on at

    This is strange, I started to create a plugin on Friday and it all worked ok. I decided to make some changes so I deleted it and created a new one and I'm now having all these problems.

    1. I'm getting the following warning Warning Load of property 'RootNamespace' failed.  The string for the root namespace must be a valid identifier.

    2. In the Plugin.cs The namespace statement looks like this... namespace Update Lead.Update Company Name (notice the spaces)

    3. After changing from Plugin to IPlugin I'm receiving the following 2 messages...

       a. Could not copy the file "C:\Users\User\Documents\Visual Studio 2012\Projects\Update Lead\Update Company         Name\bin\Debug\Update Lead.Update Company Name.dll" because it was not found.

       b. 'object' does not contain a constructor that takes 1 arguments ( This error is on ": base(typeof(PreLeadCreate))"

    Thanks Jason for the help!!

    Gary

  • jlattimer Profile Picture
    24,562 on at

    In the project properties - make sure the default namespace doesn't have any spaces and update the namespaces in the the code accordingly and see what effect that has - might be the root of your issues now.

    Just throwing this out there - have you looked the the Developer's Toolkit that comes with the SDK Download? It contains templates you can use for creating plugins.

  • Verified answer
    Community Member Profile Picture
    on at

    Ok, as long as you don't put spaces in the project name everything works fine. Not really sure why I did that, but...

    Thanks

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans