Archive

Archive for the ‘.NET’ Category

.NET Deployment questions

.NET Deployment questions

What do you know about .NET assemblies?
Assemblies are the smallest units of versioning and deployment in the .NET application. Assemblies are also the building blocks for programs such as Web services, Windows services, serviced components, and .NET remoting applications.

What’s the difference between private and shared assembly? Private assembly is used inside an application only and does not have to be identified by a strong name. Shared assembly can be used by multiple applications and has to have a strong name.

What’s a strong name? A strong name includes the name of the assembly, version number, culture identity, and a public key token.

How can you tell the application to look for assemblies at the locations other than its own install? Use the
directive in the XML .config file for a given application.

Categories: .NET Tags:

C# developer interview questions

C# developer interview questions

A representative of a high-tech company in United Kingdom sent this in today noting that the list was used for interviewing a C# .NET developer. Any corrections and suggestions would be forwarded to the author. I won’t disclose the name of the company, since as far as I know they might still be using this test for prospective employees. Correct answers are in green color.

1) The C# keyword ‘int’ maps to which .NET type?

System.Int16

System.Int32

System.Int64

System.Int128

2) Which of these string definitions will prevent escaping on backslashes in C#?

string s = #”n Test string”;

string s = “’n Test string”;

string s = @”n Test string”;

string s = “n Test string”;

3) Which of these statements correctly declares a two-dimensional array in C#?

int[,] myArray;

int[][] myArray;

int[2] myArray;

System.Array[2] myArray;

4) If a method is marked as protected internal who can access it?

Classes that are both in the same assembly and derived from the declaring class.

Only methods that are in the same class as the method in question. Read more…

Categories: .NET Tags:

COM/COM+ services and components in .NET

COM/COM+ services and components in .NET

Explain transaction atomicity. We must ensure that the entire transaction is either committed or rolled back.

Explain consistency. We must ensure that the system is always left at the correct state in case of the failure or success of a transaction.

Explain integrity. Ensure data integrity by protecting concurrent transactions from seeing or being adversely affected by each other’s partial and uncommitted results.

Explain durability. Make sure that the system can return to its original state in case of a failure.

Explain object pooling. With object pooling, COM+ creates objects and keeps them in a pool, where they are ready to be used when the next client makes a request. This improves the performance of a server application that hosts the objects that are frequently used but are expensive to create.

Explain JIT activation. The objective of JIT activation is to minimize the amount of time for which an object lives and consumes resources on the server. With JIT activation, the client can hold a reference to an object on the server for a long time, but the server creates the object only when the client calls a method on the object. After the method call is completed, the object is freed and its memory is reclaimed. JIT activation enables applications to scale up as the number of users increases.

Explain role-based security. In the role-based security model, access to parts of an application are granted or denied based on the role to which the callers belong. A role defines which members of a Windows domain are allowed to work with what components, methods, or interfaces. Read more…

Categories: .NET Tags:

Windows code security questions

Windows code security questions

What’s the difference between code-based security and role-based security? Which one is better? Code security is the approach of using permissions and permission sets for a given code to run. The admin, for example, can disable running executables off the Internet or restrict access to corporate database to only few applications. Role-based security most of the time involves the code running with the privileges of the current user. This way the code cannot supposedly do more harm than mess up a single user account. There’s no better, or 100% thumbs-up approach, depending on the nature of deployment, both code-based and role-based security could be implemented to an extent.

How can you work with permissions from your .NET application? You can request permission to do something and you can demand certain permissions from other apps. You can also refuse permissions so that your app is not inadvertently used to destroy some data.

How can C# app request minimum permissions?

using System.Security.Permissions;
[assembly:FileDialogPermissionAttribute(SecurityAction.RequestMinimum, Unrestricted=true)]
What’s a code group? A code group is a set of assemblies that share a security context. Read more…

Categories: .NET Tags:

Interview questions for ASP

Interview questions for ASP

Used by IBM Consulting Services, according to the site visitor.
How many objects are there in ASP?
Which DLL file is needed to be registered for ASP?
If you want to initialize a global variable for an application, which is the right place to declare it? (like form or some other file).
What is diffrence between Server.transfer and Response.redirect.
Is there any inbuilt paging(for example shoping cart. which will show next 10 records without refreshing) in ASP? How will you do pating.
What does Server.MapPath do?
Name at least three methods of response object other than Redirect.
Name at least two methods of response object other than Transfer.
Tell few programming diffrence between ADO and DAO programming. What is state?
How many types of cookies are there?
Tell few steps for optimizing (for speed and resources) ASP page/application .

Categories: .NET Tags:

