I have a Visual C++ COM project that I need to add to my C# WinForm project.
I have added the library to my project and the Interop wrapper was added correctly, but when I build, this error occurs:
error CS1752: Interop type 'ObjectPickerHelper2Lib.ADObjectPickerClass' cannot be embedded. Use the applicable interface instead.
error CS0143: The type 'ObjectPickerHelper2Lib.ADObjectPickerClass' has no constructors defined
The line of code that has the problem is:
ObjectPickerHelper2Lib.IADObjectPicker picker = new ObjectPickerHelper2Lib.ADObjectPickerClass();
When I right click on ADObjectPickerClass and choose "Go to definition" option, this is shown:
#region Assembly Interop.ObjectPickerHelper2Lib.dll, v1.0.0.0
// C:\WorkingFolder\Proyectos\OmniLogin\OmniMaster\obj\Debug\Interop.ObjectPickerHelper2Lib.dll
#endregion
using System;
using System.Runtime.InteropServices;
namespace ObjectPickerHelper2Lib
{
[ClassInterface(0)]
[Guid("E064BB22-22CE-4E01-BB63-10EF4058CAF9")]
[TypeLibType(2)]
public class ADObjectPickerClass : IADObjectPicker, ADObjectPicker
{
public ADObjectPickerClass();
[DispId(10)]
public virtual dynamic ADObjectsColl { get; }
[DispId(7)]
public virtual string ComputerName { get; set; }
[DispId(6)]
public virtual uint DownLevelFilterFlags { get; set; }
[DispId(8)]
public virtual uint InitInfo_OptionFlags { get; set; }
[DispId(2)]
public virtual uint ScopeFlags { get; set; }
[DispId(1)]
public virtual uint ScopeTypeFlags { get; set; }
[DispId(3)]
public virtual uint UplevelFilterFlags_Both { get; set; }
[DispId(4)]
public virtual uint UplevelFilterFlags_Mixed { get; set; }
[DispId(5)]
public virtual uint UplevelFilterFlags_Native { get; set; }
[DispId(9)]
public virtual void InvokeDialog(int hWnd);
}
}
And even more, Intellisense does show the class constructor. I am using VS 2012.
Any help will be appreciated Thanks
Jaime
Aucun commentaire:
Enregistrer un commentaire