31. Can I stop my code being reverse-engineered from IL?
No. Currently no simple way to stop code being reverse-engineered from IL. In future it is likely that IL obfuscation tools will become available, either from MS or from third parties.
If you are writing web services then reverse-engineering is not a problem as clients do not have access to your IL.
32. Can I write IL programs directly?
Yes. Simple example to the DOTNET mailing list:
.assembly MyAssembly {}
.class MyApp {
.method static void Main() {
.entrypoint
ldstr "Hello, IL!"
call void System.Console:: WriteLine (class System.Object)
ret
}
}
Just put this into a file called dotnet.il, and then run ilasm dotnet.il. An exe assembly will be generated.
33. Can I do things in IL that I can't do in C#?
Yes. A couple of simple examples are that you can throw exceptions that are not derived from System.Exception, and you can have non-zero-based arrays.
34. How does .NET remoting work?
.NET remoting involves sending messages along channels.
Two of the standard channels are HTTP and TCP. TCP is intended for LANs only - HTTP can be used for LANs or WANs (internet).
Support is provided for multiple message serialization formats. Examples are SOAP (XML-based) and binary. By default, the HTTP channel uses SOAP (via the .NET runtime Serialization SOAP Formatter), and the TCP channel uses binary (via the .NET runtime Serialization Binary Formatter). But either channel can use either serialization format.
There are a number of styles of remote access:
• SingleCall. Each incoming request from a client is serviced by a new object. The object is thrown away when the request has finished.
• Singleton. All incoming requests from clients are processed by a single server object.
• Client-activated object. This is the old stateful (D) COM model whereby the client receives a reference to the remote object and holds that reference (thus keeping the remote object alive) until it is finished with it.
35. How do I read from a text file?
First, use a System.IO.FileStream object to open the file:
FileStream fs = new FileStream( @"c:\test.txt", FileMode.Open, FileAccess.Read );
FileStream inherits from Stream, so you can wrap the FileStream object with a StreamReader object. This provides a nice interface for processing the stream line by line:
StreamReader sr = new StreamReader( fs );
string curLine;
while( (curLine = sr.ReadLine()) != null )
Console.WriteLine( curLine );
Finally close the StreamReader object:
sr.Close();
Note that this will automatically call Close() on the underlying Stream object, so an explicit fs.Close() is not required.
36. How do I write to a text file?
First, use a System.IO.FileStream object to open the file:
FileStream fs = new FileStream( @"c:\test.txt", FileMode.Open, FileAccess.Read );
FileStream inherits from Stream, so you can wrap the FileStream object with a StreamReader object. This provides a nice interface for processing the stream line by line:
StreamWriter sr = new StreamWriter ( fs );
string curLine;
while( (curLine = sr.ReadLine()) != null )
Console.WriteLine( curLine );
Finally close the StreamWriter object:
sr.Close();
Note that this will automatically call Close() on the underlying Stream object, so an explicit fs.Close() is not required.
37. How do I read/write binary files?
Similar to text files, except wrap the FileStream object with a BinaryReader/Writer object instead of a StreamReader/Writer object.
38. will dotnet supports regular expressions?
Yes . Using the class regex in the namespace System.Text. RegularExpressions.
39. Give me the Code to Export DataGrid to Excel in web application
Response.Clear();
Response.Buffer true;
Response.ContentType "application/vnd.ms-excel";
Response.AddHeader("Content-Disposition" "attachment;filename ReviewDesignation.xls");//This
lets you always open the Excel window when exporting whether you click on open or save.
Response.Charset "";
this.EnableViewState false;
System.IO.StringWriter oStringWriter new
System.IO.StringWriter();System.Web.UI.HtmlTextWriter oHtmlTextWriter
new System.Web.UI.HtmlTextWriter(oStringWriter);
this.ClearControls(dGrid);
dGrid.RenderControl(oHtmlTextWriter);
Response.Write(oStringWriter.ToString());
Response.End();
40. What debugging tools come with the .NET SDK?
1. CorDBG – command-line debugger. To use CorDbg, you must compile the original C# file using the /debug switch.
2. DbgCLR – graphic debugger. Visual Studio .NET uses the DbgCLR.
Tuesday, October 13, 2009
Asp.Net Interview Questions(31-40)
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment