Assembly ID?

T

Tamir Khason

I have compiled libraries as dlls (managed) and I have to uniquely enumerate
it (kind of Guid for each one). All of them implements the same interface
(see code block) and generate ID each time it called. I want to fix it into
assembly (option 1) [maybe using SetAttribute into
AssemblyConfigurationAttribute] or use any internal GUID of assemble if
possible (Option 2). How to implement it without changing all implementation
classes (including abstracts)? Are any unique ID for compiled dll in .NET?

public Interface foo
{
Guid FooID{get;}
}
public abstract Foo:foo
{
Guid m_id=Guid.NewGuid();
public Guid ID{get{return m_id;}}
}
public class Foo1:Foo
{
}
public class Foo2:Foo
{
}
 
S

Scott Allen

Hi Tamir:

If you strong name an assembly, then the full name of the assembly
(including the version, culture, and public key) will be unique in
space and time.

You can read the following to see more information, including links
how to create and programmatically work with assemblies:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconassemblynames.asp

One caveat is: strong named assemblies do not *have* to appear in the
GAC. Sometimes these articles make it sounds as if they do (because an
assembly in the GAC has to have a strong name).
 
T

Tamir Khason

I do not want to strong name the assembly due those files are regenerated by
code, additional obsticle is versioning.
Any other options to do this?


--
Tamir Khason
You want dot.NET? Just ask:
"Please, www.dotnet.us "

Scott Allen said:
Hi Tamir:

If you strong name an assembly, then the full name of the assembly
(including the version, culture, and public key) will be unique in
space and time.

You can read the following to see more information, including links
how to create and programmatically work with assemblies:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconassemblynames.asp

One caveat is: strong named assemblies do not *have* to appear in the
GAC. Sometimes these articles make it sounds as if they do (because an
assembly in the GAC has to have a strong name).

--
Scott
http://www.OdeToCode.com/

I have compiled libraries as dlls (managed) and I have to uniquely
enumerate
it (kind of Guid for each one). All of them implements the same interface
(see code block) and generate ID each time it called. I want to fix it
into
assembly (option 1) [maybe using SetAttribute into
AssemblyConfigurationAttribute] or use any internal GUID of assemble if
possible (Option 2). How to implement it without changing all
implementation
classes (including abstracts)? Are any unique ID for compiled dll in .NET?

public Interface foo
{
Guid FooID{get;}
}
public abstract Foo:foo
{
Guid m_id=Guid.NewGuid();
public Guid ID{get{return m_id;}}
}
public class Foo1:Foo
{
}
public class Foo2:Foo
{
}
 
T

Tamir Khason

Thank you for response, but in my case I do not know the value af the
attribute in compilation process, but only after the first run so I have to
write it into manifest data on runtime. The code for this is very slow and
ugly are there any other options to do this?
 
K

Kevin Yu [MSFT]

Thanks for Scott's quick response.

Hi Tamir,

First of all, I would like to confirm my understanding of your issue. From
your description, I understand that you need to write a GUID to the
assembly when a method is called. If there is any misunderstanding, please
feel free to let me know.

As far as I know, if you're not working on a strong named assembly, the
only way is to use a custom attribute to save data at assembly level like
Scott mentioned. This persists the GUID and it can be get next time the
assembly is loaded.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 

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