Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6082991
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T11:21:02+00:00 2026-05-23T11:21:02+00:00

My questions are: Does this look ‘correct’? Or is there something fundamental I am

  • 0

My questions are:

  • Does this look ‘correct’? Or is there something fundamental I am missing?
  • Since I have a reference to the PluginCo.Load.dll, which holds the custom Attribute I need to specify in my own plugin, this is possible, right?

I am trying to create a .Net DLL to be loaded into a plugin architecture. In order for it to load in the host application, the class and method of my plugin must have a specific Attribute specified. This custom attribute is implemented in a separate DLL for the plugin.

My plugin code I am trying to write is what I believe is the problem. It SHOULD load into the plugin framework because it specifies the CreatedByPluginCo attribute on the class:

using System.Windows.Forms;
using PluginCo.Load;

namespace _test2
{

    [CreatedByPluginCo]
    public class Class1
    {
        [CreatedByPluginCo]
        public static void Test()
        {
            MessageBox.Show("If you see this it worked!");
        }
    }

Here is what the code looks like in the PluginCo.Load.dll:

[AttributeUsage(AttributeTargets.Property | AttributeTargets.Method | AttributeTargets.Constructor | AttributeTargets.Class | AttributeTargets.Assembly, AllowMultiple=true, Inherited=false)]
public class CreatedByPluginCoAttribute : Attribute
{
    // Fields
    private string _stringComment = string.Empty;

    // Properties
    public string Comment
    {
        get
        {
            return this._stringComment;
        }
        set
        {
            this._stringComment = value;
        }
    }
}

For a method to test the presence of the CreatedByPluginCo attribute in my assembly (which I hope to eventually load as a plugin), I put this method together in a small application (requires Reflection):

public static Attribute GetCreatedByPluginCoAttribute(Attribute[] attributes)
{
    for (int i = 0; i < attributes.Length; i++)
    {
        if (attributes[i].GetType().Name.CompareTo(typeof(CreatedByPluginCoAttribute).Name) == 0)
        {
            return attributes[i];
        }
    }
    return null;
}

and test if this returns null:

if (GetCreatedByPluginCoAttribute(Attribute.GetCustomAttributes(Assembly.LoadFrom(fileName))) == null)

Unfortunately, this method above is returning false when I load my little sample/test plugin DLL. It is returning true for other sample plugins (which I obviously didn’t write..).

I am looking at these sample plugins and there isn’t much too them – anything that has this attribute on a public class is loadable. I am doing exactly what they are doing..

Any insight appreciated! Even if its just a simple “that is strange, this looks correct to me”, that would help my sanity.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T11:21:03+00:00Added an answer on May 23, 2026 at 11:21 am

    The GetCustomAttributes overload you are calling returns the custom attributes that are applied at the assembly level, not types or methods.

    You will need to enumerate the public types in the assembly, and then examine each to see if it has your attribute applied.

    And to answer your other question: No, there are nothing fundamentally wrong with what you are doing (but have you heard of MEF ? Might save you some trouble).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

First look at this url: https://stackoverflow.com/questions/tagged/xoxoxo/ This directory does not exists but somehow stackoverflow
Quite new to this mocking thing, I have a couple of questions. Correct me
This is a general how does DataBind work questions... I have a simple page
I've spotted this question: Does Microsoft SkyDrive have an API? But not having an
This might be a silly question but does ARC (automatic reference counting) interact with
Still a little gunshy about jQuery. Does this simple popup window script look okay?
I'm sure there's a million questions along this line but I can't find one
I am reading this bison introduction. I have two questions and it will be
Simple question - what does this actually do? var oq = (ObjectQuery<TEntity>)L2EQuery; return ExecuteFirstorDefault<TEntity>(oq,
* Simple question : Why does this function throw an exception when evaluated ?

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.