Assembly attribute ???

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • serge calderara

    Assembly attribute ???

    Dear all,

    In my assembly info file I have such kind of default
    information :

    <Assembly: AssemblyTitle(" ")>
    <Assembly: AssemblyDescrip tion("")>
    <Assembly: AssemblyCompany ("")>

    Can I add any other type of information I want like as
    follow :
    <Assembly: AssemblyKeyCode ("3215462452158 ")>

    If yes how can I access that key from code?

    thanks for your information
    regards
    serge

  • Thomas Tomiczek \(MVP\)

    #2
    Re: Assembly attribute ???


    "serge calderara" <serge.calderar a@maillefer.net > wrote in message
    news:033001c3a5 1c$54f84550$a00 1280a@phx.gbl.. .[color=blue]
    > Dear all,
    >
    > In my assembly info file I have such kind of default
    > information :
    >
    > <Assembly: AssemblyTitle(" ")>
    > <Assembly: AssemblyDescrip tion("")>
    > <Assembly: AssemblyCompany ("")>[/color]

    Naturally.
    [color=blue]
    >
    > Can I add any other type of information I want like as
    > follow :
    > <Assembly: AssemblyKeyCode ("3215462452158 ")>[/color]

    Yes. Look in the documentation on how to create your own Attribute. It is
    basically a class inheriting from Attribute with an attribute on itself
    telling the compiler here you are allowed to put it.
    [color=blue]
    > If yes how can I access that key from code?[/color]

    Using reflection. Get ahold of the Assembly "object" (yes, it is an object,
    too) for the assembly, and call the GetCustomAttrib utes method on it.

    Assembly a; // which you can get from a type when you have it

    AssemblyKeyCode Attribute [] kcaa =
    a.GetCustomAttr ibuges(typeof(A ssemblyKeyCodeA ttribute));

    The rest is in the documentation.

    Thomas Tomiczek
    THONA Software & Consulting Ltd.
    (Microsoft MVP C#/.NET)


    Comment

    • serge calderara

      #3
      Re: Assembly attribute ???

      Thanks for your reply...

      Is there a way to change assembly attribute during runtime?

      In fact what I am thinking of is a way of having a kind of
      licence activation for our asembly when distributed.
      I was thinking to handle it in the following way:

      1- I scann first for the existance of the assembly in the
      system

      2- then I check th MAC adress of the install system
      3- then I combine that mac adress with assembly product
      code and may be write thea crypted code somewhere

      4- during runtime if that code is valid, I will check one
      assembly atrtribute which could be AsssemblyLicCou nter

      if this lic Counter = 2 then it means that it is able to
      use 2 licence, when one is used i decrease that counter by
      1, if it reach 0 then he cannot use any extra licence
      until we provide hime an extension.

      Does it sounds something simple or too crazy or too
      complex?

      In addition I woul like to get that licence installed in
      only one system, in order to avoid copy

      thanks for your comments
      regards
      serge
      [color=blue]
      >-----Original Message-----
      >
      >"serge calderara" <serge.calderar a@maillefer.net > wrote[/color]
      in message[color=blue]
      >news:033001c3a 51c$54f84550$a0 01280a@phx.gbl. ..[color=green]
      >> Dear all,
      >>
      >> In my assembly info file I have such kind of default
      >> information :
      >>
      >> <Assembly: AssemblyTitle(" ")>
      >> <Assembly: AssemblyDescrip tion("")>
      >> <Assembly: AssemblyCompany ("")>[/color]
      >
      >Naturally.
      >[color=green]
      >>
      >> Can I add any other type of information I want like as
      >> follow :
      >> <Assembly: AssemblyKeyCode ("3215462452158 ")>[/color]
      >
      >Yes. Look in the documentation on how to create your own[/color]
      Attribute. It is[color=blue]
      >basically a class inheriting from Attribute with an[/color]
      attribute on itself[color=blue]
      >telling the compiler here you are allowed to put it.
      >[color=green]
      >> If yes how can I access that key from code?[/color]
      >
      >Using reflection. Get ahold of the Assembly "object"[/color]
      (yes, it is an object,[color=blue]
      >too) for the assembly, and call the GetCustomAttrib utes[/color]
      method on it.[color=blue]
      >
      >Assembly a; // which you can get from a type when you[/color]
      have it[color=blue]
      >
      >AssemblyKeyCod eAttribute [] kcaa =
      >a.GetCustomAtt ribuges(typeof( AssemblyKeyCode Attribute));
      >
      >The rest is in the documentation.
      >
      >Thomas Tomiczek
      >THONA Software & Consulting Ltd.
      >(Microsoft MVP C#/.NET)
      >
      >
      >.
      >[/color]

      Comment

      Working...