Everyone knows about Assembly. But, very few knows about ILDASM tool, which is present in .NET Framework. ILDASM is nothing but Intermediate Language Disassembler. It is used to exploit any .NET dll or exe. By using this tool, we can see manifest,resources.....This tool is available in C:\WINNT\Microsoft.NET\Framework\v1.1.4322\. We can access this from VS.NET 2003 Command Prompt(present in VS Tools). Just drag any exe or dll onto that tool, to view its attributes. But, that tool won't show any conflicts occurs in referenced assemblies.
So, I created this Web application which will show Assembly attributes and Conflicts.
A conflict may occur, if referenced assembly is not present or problem in culture or version.
So, if a assembly has to be loaded successfully means, all referenced assemblies must be present with specified culture and version.
This application will show all referenced assemblies of an Assembly. It will also show conflicts present in referenced assemblies. We can even see attributes of referenced assembly.
I created this application in VS 2003 using C#.
First, create a web application in VS 2003 and name it as AssemblyViewer. Next, design UI as shown in below figure:
I placed a File control, to select an assembly. We can add a file control, by adding this to HTML:
<input id="fileuploader" style="Z-INDEX: 101; LEFT: 48px; POSITION: absolute; TOP: 56px" type="file" runat="server" NAME="fileuploader">
And add this attribute to form tag:
Next, to show Button in DataGrid, add this DataGrid tag in HTML view:
<asp:Button ID="button22" Runat="server" Text="View Details" Width="70"
Next place remaining labels and listbox controls on the page.
Next goto Page_load event and add this code there:
Label4.Text=string.Empty; This will clear all previous errors attributes of Selected Assembly(selected from Grid).
Next goto Click event of View Details and add this:
//To Get Selected Assembly Path...
//To Check for Extension .dll...
Literal1.Text="<b>"+"Select a Valid File Format with Extension .dll"+"</b>";
//To Store Selected assembly Name and Path...
string filepath =Path.GetDirectoryName(selectedfile);
Assembly assembly = Assembly.LoadFrom(selectedfile);
writer= new StreamWriter("c:\\assemblies.xml",false);
//To Get Attributes of each Referenced Assembly...
foreach (AssemblyName assemblynames in assembly.GetReferencedAssemblies())
//To Save Attributes of each Referenced Assembly in a Temporary xml file...
string assemblies = assemblynames.FullName.ToString().Split(',');
string assemblyname =assemblies;
string version =assemblies.ToString().Substring(assemblies.ToString().LastIndexOf('=')+1);
string culture =assemblies.ToString().Substring(assemblies.ToString().LastIndexOf('=')+1);
string publickeytoken =assemblies.ToString().Substring(assemblies.ToString().LastIndexOf('=')+1);
//To Show Attributes of each Referenced Assemblies in DataGrid...
DataSet ds=new DataSet();
//To catch Exception,if file is not in Valid Format...
Literal1.Text="<b>"+"The format of the file is invalid."+"</b>";
This will get attributes of each referenced assembly and save in xml file.Then, we are showing that data in DataGrid.
Next go to Click event of Show Conflicts and add this code as shown in below figure:
This will see for any conflicts in version or file missing for Selected Assembly(selected from file control), and will display error list and markers for that conflict assemblies in DataGrid.
Finally go to DataGrid DataGrid1_ItemCommand event and add this code as shown below:
This will show attributes of Selected Assembly(selected from Grid).
Final screen, will be like this:
This screen will show conflicts as red mark and description.
This application will show errror messages, if referenced assembly is missing or any mismatch in version. We can extend this ,to show culture conflicts also.
This application assumes selected assembly and its referenced assemblies are in same folder.
By using this application, we can see an assembly attributes and conflicts.
I am attaching code for reference.
I hope this will be useful for all.