Can I pre-compile dlls on my machine and distribute them?

  • Thread starter Thread starter Jack Wright
  • Start date Start date
J

Jack Wright

Dear All,
I know we cannot "pre-compile dlls on my machine and distribute
them" but my boss needs a link to a MS site or any technical site that
tells this...I need to give him that link asap...

Please help...

TALIA

Many Regards
Jack
 
Jack Wright said:
I know we cannot "pre-compile dlls on my machine and distribute
them" but my boss needs a link to a MS site or any technical site that
tells this...I need to give him that link asap...

Does he mean pre-JIT, eg with ngen? I believe you can do that, but I
wouldn't personally recommend it.
 
Dear Jon,Yes. Ngen the dlls on my machine and then copy these dlls on a user
machine.Really. How is this possible...I would really be suprised if we can do
this...Why? Do you know of a site/link on the web that discusses this issue and
gives the pros and cons...it will be very helpful...

Thanks a lot for ur quick reponse...

Please help...

TALIA

Many Regards
Jack
 
Well I guess you could copy the NGEN'd DLLs from the native cache on the dev machine (along with the non-NGEN'd one which will also be needed). Then you could put them in the native cache on the target machine.

The problem is that the optimizations that NGEN performed would be for the dev machine not the target machine so the optimization could be less than perfect. There is a chance (I haven't tried this so its pure supposition) that the runtime will see the hardware as totally different from that used to NGEN (does it store the machine GUID in the native file?) and refuse to load the native images but use the standard non-NGEN'd version instead.

Are you writing a GUI application? NGEN doesn't do a huge amount for non-GUI applications as it mostly helps speed up load times. What benefit does your boss see in NGENing, you shoulod test to see if NGEN really helps at all for *your* application (it can slow things down as both the native and non-native image need to be loaded into memory so potentially more paging). If it does help, what is the problme with installing on the client machine rather than just copying?

Regards

Richard Blewett - DevelopMentor
http://staff.develop.com/richardb/weblog

nntp://news.microsoft.com/microsoft.public.dotnet.framework/<[email protected]>

Dear Jon,Yes. Ngen the dlls on my machine and then copy these dlls on a user
machine.Really. How is this possible...I would really be suprised if we can do
this...Why? Do you know of a site/link on the web that discusses this issue and
gives the pros and cons...it will be very helpful...

Thanks a lot for ur quick reponse...

Please help...

TALIA

Many Regards
Jack







---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.771 / Virus Database: 518 - Release Date: 28/09/2004



[microsoft.public.dotnet.framework]
 
Jack Wright said:
Yes. Ngen the dlls on my machine and then copy these dlls on a user
machine.
Right.

Really. How is this possible...I would really be suprised if we can do
this...

Why not? I certainly *believe* it's possible, although you'd have to do
some work to get the ngen'd DLLs out of the GAC on the development
machine and install them in the GAC of the client machine.
Why? Do you know of a site/link on the web that discusses this issue and
gives the pros and cons...it will be very helpful...

The only benefit ngen really gives is startup time. However, the JIT
compiler doesn't perform as many optimisations as it does in the
"normal" framework. (The reasons why this *might* be true are obvious -
it has to compile to lowest common denominator code rather than taking
advantage of CPU-specific code. I don't know if the JIT actually does
this, but I believe there are other optimisations it doesn't use.)

That's assuming I'm correctly understanding what ngen does. It could be
that the images it produces *are* genuinely CPU-specific, but I don't
believe so.

It's generally reckoned to be a better idea to run ngen at install
time. Again, I'd only do *that* after checking that it really helps.

The following article by Jeffrey Richter gives some of the pros and
cons:

http://www.codeguru.com/Csharp/.NET/net_general/toolsand3rdparty/articl
e.php/c4651/

aka http://tinyurl.com/5v7kt
 
Thanks Richard, Jon for answering my queries...
Do you have a sample that shows how to copy Ngend dlls on to another
machine? I would like to try it out and show it to my boss...

Richard:non-GUI applications as it mostly helps >>speed up load times.
I have a stub Client Application that loads dlls via No Touch
Deployment.

Is it a bad idea to have a small .net exe whose short-cut I put on the
Startup folder so that everytime the machine is restarted my .net exe
looks into the Download cache and from Assembly.ini loads the dlls, this
way I will always have the latest dll loaded and pre-compiled...all that
exe will do is Assembly.LoadFrom("http://...")

Please help...

TALIA

Many Regards
Jack
 
Jack Wright said:
Thanks Richard, Jon for answering my queries...
Do you have a sample that shows how to copy Ngend dlls on to another
machine? I would like to try it out and show it to my boss...

No, I don't have any samples I'm afraid.
Richard:
non-GUI applications as it mostly helps >>speed up load times.
I have a stub Client Application that loads dlls via No Touch
Deployment.

Is it a bad idea to have a small .net exe whose short-cut I put on the
Startup folder so that everytime the machine is restarted my .net exe
looks into the Download cache and from Assembly.ini loads the dlls, this
way I will always have the latest dll loaded and pre-compiled...all that
exe will do is Assembly.LoadFrom("http://...")

Well, unless you tell ngen to run, it won't be pre-compiling
anything...
 
I don't have any samples as its not something i would consider doing. In your situation I'd leave the compilation to the JIT compiler. Anything else and you are fighting the runtime and only setting up headaches for yourself as .NET evolves through versions and even service packs.

Regards

Richard Blewett - DevelopMentor
http://staff.develop.com/richardb/weblog

nntp://news.microsoft.com/microsoft.public.dotnet.framework/<[email protected]>

Thanks Richard, Jon for answering my queries...
Do you have a sample that shows how to copy Ngend dlls on to another
machine? I would like to try it out and show it to my boss...

Richard:non-GUI applications as it mostly helps >>speed up load times.
I have a stub Client Application that loads dlls via No Touch
Deployment.

Is it a bad idea to have a small .net exe whose short-cut I put on the
Startup folder so that everytime the machine is restarted my .net exe
looks into the Download cache and from Assembly.ini loads the dlls, this
way I will always have the latest dll loaded and pre-compiled...all that
exe will do is Assembly.LoadFrom("http://...")

Please help...

TALIA

Many Regards
Jack



---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.771 / Virus Database: 518 - Release Date: 28/09/2004



[microsoft.public.dotnet.framework]
 
Dear Jon,
Is it a bad idea to have a small .net exe whose short-cut I put on the
Startup folder so that everytime the machine is restarted my .net exe
looks into the Download cache and from Assembly.ini loads the dlls, this
way I will always have the latest dll loaded and pre-compiled...all that
exe will do is Assembly.LoadFrom("http://...")

Well, unless you tell ngen to run, it won't be pre-compiling anything...
oops...:-) I meant Assembly.LoadForm will load my dll and CLR will
compile it to machine code...right?

If I put my .net dll in GAC (without Ngening it) will it get compiled
everytime my machine is restarted and my application accesses it?

Thanks & Regards
Jack
 
oops...:-) I meant Assembly.LoadForm will load my dll and CLR will
compile it to machine code...right?

