lundi 28 avril 2014

Getting Assembly GUID programmatically that matches that in Visual studio solution file (*.sln)


Vote count:

0




I want to get an assembly GUID that is used in a Visual Studio solution file (*.sln), like below:



Microsoft Visual Studio Solution File, Format Version 12.00
#Visual Studio 2010

Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ClassLibrary3", "..\ClassLibrary3\ClassLibrary3.csproj", "{5B402A1B-18B1-4D88-804A-BC0E58EF3730}"
EndProject


I tried the code below, all failed:



//attempt 1:
var assembly = Assembly.LoadFile(grandProject.AssemblyFilePath);
var id = assembly.GetType().GUID.ToString();

//attempt 2
var attribute = (GuidAttribute)assembly.GetCustomAttributes(typeof(GuidAttribute), true)[0];
var id = attribute.Value;


Any idea?



asked 1 min ago

Pingpong

1,355





Aucun commentaire:

Enregistrer un commentaire