Search code examples
c#.net-micro-framework

Accessing version info of another project


I have a VS solution with 2 Micro Framework C# projects A and B. I want B to access the AssemblyVersion of A (as specified in AssemblyInfo.cs). Is there a way to do that?


Solution

  • You can't access AssemblyInfo as a class. AssemblyInfo only contains assembly level attributes, that can only be accessed via reflection.

    You can use Assembly.Load("assemblypath") to load an assembly in memory and then access the version info via AsemblyName object:

    var assembly = Assembly.Load(".\myassembly.dll");
    

    AssemblyName nameInfo = assembly.GetName();

    Console.Writeline(nameInfo.Version.ToString());

    If your referenced assembly has been loaded first, you could also search it inside AppDomain loaded assemblies using AppDomain.Current.GetAssemblies