Only the methods which end up being called, in fact.
If I put my .net dll in GAC (without Ngening it) will it get compiled
everytime my machine is restarted and my application accesses it?

Yes.
 
Dear Jon,
I admire your the patience you have shown in replying to my
queries...thanks a ton...
One last question I guess...:-)
When I start my Application, use it and close it and again start
it...why does it again go for compliation...
Can something other than NGen be done about this?

Thanks & regards
Jack
 
Jack Wright said:
I admire your the patience you have shown in replying to my
queries...thanks a ton...

No problem :)
One last question I guess...:-)
When I start my Application, use it and close it and again start
it...why does it again go for compliation...

Well, you might be using a different CPU from last time you ran it. Or
maybe it's using a newer version of the framework. Or maybe you don't
want to waste disk space with code that can easily (and reasonably
quickly) be generated on the fly.

For most applications, JIT compiling is absolutely fine - no pre-
compilation is needed.
Can something other than NGen be done about this?

No - that's the whole purpose of NGen.
 
When I start my Application, use it and close it and >>again start
it...why does it again go for compliation...
Well, you might be using a different CPU from last time >you ran it.
The Application is running on the same machine and has only one
CPU...and is running via No Touch deployment...
but no new dlls were deployed...Can I control which CPU my application
uses?
Or maybe it's using a newer version of the framework.
No...I did not change any dll...is this a problem with only No touch
deployment or will even full client deployment application compile the
next time it is started...
Or maybe you don't want to waste disk space with code >that can easily
(and reasonably quickly) be generated on >the fly.
I swear I have not done anything like that...;-) only thing is that my
application was running via No Touch Deployment via a stub exe...and no
new dll was deployed the second time it was launched...

Thanks & Regards
Jack
 
It will always recompile - for example last time it ran you may have had alot of other stuff running so the machine was under memory pressure, so the JIT compiled for smaller code. This time maybe you don't have memory pressure and so it compiles with the emphasis on speed (I'm not sure if it actually does this optimization but its an example of the possibiliites).

The only way to prevent the recompilation is to use NGEN but even then there are situaltions where run runtime will fall back to JIT. If any assemblies it depends on change then is goes back to JIT for it may have inlined one of their methods in the NGEN'd version.

Regards

Richard Blewett - DevelopMentor
http://staff.develop.com/richardb/weblog

it...why does it again go for compliation...
Well, you might be using a different CPU from last time >you ran it.
The Application is running on the same machine and has only one
CPU...and is running via No Touch deployment...
but no new dlls were deployed...Can I control which CPU my application
uses?
Or maybe it's using a newer version of the framework.
No...I did not change any dll...is this a problem with only No touch
deployment or will even full client deployment application compile the
next time it is started...
Or maybe you don't want to waste disk space with code >that can easily
(and reasonably quickly) be generated on >the fly.
I swear I have not done anything like that...;-) only thing is that my
application was running via No Touch Deployment via a stub exe...and no
new dll was deployed the second time it was launched...

Thanks & Regards
Jack



---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.771 / Virus Database: 518 - Release Date: 28/09/2004



[microsoft.public.dotnet.framework]
 
Back
Top