ngen

T

Tony Johansson

Hi!

I have used ngen on an assembly exe file by writing
ngen test.exe and it works.

I just wonder how can I see if ngen has been run on an assembly(dll or exe)
?

//Tony
 
A

Alberto Poblacion

Tony Johansson said:
I just wonder how can I see if ngen has been run on an assembly(dll or
exe)

You can run "ngen display [assembly name]". If the assembly is not
installed in the native images cache, ngen will respond with "Error: The
specified assembly is not installed."
 
T

Tony Johansson

Alberto Poblacion said:
Tony Johansson said:
I just wonder how can I see if ngen has been run on an assembly(dll or
exe)

You can run "ngen display [assembly name]". If the assembly is not
installed in the native images cache, ngen will respond with "Error: The
specified assembly is not installed."

Hi!

I just wonder if anyone have any experience how much in performance profit
it might give when uses this ngen utility.
I'm just curious to know.

//Tony
 
P

Peter Duniho

Tony said:
I just wonder if anyone have any experience how much in performance profit
it might give when uses this ngen utility.
I'm just curious to know.

It could help a little, it could help a lot. It just depends on your
situation. You can find out specifically how much it helps by doing
actual performance testing.
 
T

Tony Johansson

Patrice said:
Hello,


Just try ngen /? or see the documentation for ngen at :
http://msdn.microsoft.com/en-us/library/6t9t5wcf.aspx to find the
appropriate option...

In a book I'm reading it says.
"A company name commonly used as the first part of the namespace is not
necessarily unique, so something more must be used to build a strong name.
For this public key is used. Because of the public/private key principle is
strong names, no one without access to your private key can destuctively
create an assembly that could be unintentionally called by the client"

If I have created a strong name for an assembly and this assembly has been
placed in the GAC how do I get this private
key that is mentioned in the text.
I have never thought about this private key because I have never used it so
I just curious how I can get it ?

//Tony
 
P

Peter Duniho

Tony said:
[...]
If I have created a strong name for an assembly and this assembly has been
placed in the GAC how do I get this private
key that is mentioned in the text.

You don't. That's the point!

If you or anyone else could retrieve the private key from an assembly
that's been placed in the GAC, then it would negate the whole point of
having a private key. Anyone could then impersonate you and your
original private key.

There's a reason the key is described as "private". You should keep it
to yourself. :)
I have never thought about this private key because I have never used it so
I just curious how I can get it ?

Generally, you would be issued a certificate by some certificate
provider, who essentially provides a private key for you.

Hopefully, you should never have to actually know the private key
itself. Rather, it's encapsulated in a certificate that you can use for
encryption/strong-naming/etc.

My recollection is that you can self-issue a certificate for
low-security purposes. It won't be trusted when a root authority is
needed, but it's enough for strong-naming. Unfortunately (or
fortunately? :) ) I haven't had a need to sign my .NET programs and so
have no first-hand, practical experience with it, so I can't tell you
all the specifics.

I can tell you that you should keep your private key to yourself. :)

Pete
 
A

Alberto Poblacion

Tony Johansson said:
If I have created a strong name for an assembly and this assembly has been
placed in the GAC how do I get this private
key that is mentioned in the text.
I have never thought about this private key because I have never used it
so I just curious how I can get it ?

If you have created a strong name for an assembly, then at some point
you must have created a key file (.snk). You either created it manually with
"sn -k", or you used the project properties in Visual Studio to select the
option "new key file". In both cases, a .snk file is created on disk. This
..snk file contains both the private and the public key. You can extract the
public key from the .snk file by means of the SN.EXE utility. From a Visual
Studio command prompt, type "sn -?" to see the options. I don't remember
seeing an option to extract the private key, but it is there anyway; for all
practical purposes the .snk file IS your private key. You just provide the
file when you need to encrypt something with the private key.
 
T

Tony Johansson

