Assembly attribute ???

  • Thread starter serge calderara
  • Start date
S

serge calderara

Dear all,

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

<Assembly: AssemblyTitle("")>
<Assembly: AssemblyDescription("")>
<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
 
T

Thomas Tomiczek \(MVP\)

serge calderara said:
Dear all,

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

<Assembly: AssemblyTitle("")>
<Assembly: AssemblyDescription("")>
<Assembly: AssemblyCompany("")>
Naturally.


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

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.
If yes how can I access that key from code?

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

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

AssemblyKeyCodeAttribute [] kcaa =
a.GetCustomAttribuges(typeof(AssemblyKeyCodeAttribute));

The rest is in the documentation.

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

serge calderara

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 AsssemblyLicCounter

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
-----Original Message-----

Dear all,

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

<Assembly: AssemblyTitle("")>
<Assembly: AssemblyDescription("")>
<Assembly: AssemblyCompany("")>
Naturally.


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

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.
If yes how can I access that key from code?

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

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

AssemblyKeyCodeAttribute [] kcaa =
a.GetCustomAttribuges(typeof(AssemblyKeyCodeAttribute));

The rest is in the documentation.

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


.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top