02.07.2013 Views

.NET Interview Questions 4 th Edition By Shivprasad ... - A2Z Dotnet

.NET Interview Questions 4 th Edition By Shivprasad ... - A2Z Dotnet

.NET Interview Questions 4 th Edition By Shivprasad ... - A2Z Dotnet

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>th</strong>eClass.Name = “Entry Point”;<br />

// add bo<strong>th</strong> <strong>th</strong>e code of WriteLine and Readline<br />

objMainMe<strong>th</strong>od.Statements.Add (write Line);<br />

objMainMe<strong>th</strong>od.Statements.Add (read Line);<br />

// add namespace and add class<br />

Code Namespace ns = new Code Namespace (“<strong>Interview</strong> <strong>Questions</strong>”);<br />

ns.Imports.Add (new CodeNamespaceImport (“System”));<br />

ns.Types.Add (<strong>th</strong>e Class);<br />

// Generate <strong>th</strong>e Compile Unit<br />

CodeCompileUnit unit = new CodeCompileUnit();<br />

unit.Namespaces.Add(ns);<br />

Sample provided is very basic but in actual project, using codedom can be very<br />

complicated. Projects where you need auto code generation codedom can be a right<br />

choice. Beware of high bulky architecture created due to codedom.<br />

Chapter 2: <strong>NET</strong> Interoperability<br />

(I) How can we use COM Components in .<strong>NET</strong>?<br />

Twist: What is RCW?<br />

.<strong>NET</strong> components communicate wi<strong>th</strong> COM using RCW (Runtime Callable Wrapper). Following<br />

are <strong>th</strong>e ways wi<strong>th</strong> which you can generate RCW:-<br />

• Adding reference in Visual Studio.net. See figure below (Adding reference using<br />

VS.<strong>NET</strong> 2005). Wrapper class is generated and placed in <strong>th</strong>e “BIN” directory.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!