NGen, will create persistent native code to speed up process time.
Usually JIT (Just In Time) compiler will compile the MSIL ( Microsoft Intermediate code) to native code immediately before code is executed, this is temporary, this is redundant processing time, to reduce this nGen is used.
a) nGen will create native images.
b) These will be stored in native image cache.
c) When assembly is used by a managed application, CLR loader will locate, load and use the native images.
Drawbacks of nGen 1.0 and 1.1
a) All managed assemblies have dependencies. even if only dependency is on mscorlib.dll.
b) nGen Images contains code and data structure which are based on assumption on dependencies of the assembly.
c) If dependencies change, it invalidates code in the native image and runtime will fail to use native image instead reverting to JIT compilation.
d) This problem is particularly bad when considering that if a component shared by many applications is updated, for instance System.dll, then this will cause the native images for many applications on the machine to be invalidated.
e) Native images could be used only in single application domain in a process.
Features of NGen 2.0
a) Instead of invoking NGen on individual assembly, in 2.0 it is invoked on application, This is done by running NGen on top level assembly in the application.
b) NGen will automatically discover the dependency assemblies and make sure that all are having images (applies only to static assemblies recorded in assemblies manifest, dynamically loaded assemblies are not discovered by NGen like Assembly.load).
c) NGen keeps record of all dependencies of application, so that if shared component is later updated NGen can discover all application which are affected with the update and regenerate images wherever needed.
d) NGen is now windows service.
e) You can submit to NGen que if application is large enough, it will find run on free system time.
f) NGen 2.0 created images can now be shared across application domains in a process.
g) Reflection is fully supported only in native images.
h) New Generic features are fully supported.
When to Use:
1) When native images are created, these will be directly loaded by CLR and JIT is not required so the amount of space taken by JIT will be saved for other purpose.
2) Native images are loaded by CLR as just like any other DLL, which makes it possible to have cross domain usage of native images, and if other application using these native images does not require loading again, instead use already loaded image.
Extra cost:
a) You need to identify the accessing of number of times on module boundary,.
b) Strong Named assemblies which are not in GAC will have extra cost on validation, which causes every page to be touched in native image.
Here is the dynamic MS Word document generation in C#, You can use HTML tags and style sheets,
In this example table is designed not to appear even in non printable view. Usually tables will appear in word though they will not be seen when printed, In this example I have changed the border font color to white so as not to appear even in grey color, You can see MS specific style sheet tags:
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.ClearContent();
HttpContext.Current.Response.ClearHeaders();
HttpContext.Current.Response.Buffer =true;
HttpContext.Current.Response.ContentType="application/msword";
HttpContext.Current.Response.Write(@"<!DOCTYPE HTML PUBLIC ""-//W3C//DTD HTML 4.0 Transitional//EN"">");
HttpContext.Current.Response.AddHeader("Content-Disposition","attachment;filename=InvDetails.doc");
HttpContext.Current.Response.Charset = "utf-8"; //UTF8
HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.GetEncoding("windows-1250"); //windows-1250
HttpContext.Current.Response.Write("<font style='font-size:10.0pt; font-family:Verdana;'>");
HttpContext.Current.Response.Write("<BR><BR><BR>");
HttpContext.Current.Response.Write("<Table border='1' bgColor='#ffffff' borderColor='#ffffff' cellSpacing='0' cellPadding='0' style='font-size:10.0pt; font-family:Verdana; background:white;border-collapse:collapse;border:none;mso-border-alt:solid white .5pt;mso-border-right-alt:dotted white .5pt; mso-padding-alt:0in 0in 0in 0in;mso-border-insideh:.5pt dotted white; mso-border-insidev:.5pt dotted white'> <TR> <TD width=300>");
HttpContext.Current.Response.Write("MY First Row First cell Data");
HttpContext.Current.Response.Write("</Td><TD>");
HttpContext.Current.Response.Write("My First Row Second Cell Data");
HttpContext.Current.Response.Write("</Td></TR><TR><TD width=300>");
HttpContext.Current.Response.Write("MY Second Row First cell Data");
HttpContext.Current.Response.Write("</Td><TD>");
HttpContext.Current.Response.Write("My Second Row Second Cell Data");
HttpContext.Current.Response.Write("</Td></TR></TABLE>");
HttpContext.Current.Response.Write("<BR><BR><BR>");
HttpContext.Current.Response.Write("<U>");
HttpContext.Current.Response.Write("UnderLined data");
HttpContext.Current.Response.Write("</U>");
HttpContext.Current.Response.Write("<BR><BR><BR>");
HttpContext.Current.Response.Write("<P>");
HttpContext.Current.Response.Write("This is paragraph data which can be placed in single line, when it appears in word it will have autofit. Today's date in specific format::");1
HttpContext.Current.Response.Write(String.Format("{0:d-MMMM-yyyy}", DateTime.Now));
HttpContext.Current.Response.Write("</P>");
HttpContext.Current.Response.Write("</font>");
HttpContext.Current.Response.Flush();
HttpContext.Current.Response.End();
Here it ends...
Scott W. Ambler, is cool on experienced stuff , he describes what's best to use in different aspects using all components of Rambugh methods and with other models.
http://www.agilemodeling.com/style/
Highlights could be
--> Author is more specific on language, which is very cute thing, while using auto code converters this could help a lot.
eg: Public attributes and functions of an interfaces is yet not supported by Java language, while if we put class diagram interfaces with these, this diagram may not be used for this language.
--> He puts a barriage between the thinking interms of class idenitfication,
(responsibility-driven and data-driven)
--> A class could be created with attribute and operations (behavior)
--> on other aspect , it could be created with logical aspect like responsibility driven with an exaple as the Invoice class is responsible for providing its total,
and other things or operations will be help this responsibility.
Read more here:
http://www.agilemodeling.com/style/