Created
September 6, 2014 18:43
-
-
Save jakesays-old/9107987b882a3a3933e2 to your computer and use it in GitHub Desktop.
Using IKVM.Reflection to obtain an assembly's version
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static string GetVersionFromAssembly(byte[] fileData, string fileName) | |
{ | |
var reflector = new Universe(); | |
AssemblyName name = null; | |
using (var fileStream = new MemoryStream(fileData)) | |
{ | |
var module = reflector.OpenRawModule(fileStream, fileName); | |
if (module == null) | |
{ | |
return null; | |
} | |
name = module.GetAssemblyName(); | |
if (name == null) | |
{ | |
return null; | |
} | |
} | |
var version = name.Version.ToString(); | |
return version; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment