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

  • SEARCH
  • Home
  • 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 6251379
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T13:36:10+00:00 2026-05-24T13:36:10+00:00

I have a base class in C# which is like so Class A {

  • 0

I have a base class in C# which is like so

   Class A
   {
     public ClassA()
     { 

     }

     .....
   }

In python I Inherit this base class

import clr
clr.AddReferenceToFile("MyClass.dll")
from MyNamespace import ClassA    

class MySubclass(ClassA):
    def _init_(self):
        print "I'm in a subclass in python"

I also have an attribute class in C# called MyAttrib("Value")

Somewhere later on in my C# code I check that any classes derived from ClassA have the Attribute MyAttrib applied to it, which fails in the case of the Python class.

Is there a way to do either of the following :

  1. Apply an attrib class to the derived class in Python?
  2. Set the AttributeValue in Python somehow when the object is being instantiated?
  3. Some other, way to do what I am thinking about

I am using IronPython with plug-ins for Visual studio.

  • 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-24T13:36:11+00:00Added an answer on May 24, 2026 at 1:36 pm

    I don’t think there’s a simple way to do that. It’s definitely easier to use a C# stub class having the necessary attributes defined and subclass that.

    But, if you really need to define a class like that in python, you can use a workaround (as shown here )

    Basically you can compile (in memory) a piece of C# code and import that in IronPython. Given that is a C# piece of code you can add attributes and hence your problem is solved.

    This is of course quite convoluted because your basically embedding a language into another making a chain like this: C# <- IronPython <- C#, then, again, I’d strongly suggest you to define a C# class already having the necessary attributes and use that.

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

Sidebar

Related Questions

I have usercontrols which inherit a base class which looks like this: BasePage.cs: using
I have a base class which looks something like this: class Base { public:
I have a base class like this: public class Trajectory{ public int Count {
I have one base class which holds a map for function pointers like this
I have 2 web user controls, both inherit the same base class which extends
So, I have a base class which has a private locking object like so:
If I have a generic class like this: public class Repository<T> { public string
I have a base class ReportElement which has type property: public abstract class ReportElement
I have a generic abstract base class from which I would like to derive
I have a base class which is non-generic with a derived generic class. The

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.