0
我已經安裝vs 2013,我正在嘗試創建自定義VisualStudio工具,但在建項目中,我應付這個錯誤:「Microsoft.VisualStudio.Shell.Interop,Version = 7.1.40304.0」未註冊COM Interop,請用regasm.exe/tlb註冊
The assembly "Microsoft.VisualStudio.Shell.Interop, Version=7.1.40304.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' is not registered for COM Interop. Please register it with regasm.exe /tlb
我試圖regasm註冊它,但這不是固定我的問題,我的代碼如下所示:
[Guid("6ECD98B5-C7E5-462E-8922-24890A8F3FE1")]
[ComVisible(true)]
public class GPFDicKeyToEnumGenerator : BaseCodeGeneratorWithSite
{
protected override byte[] GenerateCode(string inputFileName, string inputFileContent)
{
return System.Text.Encoding.ASCII.GetBytes(
@"
using System;
namespace My.Name.Space
{
public class foo
{
}
}
");
}
public override string GetDefaultExtension()
{
return ".cs";
}
#region Registration
private static Guid CustomToolGuid =
new Guid("{6ECD98B5-C7E5-462E-8922-24890A8F3FE1}");
private static Guid CSharpCategory =
new Guid("{FAE04EC1-301F-11D3-BF4B-00C04F79EFBC}");
private const string CustomToolName = "GAMA.gpf.SDK.Tools";
private const string CustomToolDescription = "Generate Enum of Keys for GPFDictionary";
private const string KeyFormat
= @"SOFTWARE\Microsoft\VisualStudio\{0}\Generators\{1}\{2}";
protected static void Register(Version vsVersion, Guid categoryGuid)
{
string subKey = String.Format(KeyFormat,
vsVersion, categoryGuid.ToString("B"), CustomToolName);
using (RegistryKey key = Registry.LocalMachine.CreateSubKey(subKey))
{
key.SetValue("", CustomToolDescription);
key.SetValue("CLSID", CustomToolGuid.ToString("B"));
key.SetValue("GeneratesDesignTimeSource", 1);
}
}
protected static void Unregister(Version vsVersion, Guid categoryGuid)
{
string subKey = String.Format(KeyFormat,
vsVersion, categoryGuid.ToString("B"), CustomToolName);
Registry.LocalMachine.DeleteSubKey(subKey, false);
}
[ComRegisterFunction]
public static void RegisterClass(Type t)
{
// Register for both VS.NET 2012, 2013 (C#)
Register(new Version(11, 0), CSharpCategory);
Register(new Version(12, 0), CSharpCategory);
}
[ComUnregisterFunction]
public static void UnregisterClass(Type t)
{
// UnRegister for both VS.NET 2012, 2013 (C#)
Register(new Version(11, 0), CSharpCategory);
Register(new Version(12, 0), CSharpCategory);
}
#endregion Registration
}
請幫我解決這個問題問題。
你找到一個解決方案? – PeterFromCologne
是的,我解決了這個問題。 –
我改變了我用來註冊我的工具的方式,我用屬性 –