Before talking about Property in C# I want to tell you about other mechanism that can also use in place of Properties- Continue reading
Before writing about Delegates I would like to introduce you about the problems that we are facing before delegate come in existence.
Heavy Coupling- Heavy coupling between method declaration and definition creates Continue reading
.Net Data Types-
. Net Data Types can be classified in 3 categories –
1. Any data- byte, char, string
2. Numeric data- Continue reading
GAC-Global Assembly Cache is where all shared .NET assembly reside.
GAC is used in the following situations-
1. If the assembly has to be shared among several application which are in the same computer.
2. If the assembly has some special security, requirements like only administrator can remove the assembly. If the assembly is private for program then a simple delete of assembly can delete the assembly file.
Our all share assembly is located in “c:\WINDOWS\assembly\” where we can also see the version and public key token of assembly.
To register any assembly in GAC we have to follow bellow steps-
1. Assign strong name to Assembly
2. Copy the Assembly in another location (like d:\Commondll\) and then register the dll in GAC by 2 ways. First way-
I. Go to Visual studio command prompt
II. Go to d:\Commondll\ (where our Assembly is copied)
III. Just type- gacutil -i common.dll
Just drag and drop common.dll file from source to “c:\WINDOWS\assembly\”
Note- We can cross check by search the common.dll in “c:\WINDOWS\assembly\”
Now to use common.dll registered in GAC we have to add reference in windows application from “d:\Commondll\common.dll” and then use common namespace in windows application and now we can use all methods of common.dll in our windows application.
After compilation we will move the windowapplication.exe to “d:\Commondll\” and we can see the .exe running properly because it’s linked with common.dll register in GAC and reside in the same folder.
To create a new version of .dll file in GAC go to Properties->AssemblyInfo.cs in Common class library and update the assembly version- [assembly: Assemblyversion(“220.127.116.11”)] and then after build the application lets register this assembly in GAC.
To change the pointing dll by any application-
1. Go to Administrative Tools->Microsoft .NET Framework 2.0 Configuration
2. Right click on Applications in the left hand side tree structure and add windowapplication
3. Select windowapplication after it will add to Applications and click on “Managed Configured Assemblies” then “Configure an Assembly”-> “Choose an assembly from the assembly cache”-> click on “Choose Assembly” and then choose Common which has version 18.104.22.168 and click on Finish.
4. As we click on finish we will get new popup which has Binding Policy tab and enter 22.214.171.124 in Requested Version and 126.96.36.199 in New Version. It creates windowapplication.exe.config file which will redirect the control to new version when it calls for old version.
Delay Signing helps us to prevent our application from our own developers. Because our developer knows everything about our application, they know strong key file, dll name, function name etc so they can easily take the strong key file and can place a fake dll, that’s where Delay Signing comes into picture.
Structure of Strong Key-
When we create a Strong Key there are 2 parts to it-
- Public Key
- Private Key
So we have to share only Public Strong Key with the internal developers and when we want to deploy the application at that time we have to add the Private Strong Key and do the deployment.
We can understand the whole concept of Delay Signing by a Strong Key creation-
To create a Strong Key we have to open “Visual Studio Command Prompt”
- Go to the desired location where you want to create Strong Name Key file. (for example D:\Akash\Study\Projects\Windows Application\Strong Name)
- Type- sn -k MyStrongName.snk. This command created a Strong Name Key file in desired location. This key hold both public as well as private key.
- In order to extract Public Strong Name Key from above Strong Name Key file Type-
sn -p MyStrongName.snk MyStrongNamePublic.snk
- Now we can give the MyStrongNamePublic.snk file to our internal developers for development and store the MyStrongName.snk file in a secured location and will use this at the time of deployment. REMEMBER A POINT when we using delay signing concept we have to check the check box “Delay sign only” at the time of Public Strong Name Kay file assignment.
- At the time of deployment we have to assign the secured Strong Name Key file to the dll so to do this we have to go to the location where the secured Strong Name Key file stored, Type-
sn –R ClassLibrary1.dll MyStrongName.snk
We can understand weak reference and strong reference with the help of a windows application which have 1 windows project file and 1 class library. Continue reading
Destructor/Finalize can be used to Clean up unmanaged code, but if we use destructor in our .Net application then the number of objects appearing in Gen 1 and Gen 2 is higher than no of objects in Gen 0. Continue reading