Interview questions for MS SQL Server

Interview questions for MS SQL Server

This one always gets asked. For a while the database interview questions were limited to Oracle and generic database design questions. This is a set of more than a hundred Microsoft SQL Server interview questions. Some questions are open-ended, and some do not have answers.

What is normalization? – Well a relational database is basically composed of tables that contain related data. So the Process of organizing this data into tables is actually referred to as normalization.

What is a Stored Procedure? – Its nothing but a set of T-SQL statements combined to perform a single task of several tasks. Its basically like a Macro so when you invoke the Stored procedure, you actually run a set of statements.

Can you give an example of Stored Procedure? – sp_helpdb , sp_who2, sp_renamedb are a set of system defined stored procedures. We can also have user defined stored procedures which can be called in similar way.

What is a trigger? – Triggers are basically used to implement business rules. Triggers is also similar to stored procedures. The difference is that it can be activated when data is added or edited or deleted from a table in a database.

What is a view? – If we have several tables in a db and we want to view only specific columns from specific tables we can go for views. It would also suffice the needs of security some times allowing specfic users to see only specific columns based on the permission that we can configure on the view. Views also reduce the effort that is required for writing queries to access specific columns every time. Read more…

Categories: .NET Tags:

ASP.NET questions, part 1

ASP.NET questions, part 1

Explain the differences between Server-side and Client-side code? Server side scripting means that all the script will be executed by the server and interpreted as needed. ASP doesn’t have some of the functionality like sockets, uploading, etc. For these you have to make a custom components usually in VB or VC++. Client side scripting means that the script will be executed immediately in the browser such as form field validation, clock, email validation, etc. Client side scripting is usually done in VBScript or JavaScript. Download time, browser compatibility, and visible code – since JavaScript and VBScript code is included in the HTML page, then anyone can see the code by viewing the page source. Also a possible security hazards for the client computer.

What type of code (server or client) is found in a Code-Behind class? C#

Should validation (did the user enter a real date) occur server-side or client-side? Why? Client-side validation because there is no need to request a server side date when you could obtain a date from the client machine.

