我想获得一个在Visual Studio解决方案文件(* .sln)中使用的程序集GUID,如下所示:
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
我尝试了以下代码,所有失败:
//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;
有什么想法吗?
答案 0 :(得分:0)
* .sln文件中使用的程序集guid位于* .csproj文件
中<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ProjectGuid>{5B402A1B-18B1-4D88-804A-BC0E58EF3730}</ProjectGuid>
</PropertyGroup>
</Project>