Thursday, April 19, 2007
What are the different types of Asp.Net Session States?
Posted by Don at 5:34 AM 0 comments
if you use xml formatter to serialize an object, would the private properties be serialized? What happens when you use a binary formatter?
XML Formatter does not serialize private properties. Serialization is the process of storing the state of an object into a persistence storage media and private properties are not serialized. Serialization has nothing to do with Private Properties.
When using Binary formatter, the private properties are serialized. Since it is a binary formatter, it just writes everything it reads from the object into the persistent storage media. Hence the private variables would also be persisted. But logically they should not be and using an XML Formatter is more advisable.
Posted by Don at 3:26 AM 0 comments
What is an assembly?
An assembly is the primary building block of a .NET Framework application. It is a collection of functionality that is built, versioned, and deployed as a single implementation unit (as one or more files). All managed types and resources are marked either as accessible only within their implementation unit, or as accessible by code outside that unit.
Assemblies are self-describing by means of their manifest, which is an integral part of every assembly. The manifest:
Establishes the assembly identity (in the form of a text name), version, culture, and digital signature (if the assembly is to be shared across applications).
Defines what files (by name and file hash) make up the assembly implementation.
Specifies the types and resources that make up the assembly, including which are exported from the assembly.
Itemizes the compile-time dependencies on other assemblies.
Specifies the set of permissions required for the assembly to run properly.
This information is used at run time to resolve references, enforce version binding policy, and validate the integrity of loaded assemblies. The runtime can determine and locate the assembly for any running object, since every type is loaded in the context of an assembly. Assemblies are also the unit at which code access security permissions are applied. The identity evidence for each assembly is considered separately when determining what permissions to grant the code it contains.
The self-describing nature of assemblies also helps makes zero-impact install and XCOPY deployment feasible.
Posted by Don at 3:18 AM 0 comments
How can I see what assemblies are installed in the global assembly cache?
The .NET Framework ships with a Windows shell extension for viewing the assembly cache. Navigating to % windir%\assembly with the Windows Explorer activates the viewer.
Posted by Don at 3:08 AM 0 comments
What is the difference between Aggregation and Composition
As Robert C. Martin Explains it:
Association represents the ability of one instance to send a message to another instance. This is typically implemented with a pointer or reference instance variable, although it might also be implemented as a method argument, or the creation of a local variable.
[Example:]
|A|----------->|B|
class A
{
private:
B* itsB;
};
Aggregation [...] is the typical whole/part relationship. This is exactly the same as an association with the exception that instances cannot have cyclic aggregation relationships (i.e. a part cannot contain its whole).
[Example:]
|Node|<>-------->|Node|
class Node
{
private:
vector
};
The fact that this is aggregation means that the instances of Node cannot form a cycle. Thus, this is a Tree of Nodes not a graph of Nodes.
Composition [...] is exactly like Aggregation except that the lifetime of the 'part' is controlled by the 'whole'. This control may be direct or transitive. That is, the 'whole' may take direct responsibility for creating or destroying the 'part', or it may accept an already created part, and later pass it on to some other whole that assumes responsibility for it.
[Example:]
|Car|<#>-------->|Carburetor|
class Car
{
public:
virtual ~Car() {delete itsCarb;}
private:
Carburetor* itsCarb
};
Posted by Don at 3:06 AM 0 comments
How do you modify Code Access Security Policy?
The Code Access Security Policy tool enables users and administrators to modify security policy for the machine policy level, the user policy level, and the enterprise policy level.
http://msdn2.microsoft.com/en-us/library/cb6t8dtz(VS.80).aspx
Posted by Don at 2:39 AM 0 comments
What would you have to do to implement an asynchronous Web service method
-
Split a synchronous Web service method into two methods, each with the same base name, one with that name starting with Begin and the other End.
-
The parameter list for the Begin method contains all the in and by reference parameters for the method's functionality plus two additional parameters.
-
By reference parameters are listed as in parameters.
-
The second from the last parameter must be an AsyncCallback. The AsyncCallback parameter allows a client to supply a delegate, which is invoked when the method completes. When an asynchronous Web service method calls another asynchronous method, this parameter can be passed into the second from last parameter for that method.
-
The last parameter is an Object. The Object parameter allows a caller to supply state information to the method. When an asynchronous Web service method calls another asynchronous method, this parameter can be passed into the last parameter for that method.
-
The return value must be of type IAsyncResult.
-
-
The parameter list for the End method consists of an IAsyncResult followed by any out and by reference parameters specific to the method's functionality.
-
The return value is the same type as the return value of a synchronous Web service method.
-
By reference parameters are listed as out parameters.
-
Example
using System;
using System.Web.Services;
[WebService(Namespace="http://www.contoso.com/")]
public class MyService : WebService
{
public RemoteService remoteService;
public MyService()
{
// Create a new instance of proxy class for
// the Web service to be called.
remoteService = new RemoteService();
}
// Define the Begin method.
[WebMethod]
public IAsyncResult BeginGetAuthorRoyalties(String Author,
AsyncCallback callback, object asyncState)
{
// Begin asynchronous communictation with a different XML Web
// service.
return remoteService.BeginReturnedStronglyTypedDS(Author,
callback,asyncState);
}
// Define the End method.
[WebMethod]
public AuthorRoyalties EndGetAuthorRoyalties(IAsyncResult
asyncResult)
{
// Return the asynchronous result from the other Web service.
return remoteService.EndReturnedStronglyTypedDS(asyncResult);
}
}
Posted by Don at 12:12 AM 0 comments
Wednesday, April 18, 2007
Interface Inheritance
Is interface inheritance possible? Why is it required? why wouldn't I implement 2 interfaces instead of doing an interface inheritance?
Ans: Suppose there is a class that I want to function as a Bank Account. Now there are 5 classes that are 5 different types of Bank Accounts which have a function CalculateInterest(). I would define an interface called IBankAccount Interface and implement this interface in my 5 classes to make them BankAccounts. Now I want one bank account to do something special. It should contain all the existing functions of a normal bank account and should specialize in something.
So I would create a new Interface say, ISpecialBankAccount and inherit it from IBankAccount. Now in my special class I would implement ISpecialBankAccount.
Now I can omit the inheritance of interfaces and implement both these interfaces. And from the code perspective it would be the same thing. But when I am breaking the rules of OO. From a design perspective it would make more logical sense. because ISpecialBankAccount would contain all the functions of the IBankAccount interface and it would add special functionality to it.
So Implementing ISpecialBankAccount in our special class would keep the existing bank account as they are and would also have special features of the ISpecialBankAccount.
Posted by Don at 10:57 PM 0 comments