Blue Theme Orange Theme Green Theme Red Theme
 
Dundas Dashboard
Home | Forums | Videos | Photos | Downloads | Blogs | E-Books | Interviews | Jobs | Beginners | Training
 | Consulting  
Submit an Article Submit a Blog 
 Login Close
User Id:
Password:
 
Forgot Password
Forgot Username
Why Register
 Jump to
Skip Navigation Links
TechnologyExpand Technology
WebsiteExpand Website
Dundas Dashboard
 Resources  
Close
 Our Network  
Close
Search :       Advanced Search »
Home » ASP.NET & Web Forms » Assembly Viewer and Assembly Conflict Viewer in ASP.NET

Assembly Viewer and Assembly Conflict Viewer in ASP.NET

This article show how to view assembly attributes and conflicts in ASP.NET page using C#.

Technologies: .NET 1.0/1.1, ASP.NET 1.0,Visual C# .NET
Total downloads : 95
Total page views :  9054
Rating :
 0/5
This article has been rated :  0 times
   Print Read/Post comments Post a comment  Rate  
   Email to a friend  Bookmark  Similar Articles  Author's other articles  
Download Files:
AssemblyViewer.zip
 
Become a Sponsor


Related EbooksTop Videos

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:

encType="multipart/form-data"

Next, to show Button in DataGrid, add this DataGrid tag in HTML view:

<Columns>

   <asp:TemplateColumn>

      <ItemTemplate>

         <asp:Button ID="button22" Runat="server" Text="View Details" Width="70"

         CommandName="ShowDetails"></asp:Button>

      </ItemTemplate>

   </asp:TemplateColumn>

</Columns>

Next place remaining labels and listbox controls on the page.

Next goto Page_load event and add this code there:

ListBox1.Items.Clear();

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:
  

try

{

          //To Get Selected Assembly Path...

          string FileExt=fileuploader.PostedFile.FileName.Substring(fileuploader.PostedFile.FileName.LastIndexOf(".")+1);

          //To Check for Extension .dll...

          if(FileExt.ToLower()!="dll")

          {

                   Literal1.Text="<b>"+"Select a Valid File Format with Extension .dll"+"</b>";

                   return;

          }

          //To Store Selected assembly Name and Path...

          string selectedfile=fileuploader.PostedFile.FileName.ToString();

          string filepath    =Path.GetDirectoryName(selectedfile);

          Assembly assembly = Assembly.LoadFrom(selectedfile);

          Label2.Text =Path.GetFileName(fileuploader.PostedFile.FileName);

          assemblypath.Text =assembly.Location;

          StreamWriter writer;

          writer= new StreamWriter("c:\\assemblies.xml",false);

          writer.Write("<?xml version=\"1.0\"?>");

          writer.Write("<assemblies>");

          //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(',');

                   writer.Write("<assembly>");   

                   string assemblyname =assemblies[0];

                   string version =assemblies[1].ToString().Substring(assemblies[1].ToString().LastIndexOf('=')+1);

                   string culture =assemblies[2].ToString().Substring(assemblies[1].ToString().LastIndexOf('=')+1);

                   string publickeytoken =assemblies[3].ToString().Substring(assemblies[3].ToString().LastIndexOf('=')+1);

                    writer.Write("<assemblyname>"+assemblyname+"</assemblyname>");

                    writer.Write("<version>"+version+"</version>");

                    writer.Write("<culture>"+culture+"</culture>");

                    writer.Write("<publickeytoken>"+publickeytoken+"</publickeytoken>");

                    writer.Write("</assembly>");

          }

          writer.Flush();

          writer.Close();

          File.Copy("c:\\assemblies.xml","c:\\temp1.xml",true);

          StreamWriter writer1=File.AppendText("c:\\temp1.xml");

          writer1.Write("</assemblies>");

          writer1.Close();

          //To Show  Attributes of each Referenced Assemblies in DataGrid...

          DataSet ds=new DataSet();

          ds.ReadXml("c:\\temp1.xml");

          DataGrid1.DataSource=ds;

          DataGrid1.DataBind();

          File.Delete("c:\\assemblies.xml");

          File.Delete("c:\\temp1.xml");

}

catch(Exception ex)

{

          //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.


Login to add your contents and source code to this article
 [Top] Rate this article
 About the author
 
Satish Arveti
Looking for C# Consulting?
C# Consulting is founded in 2002 by the founders of C# Corner. Unlike a traditional consulting company, our consultants are well-known experts in .NET and many of them are MVPs, authors, and trainers. We specialize in Microsoft .NET development and utilize Agile Development and Extreme Programming practices to provide fast pace quick turnaround results. Our software development model is a mix of Agile Development, traditional SDLC, and Waterfall models.
Click here to learn more about C# Consulting.
 
Introducing MaxV - one click. infinite control. Hyper-V Hosting from MaximumASP.
Finally – a virtual platform that delivers next-generation Windows Server 2008 Hyper-V virtualization technology from a managed hosting partner you can truly depend on. Visit www.maximumasp.com/max for a FREE 30 day trial. Hurry offer ends soon. Climb aboard the MaxV platform and take advantage of High Availability, Intelligent Monitoring, Recurrent Backups, and Scalability – with no hassle or hidden fees. As a managed hosting partner focused solely on Microsoft technologies since 2000, MaximumASP is uniquely qualified to provide the superior support that our business is built on. Unparalleled expertise with Microsoft technologies lead to working directly with Microsoft as first to offer IIS 7 and SQL 2008 betas in a hosted environment; partnering in the Go Live Program for Hyper-V; and product co-launches built on WS 2008 with Hyper-V technology.
Dynamic PDF
ceTE software specializes in components for dynamic PDF generation and manipulation. The DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and new content to existing PDF documents from within your applications.
Go.NET
Build custom interactive diagrams, network, workflow editors, flowcharts, or software design tools. Includes many predefined kinds of nodes, links, and basic shapes. Supports layers, scrolling, zooming, selection, drag-and-drop, clipboard, in-place editing, tooltips, grids, printing, overview window, palette. 100% implemented in C# as a managed .NET Control. Document/View/Tool architecture with many properties&events. Optional automatic layout.
Dundas Software
Dundas Chart for .NET is the most advanced .NET charting package available today.  With an extremely complete feature set, elegant architecture and easy implementation, Dundas Chart can quickly add advanced Charting functionality to enhance and transform ASP.NET and Windows Forms applications.  Whether you are implementing charting into internal projects, or building applications for clients, Dundas Chart offers advanced technology and advanced results to get the most out of data.
Clickatell's SMS Gateway
Clickatell's Developer Solutions allow you to SMS enable any website or application via a range of API's. Learn More about our API connections.
Free access to .NET Memory Management video
Everything you need to know about Garbage Collection, Temporary Objects, Fragmentation, Finalization and common causes of memory leaks in .NET. Watch the video here.
Microsoft Visual Studio 2010
Microsoft Visual Studio 2010 offers more to developers than any other Visual Studio release. Work more productively and collaboratively-with greater control over your work at every step. The Beta 2 can give you a head start on achieving efficiency.
 
   Print Read/Post comments Post a comment  Rate  
   Email to a friend  Bookmark  Similar Articles  Author's other articles  
Download Files:
AssemblyViewer.zip
 
 Post a Feedback, Comment, or Question about this article
Subject:  
Comment:  
Become a Sponsor
 Comments

 Hosted by MaximumASP  |  Found a broken link?  |  Contact Us  |  Terms & conditions  |  Privacy Policy  |  Site Map  |  Suggest an Idea  |  Media Kit
Current Version: 5.2009.6.2
 © 1999 - 2009  Mindcracker LLC. All Rights Reserved