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 6819371
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T21:17:55+00:00 2026-05-26T21:17:55+00:00

Are there any meaningful ways to use public void SetCustomAttribute( ConstructorInfo con, byte[] binaryAttribute

  • 0

Are there any meaningful ways to use

public void SetCustomAttribute(
    ConstructorInfo con,
    byte[] binaryAttribute
)

from AssemblyBuilder.SetCustomAttribute

Clarification: by meaningful, I mean what kind of data would you ever want to fill that array with? What does it do with it?

Is there something like I could binary formatter serialize an existing Attribute and pass it that data?

  • 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-26T21:17:55+00:00Added an answer on May 26, 2026 at 9:17 pm

    Because attribute storage is a magic science. They are always stored using a binary format that is encoded, and in this case it’s just giving you raw write-access to the binary content of the attribute. Largely, this would be used by someone implementing their own compiler, or are trying to squeak out every bit of performance as possible. You can’t just put anything you’d like in there, you are expected to follow the CLI’s specifications.

    For example, the value of the constructor arguments in an attribute must be encoded. Take for example the following attribute:

    internal class MyAttribute : Attribute
    {
        public string Foo;
    }
    

    And if we apply it with something like [MyAttribute(Foo = "4")] to a token, it must serialize:

    • The member being initialized
    • The type of member being initialized (field or property)
    • Whether or not the attribute is inherited
    • The value
    • Etc.

    So it gets compiled into something like this:

    .custom instance void Dummy.MyAttribute::.ctor() = ( 01 00 01 00 53 0E 03 46 6F 6F 01 34 )
    

    These values mean:

    1. The prolog (the encoding version). This starts with the byte value of 0x0001 (the version has never changed, AFAIK)
    2. The number of Constructor arguments (1 in this case) (So far this takes care of the first 4 bytes, 01 00 01 00.
    3. The type of constructor argument. 0x53 if a field (See CorSerializationType for all of them). Type is 0x50, Property is 0x54, and there are a few others. (This explains the 5th byte, 0x53).
    4. Other details about the encoding of the data (a string).
    5. The field name (Foo = 0x46 0x6F 0x6F)
    6. The length of the string (0x1)
    7. The UTF8 value of the string 0x34 = “4”
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there any meaningful distinction between: class A(object): foo = 5 # some default
When building an application, is there any meaningful difference between the idea of Find
Is there any way to capture the MouseDown even from the .NET 2.0 TextBox
Is there any difference between int on_exit(void (*function)(int , void *), void *arg); and
Is there any reason not to use the bitwise operators &, |, and ^
When I make a query... is there any meaningful difference between using a find_by
Is there any way to check if an iterator (whether it is from a
Is there any way to check whether a file is locked without using a
Is there any free or commercial component written in .NET (no COM interop) that
Is there any query which can return me the number of revisions made to

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.