What does the “EnableViewState” property do? Why would I want it on or off? Enable ViewState turns on the automatic state management feature that enables server controls to re-populate their values on a round trip without requiring you to write any code. This feature is not free however, since the state of a control is passed to and from the server in a hidden form field. You should be aware of when ViewState is helping you and when it is not. For example, if you are binding a control to data on every round trip (as in the datagrid example in tip #4), then you do not need the control to maintain it’s view state, since you will wipe out any re-populated data in any case. ViewState is enabled for all server controls by default. To disable it, set the EnableViewState property of the control to false. Read more…

Categories: .NET Tags:

.NET and COM interop questions

.NET and COM interop questions

Describe the advantages of writing a managed code application instead of unmanaged one. What’s involved in certain piece of code being managed? The advantages include automatic garbage collection, memory management, support for versioning and security. These advantages are provided through .NET FCL and CLR, while with the unmanaged code similar capabilities had to be implemented through third-party libraries or as a part of the application itself.

Are COM objects managed or unmanaged? Since COM objects were written before .NET, apparently they are unmanaged.

So can a COM object talk to a .NET object? Yes, through Runtime Callable Wrapper (RCW) or PInvoke.
How do you generate an RCW from a COM object? Use the Type Library Import utility shipped with SDK. tlbimp COMobject.dll /out:.NETobject.dll or reference the COM library from Visual Studio in your project.

I can’t import the COM object that I have on my machine. Did you write that object? You can only import your own objects. If you need to use a COM component from another developer, you should obtain a Primary Interop Assembly (PIA) from whoever authored the original object.

How do you call unmanaged methods from your .NET code through PInvoke? Supply a DllImport attribute. Declare the methods in your .NET code as static extern. Do not implement the methods as they are implemented in your unmanaged code, you’re just providing declarations for method signatures. Read more…

Categories: .NET Tags:

ASP.NET DataGrid questions

ASP.NET DataGrid questions

What is datagrid? The DataGrid Web server control is a powerful tool for displaying information from a data source. It is easy to use; you can display editable data in a professional-looking grid by setting only a few properties. At the same time, the grid has a sophisticated object model that provides you with great flexibility in how you display the data.

What’s the difference between the System.Web.UI.WebControls.DataGrid and and System.Windows.Forms.DataGrid? The Web UI control does not inherently support master-detail data structures. As with other Web server controls, it does not support two-way data binding. If you want to update data, you must write code to do this yourself. You can only edit one row at a time. It does not inherently support sorting, although it raises events you can handle in order to sort the grid contents. You can bind the Web Forms DataGrid to any object that supports the IEnumerable interface. The Web Forms DataGrid control supports paging. It is easy to customize the appearance and layout of the Web Forms DataGrid control as compared to the Windows Forms one.

How do you customize the column content inside the datagrid? If you want to customize the content of a column, make the column a template column. Template columns work like item templates in the DataList or Repeater control, except that you are defining the layout of a column rather than a row.

How do you apply specific formatting to the data inside the cells? You cannot specify formatting for columns generated when the grid’s AutoGenerateColumns property is set to true, only for bound or template columns. To format, set the column’s DataFormatString property to a string-formatting expression suitable for the data type of the data you are formatting. Read more…

Categories: .NET Tags:

ASP.NET questions, part 2

ASP.NET questions, part 2

Whats an assembly? Assemblies are the building blocks of .NET Framework applications; they form the fundamental unit of deployment, version control, reuse, activation scoping, and security permissions. An assembly is a collection of types and resources that are built to work together and form a logical unit of functionality. An assembly provides the common language runtime with the information it needs to be aware of type implementations. To the runtime, a type does not exist outside the context of an assembly.

Describe the difference between inline and code behind - which is best in a loosely coupled solution? ASP.NET supports two modes of page development: Page logic code that is written inside

Categories: .NET Tags:

Interview questions for C# developers

Interview questions for C# developers

Useful for preparation, but too specific to be used in the interview.
Is it possible to inline assembly or IL in C# code? – No.

Is it possible to have different access modifiers on the get/set methods of a property? – No. The access modifier on a property applies to both its get and set accessors. What you need to do if you want them to be different is make the property read-only (by only providing a get accessor) and create a private/internal set method that is separate from the property.

Is it possible to have a static indexer in C#? – No. Static indexers are not allowed in C#.

If I return out of a try/finally in C#, does the code in the finally-clause run? – Yes. The code in the finally always runs. If you return out of the try block, or even if you do a “goto” out of the try, the finally block always runs:

using System;

class main
{
public static void Main()
{
try
{
Console.WriteLine(“In Try block”);
return;
}
finally
{
Console.WriteLine(“In Finally block”);
}
}
}

Both “In Try block” and “In Finally block” will be displayed. Whether the return is in the try block or after the try-finally block, performance is not affected either way. The compiler treats it as if the return were outside the try block anyway. If it’s a return without an expression (as it is above), the IL emitted is identical whether the return is inside or outside of the try. If the return has an expression, there’s an extra store/load of the value of the expression (since it has to be computed within the try block).

I was trying to use an “out int” parameter in one of my functions. How should I declare the variable that I am passing to it? - You should declare the variable as an int, but when you pass it in you must specify it as ‘out’, like the following: int i; foo(out i); where foo is declared as follows: [return-type] foo(out int o) { } Read more…

Categories: .NET Tags:

C# .NET interview questions

C# .NET interview questions

Good for preparation and general self-testing, but too specific for the actual job interview. This was sent in by a job applicant getting ready to step into the .NET field in India.

Are private class-level variables inherited? – Yes, but they are not accessible, so looking at it you can honestly say that they are not inherited. But they are.

Why does DllImport not work for me? – All methods marked with the DllImport attribute must be marked as public static extern.

Why does my Windows application pop up a console window every time I run it? – Make sure that the target type set in the project properties setting is set to Windows Application, and not Console Application. If you’re using the command line, compile with /target:winexe, not /target:exe.

Why do I get an error (CS1006) when trying to declare a method without specifying a return type? – If you leave off the return type on a method declaration, the compiler thinks you are trying to declare a constructor. So if you are trying to declare a method that returns nothing, use void. The following is an example: // This results in a CS1006 error public static staticMethod (mainStatic obj) // This will work as wanted public static void staticMethod (mainStatic obj)

Why do I get a syntax error when trying to declare a variable called checked? – The word checked is a keyword in C#. Read more…

Categories: .NET Tags:

Interview questions for Web application developers

Interview questions for Web application developers

What is the maximum length of a varchar field in SQL Server?
How do you define an integer in SQL Server?
How do you separate business logic while creating an ASP.NET application?
If there is a calendar control to be included in each page of your application, and we do not intend to use the Microsoft-provided calendar control, how do you develop it? Do you copy and paste the code into each and very page of your application?
How do you debug an ASP.NET application?
How do you deploy an ASP.NET application?
Name a few differences between .NET application and a Java application?
Specify the best ways to store variables so that we can access them in various pages of ASP.NET application?
What are the XML files that are important in developing an ASP.NET application?
What is XSLT and what is its use?

Categories: .NET Tags: