Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>From the problem description in your question I can see there are really 2 primary tasks that you are trying to accomplish:</p> <p>1) Determine if a given assembly name can be loaded from the GAC.<br/> 2) Return the file modified date for the given assembly.</p> <p>I believe these 2 points can be accomplished in a much simpler fashion and without having to work with the <a href="http://msdn.microsoft.com/en-us/library/ms404523.aspx" rel="nofollow">unmanaged fusion API</a>. An easier way to go about this task might be as follows:</p> <pre><code>static void Main(string[] args) { // Run the method with a few test values GetAssemblyDetail("System.Data"); // This should be in the GAC GetAssemblyDetail("YourAssemblyName"); // This might be in the GAC GetAssemblyDetail("ImaginaryAssembly"); // This just plain doesn't exist } private static DateTime? GetAssemblyDetail(string assemblyName) { Assembly a; a = Assembly.LoadWithPartialName(assemblyName); if (a != null) { Console.WriteLine("'{0}' is in GAC? {1}", assemblyName, a.GlobalAssemblyCache); FileInfo fi = new FileInfo(a.Location); Console.WriteLine("'{0}' Modified: {1}", assemblyName, fi.LastWriteTime); return fi.LastWriteTime; } else { Console.WriteLine("Assembly '{0}' not found", assemblyName); return null; } } </code></pre> <p>An example of the resulting output:</p> <blockquote> <p>'System.Data' is in GAC? True<br/> 'System.Data' Modified: 10/1/2010 9:32:27 AM<br/> 'YourAssemblyName' is in GAC? False<br/> 'YourAssemblyName' Modified: 12/30/2010 4:25:08 AM<br/> Assembly 'ImaginaryAssembly' not found<br/></p> </blockquote>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload