2013-03-26 49 views
7

閱讀:我在回答我自己的問題,以幫助其他人在未來的事件。無法轉換爲類型庫 - 錯誤:找不到元素

,我發現了錯誤:

Error 2 The assembly "C:\XYZ.dll" could not be converted to a type library. Type library exporter encountered an error while processing 'XYZ'. Error: Element not found.

這裏是導致該問題的代碼:

[Guid("7a4e9867-96a7-43f0-9492-0327b9053853"), 
ClassInterface(ClassInterfaceType.None)] 
public class TimeSeriesPoint 
{ 
    public string Date { get; set; } 
    public float Value { get; set; } 
} 

[Guid("7a4e9867-96a7-43f0-9492-0327b9053853"), 
InterfaceType(ComInterfaceType.InterfaceIsDual)] 
public interface IDataHelper 
{ 
    //RCOMServerLib.IStatConnector Connector { set; } 
    string Text { set; } 
    void DoCallback(); 

回答

15

我用的是相同的GUID從集信息文件:

[assembly: Guid("7a4e9867-96a7-43f0-9492-0327b9053853")] 

您需要使用唯一的GUID來解決錯誤:

[Guid("C25D485B-F7DE-4F1C-99FE-FFAF5A219B77"), 
ClassInterface(ClassInterfaceType.None)] 
public class TimeSeriesPoint 
{ 
    public string Date { get; set; } 
    public float Value { get; set; } 
} 

[Guid("FA6F70DD-CDD0-4FF3-94BA-E2B94E68321D"), 
InterfaceType(ComInterfaceType.InterfaceIsDual)] 
public interface IDataHelper 
{ 
    //RCOMServerLib.IStatConnector Connector { set; } 
    string Text { set; } 
    void DoCallback(); 

要獲得唯一的GUID單擊Visual Studio工具>創建GUID>選擇第4個選項註冊>複製:

enter image description here

編號:http://social.msdn.microsoft.com/forums/en-US/csharpgeneral/thread/a440f695-652c-46d2-bb52-650c6227d3e9

相關問題