Could not be converted to a type library - Error: Element not found

I was using the same GUID from the AssemblyInfo file:

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

You need to use unique GUIDs to resolve the error:

[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();

To get unique GUIDs in Visual Studio click Tools Menu > Create GUID > select the 4th option Registry Format > Copy:

enter image description here

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


Similar problem, but with the final error statement:

Error: Error loading type library/DLL.

In my case, there was a referenced project/assembly that didn't have its tlb generated.

However, running regasm manually worked. It generated the tlb for both the referenced project/assembly and the target, Acme.Widgets.dll. And there were no explicit references to the related project specified on the regasm command line:

@ECHO OFF

pushd "%~dp0"

%SystemRoot%\Microsoft.NET\Framework\v4.0.30319\regasm Acme.Widgets.dll /tlb Acme.Widgets.tlb /codebase 

popd

pause

I eventually realized the referenced project/assembly didn't have the Register for COM interop setting enabled within Visual Studio. Figured it was enough to have it enabled for the target only, but that wasn't the case.

The referenced project/assembly began its life serving an ordinary .Net app where COM wasn't a factor.

Tags:

C#

.Net

Vb.Net

Com