I'm pretty new to C#, I'm trying to complete a little side project I've been working on that uses a small amount of C# code to assist the development of a Windows Desktop Gadget. Basically, I'm trying to implement the IDesktopGadget
interface so that I can use the RunGadget method.
Here's what I got so far from reading information about similar interfaces:
[ComImport]
[Guid("C1646BC4-F298-4F91-A204-EB2DD1709D1A")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
interface IDesktopGadget
{
uint RunGadget([MarshalAs(UnmanagedType.LPWStr)] string gadgetPath);
}
Unfortunately, I get an error when I try and create an object from it: "Cannot create an instance of the abstract class or interface 'GadgetTask.IDesktopGadget'"
Can someone point me in the right direction and maybe help me understand what I'm doing wrong at the same time?
Thanks for the guidance. For a little more straight forward help, this is what worked for me:
IDesktopGadget.cs
Program.cs
You actually need an implementation of the DesktopGadget object in order to use the interface. MS provide a standard COM object to do it on Windows 7. You can create an instance by doing something like: