哪里可以找到我的c#解决方案的GUID

时间:2013-06-05 01:00:12

标签: c# visual-studio guid

你好我在构建MonoGame时遇到问题我得到glbind ...错误在opengl32.dll所以我被建议找到我的GUID它听起来像一个简单的任务但我已经查看了项目文件夹文件并且找不到它我发现了一个

<ProjectGuid>{325BCA73-8459-49AF-9C31-D4A268BF8A1A}</ProjectGuid>

但我正在寻找像这样的人

<ProjectTypeGuids>{9B831FEF-F496-498F-9FE8-180DA5CB4258};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>

这是我的文件夹和主要“碰撞”.csproj文件的图像,其中我找到了一个GUID。我做了一些研究,但我似乎无法找到答案在哪里看。 HERE

更多的是我正在寻找Projecttypeguids,所以我可以删除其中一个,看看是否解决了我在这里建议的问题....我认识到我在顶部的措辞有点模糊抱歉

Here

3 个答案:

答案 0 :(得分:1)

您提供的第一个示例是项目的GUID。因此ProjectGuid
第二个是项目项目类型的GUID列表。因此ProjectTypeGuids

如果您正在寻找项目的GUID,第一个例子就是给出正确答案。

答案 1 :(得分:0)

您链接的屏幕截图显示了未列出任何类型GUID的项目。如果存在,该值主要由开发工具使用(例如,VS使用它来确定要在上下文菜单中包含哪些项目以添加新项目。)如果没有项目类型GUID,您的项目仍将“工作”最多部分,但您可能会在您选择的IDE中遇到奇怪的行为。

您的问题中的项目类型GUID值对于使用MonoGame插件的C#应用​​程序的项目是正确的。如果您的项目文件缺少该标记,只需使用您希望项目具有的GUID自行添加。

(众所周知的GUID列表可以找到here,但我必须在Google上查看MonoGame。)

答案 2 :(得分:0)

首先,你没有提到你正在使用winforms或wpf。

没问题。如果你使用的是wpf,你可以在winforms中支持ProjectTypeGuids。

如果您使用的是wpf,则可以使用以下代码:

 public string GetProjectTypeGuids(EnvDTE.Project proj)
       {

      string projectTypeGuids = "";
      object service = null;
      Microsoft.VisualStudio.Shell.Interop.IVsSolution solution = null;
      Microsoft.VisualStudio.Shell.Interop.IVsHierarchy hierarchy = null;
      Microsoft.VisualStudio.Shell.Interop.IVsAggregatableProject aggregatableProject = null;
      int result = 0;

      service = GetService(proj.DTE, typeof(Microsoft.VisualStudio.Shell.Interop.IVsSolution));
      solution = (Microsoft.VisualStudio.Shell.Interop.IVsSolution)service;

      result = solution.GetProjectOfUniqueName(proj.UniqueName, hierarchy);

      if (result == 0)
      {
         aggregatableProject = (Microsoft.VisualStudio.Shell.Interop.IVsAggregatableProject) hierarchy;
         result = aggregatableProject.GetAggregateProjectTypeGuids(projectTypeGuids);
      }

      return projectTypeGuids;

   }

   public object GetService(object serviceProvider, System.Type type)
   {
      return GetService(serviceProvider, type.GUID);
   }

   public object GetService(object serviceProviderObject, System.Guid guid)
   {

      object service = null;
      Microsoft.VisualStudio.OLE.Interop.IServiceProvider serviceProvider = null;
      IntPtr serviceIntPtr;
      int hr = 0;
      Guid SIDGuid;
      Guid IIDGuid;

      SIDGuid = guid;
      IIDGuid = SIDGuid;
      serviceProvider = (Microsoft.VisualStudio.OLE.Interop.IServiceProvider)serviceProviderObject;
      hr = serviceProvider.QueryService(SIDGuid, IIDGuid, serviceIntPtr);

      if (hr != 0)
      {
         System.Runtime.InteropServices.Marshal.ThrowExceptionForHR(hr);
      }
      else if (!serviceIntPtr.Equals(IntPtr.Zero))
      {
         service = System.Runtime.InteropServices.Marshal.GetObjectForIUnknown(serviceIntPtr);
         System.Runtime.InteropServices.Marshal.Release(serviceIntPtr);
      }

      return service;
   }

来自here

相关问题