Alberto Poblacion said:
If you have created a strong name for an assembly, then at some point
you must have created a key file (.snk). You either created it manually
with "sn -k", or you used the project properties in Visual Studio to
select the option "new key file". In both cases, a .snk file is created on
disk. This .snk file contains both the private and the public key. You can
extract the public key from the .snk file by means of the SN.EXE utility.
From a Visual Studio command prompt, type "sn -?" to see the options. I
don't remember seeing an option to extract the private key, but it is
there anyway; for all practical purposes the .snk file IS your private
key. You just provide the file when you need to encrypt something with the
private key.

Good answer!

//Tony
 
A

Arne Vajhøj

Alberto Poblacion said:
Tony Johansson said:
I just wonder how can I see if ngen has been run on an assembly(dll or
exe)

You can run "ngen display [assembly name]". If the assembly is not
installed in the native images cache, ngen will respond with "Error: The
specified assembly is not installed."

I just wonder if anyone have any experience how much in performance profit
it might give when uses this ngen utility.
I'm just curious to know.

Execution: using NGEN will either not improve the performance or
make the app run slower (due to less information being available
when generating the native code).

Startup: using NGEN may result in faster startup.

In general you should not use NGEN.

Arne
 
T

Tony Johansson

Arne Vajhøj said:
"Alberto Poblacion"<[email protected]>
skrev i
meddelandet news:OuZxfw%[email protected]...
I just wonder how can I see if ngen has been run on an assembly(dll or
exe)

You can run "ngen display [assembly name]". If the assembly is not
installed in the native images cache, ngen will respond with "Error: The
specified assembly is not installed."

I just wonder if anyone have any experience how much in performance
profit
it might give when uses this ngen utility.
I'm just curious to know.

Execution: using NGEN will either not improve the performance or
make the app run slower (due to less information being available
when generating the native code).

Startup: using NGEN may result in faster startup.

In general you should not use NGEN.

Arne

I don't understand your mail what is it that you try to say about Execution
/Startup.

What I have heard is that instead of letting the CLR in a way compile MSIL
code into native during runtime
you can do this by using ngen so the startup should be faster. This is what
I have heard.

//Tony
 
P

Peter Duniho

Tony said:
I don't understand your mail what is it that you try to say about Execution
/Startup.

He is describing "Startup" as a separate phase of operation from
"Execution". One might consider "Execution" to include "Startup", but
it seems obvious to me from the context that that's not how Arne is
describing it. Rather, he is considering the two as different phases of
operation for a given assembly.

And if you look at the operation of a program being "Startup" followed
by "Execution", then ngen.exe can improve the "Startup" portion because
the compilation that normally happens then has already been done. But
since your program is already compiled once you get to the "Execution"
phase, whether or not you use ngen.exe, ngen.exe can't improve the
performance there.
What I have heard is that instead of letting the CLR in a way compile MSIL
code into native during runtime
you can do this by using ngen so the startup should be faster. This is what
I have heard.

Of course you have. You just heard it from Arne!

Pete
 
A

Arne Vajhøj

Arne Vajhøj said:
"Alberto Poblacion"<[email protected]>
skrev i
meddelandet I just wonder how can I see if ngen has been run on an assembly(dll or
exe)

You can run "ngen display [assembly name]". If the assembly is not
installed in the native images cache, ngen will respond with "Error: The
specified assembly is not installed."

I just wonder if anyone have any experience how much in performance
profit
it might give when uses this ngen utility.
I'm just curious to know.

Execution: using NGEN will either not improve the performance or
make the app run slower (due to less information being available
when generating the native code).

Startup: using NGEN may result in faster startup.

In general you should not use NGEN.

I don't understand your mail what is it that you try to say about Execution
/Startup.

startup = the time to load the code and JIT if not NGEN'ed
execution = the time to run after the code id loaded and JIT'ed
What I have heard is that instead of letting the CLR in a way compile MSIL
code into native during runtime
you can do this by using ngen so the startup should be faster. This is what
I have heard.

It is true !

:)

How much depend on the complexity of the assembly.

Arne
 

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

Similar Threads


Top