Saswati's profileSaswati's spacePhotosBlogLists Tools Help

Saswati's space

No list items have been added yet.

Check the details of your Operating System from registry location

 

You will find your Operating system details from the following registry location

 

HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\CSDVersion

How to sign an executable file

 

Before signing an executable file you need to create the files using which you can sign an exe in shot certification keys.

First create a folder where you want to save your certification keys. Suppose it is myfolder.

Now open the .net framework command prompt and write the following command in the command prompt. Make sure that you have installed .net framework 2.0 because this MakeCert.exe comes with .net framework 2.0.

 

Makecert –sv [filename.pvk] [filename.cer]

 

for example,

 

Makecert –sv privatekey.pvk certificationkey.cer

 

Once you enter you will see the following window.

image

If you want to protect your .pvk file with the password then you can provide that else don’t.

Once you succeeded you will find your .cer and .pvk file in myfolder.

Now you need to generate a .spc file against you .pvk file. You can do it by using the following command

 

Cert2spc [filename.spc] [filename.cer]

 

for example,

 

Cert2spc myspcfile.spc certificationkey.cer

 

You will find your .spc file in myfolder .

So you have generated the files. Now you can go ahead and sign you executables.

You can use the signtool.exe to sign your executables.

To run the signtool wizard you need to write the following command in the command prompt.

 

Signtool signwizard

 

You will see the wizard as follows

image

Now one question can arise how we can see what is there inside a certificate. We can see the certificate details by the following command,

 

certutil -f -urlfetch –verify [filename]

 

for example,

 

certutil -f -urlfetch –verify certificationkey.cer

 

You can find the information as follows

image

How to add an assembly in Global Assembly Cache in short GAC

Before adding my DLL in GAC I need to create a strong name for my assembly.

For Visual Studio 2005 the steps are as follows:

Goto the signing property =>check “Sign the assembly” check box =>select “New” from the “Choose a strong name key file” drop down box =>provide the key file name and then click “ok”

Done. I got a strong name i.e. a file with a .shk extension against my assembly.

After creating a strong name I am ready to add my assembly into the GAC.

For Vista I have to open the Visual Studio Command prompt with the admin privilege. Nothing but rclick Run as Administrator.

Now goto the same folder where you have your assembly then type the following command

gacutil /if ClassLibrary1.dll

Switch /i is also can be used.

Some reference links are

http://msdn.microsoft.com/en-us/library/ex0ss12c(VS.80).aspx.

http://msdn.microsoft.com/en-us/library/dkkx7f79(VS.71).aspx

C# default keyword

Today we will talk about default keyword which is a cool C# 2.0 feature.

Let’s focus on the following peace of code:

image

Here, we are adding items in a list. Now as you all know by using Generics we can create a list of items but we don’t need to define the type of the list. While calling the list we can mention which type of list it is.

So here, the type T might not be known at compile time or when the program is written. T can be either a value type or can be a reference type. Now this makes it difficult to specify how we can initialised the variable temp.

If we set temp as null and if T is a value type then, this will be an illegal assignment (you cannot set value types to null, only reference types can be null).

Similarly, if you set temp to 0 in the expectation that the T will be numeric, then this will be illegal if the type used is actually a reference type.

For example T can be a boolean type also.

To solve this kind of problems we can use default keyword.

It can be added to the above code in the following way.

image

 

Here the value used to initialize the variable will be determined when the statement is executed; if T is a reference type default(T) returns null, if T is numeric, default(T) returns 0, and if T is a boolean, default(T) returns false. If T is a struct, the individual fields in the struct are initialized in the same way (reference fields are set to null, numeric fields are set to 0, and boolean fields are set to false.)

 

Reference links are

http://weblogs.asp.net/avnerk/archive/2006/05/21/Non_2D00_generic-default-values-in-C_23003F00_-Why-not_3F002100_.aspx

http://bartdesmet.net/blogs/bart/archive/2005/12/03/3791.aspx

http://www.c-sharpcorner.com/UploadFile/akrao/CSharp2.0CoreFeatures11102005060812AM/CSharp2.0CoreFeatures.aspx

Vista Certification

Friends if you want to certify your product for Vista, please visit

http://www.innovateon.com/product_vista.aspx

C# Delegate

Yesterday I have studied C# Delegate and I was thinking where can I write my knowledge for the future reference.

Suddenly this blogging thing came into my mind and today I am writing my first blog . It's a cool thing and I like it rather than the note book and pen.

So now let see what is Delegate??

C and C++ programmer must have an idea about function pointer. Delegate is quite similar to that.

Using delegate you can encapsulate a method reference inside a delegate object.

An interesting and useful feature of a Delegate is that it doesn’t care about the class of the object that it references. The only think you need to take care are the method’s argument type and the return type should match with the delegate. This makes delegates perfectly suited for "anonymous" invocation.

Generally the structure of a delegate looks like this

delegate result-type identifier ([parameters]);

where:

· Result-type: The result type, which matches the return type of the function.

· Identifier: The delegate name.

· Parameters: The Parameters that the function takes.

Let see what are ways we can create a delegate.

1st way

image

===========================

Note: we can also write the above code in the following way.

 

image

And in both the cases the output will the be same. That is the beauty of Delegate that it doesn’t depend on which class object it is referring.

2nd way

image

I found http://www.akadia.com/services/dotnet_delegates_and_events.html is very useful.

 
List of my fav blogs

Saswati

Photo 1 of 16
More albums (1)