02.07.2013 Views

.NET Interview Questions 4 th Edition By Shivprasad ... - A2Z Dotnet

.NET Interview Questions 4 th Edition By Shivprasad ... - A2Z Dotnet

.NET Interview Questions 4 th Edition By Shivprasad ... - A2Z Dotnet

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Now when we view <strong>th</strong>e GAC we can see two version of “ClassLibraryVersion” i.e.<br />

“1.1.1832.2619” and “1.0.1832.2172” (see figure below).<br />

Figure 1.16: - Two version of “ClassLibraryVersion” dll.<br />

Now <strong>th</strong>at we have created <strong>th</strong>e environment of two version of <strong>th</strong>e same DLL in GAC its time to<br />

look at how client can make a choice between <strong>th</strong>ose versions. We need to generate<br />

“publicKeyToken” in order to move ahead. Below is a sample print screen, which shows how we<br />

can use “sn.exe” to generated <strong>th</strong>e public key token. Note <strong>th</strong>e “-T” parameter.<br />

Figure 1.17: - Get <strong>th</strong>e PublicKeyToken<br />

Now let us look at <strong>th</strong>e client <strong>th</strong>at will consume <strong>th</strong>is DLL. I have just added windows form and a<br />

button to <strong>th</strong>e same. In <strong>th</strong>e button click, we will try to call <strong>th</strong>e version function and display <strong>th</strong>e<br />

data. Therefore, below is <strong>th</strong>e code in <strong>th</strong>e first step we create <strong>th</strong>e object of<br />

“ClassLibraryVersion.Class1” and in <strong>th</strong>e second step we call <strong>th</strong>e “Version” function to display<br />

<strong>th</strong>e data.<br />

Figure 1.18: - Client code calling <strong>th</strong>e GAC class.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!