IDragSourceHelper problem
-
I've implemented the IDropTargetHelper and IDragSourceHelper COM interfaces to augment my drag drop support. So far I can create the IDropTargetHelper interface and call the respective methods will absolutely no problem. I should be able to use the exact same logic to create and use an IDragSourceHelper objedt. For some reason I get the following error when trying to create the object: "COM object with CLSID {DE5BF786-477A-11D2-839D-00C04FD918D0} is either not valid or not registered." I've triple checked and the GUID is correct for the IDragSourceHelper interface. Does anyone know what can be done here? Does somet DLL need to be registered? I'm out of ideas. Thanks
-
I've implemented the IDropTargetHelper and IDragSourceHelper COM interfaces to augment my drag drop support. So far I can create the IDropTargetHelper interface and call the respective methods will absolutely no problem. I should be able to use the exact same logic to create and use an IDragSourceHelper objedt. For some reason I get the following error when trying to create the object: "COM object with CLSID {DE5BF786-477A-11D2-839D-00C04FD918D0} is either not valid or not registered." I've triple checked and the GUID is correct for the IDragSourceHelper interface. Does anyone know what can be done here? Does somet DLL need to be registered? I'm out of ideas. Thanks
It's the IID (interface GUID) that's the problem, but the COM object GUID (that's what a CLSID is - a GUID for a class). You must have defined an interop class for the shell object that implements
IDragSourceHelper
. See, you don't actually create an interface; an interface is abstract and can't be instantiated. What happens behind the scenes (in the CLR) is that the COM object is created and AddRef'd. The CLR QI's (QueryInterface) for the interface when you perform a cast and returns the interface you want (to which you're casting).Microsoft MVP, Visual C# My Articles
-
It's the IID (interface GUID) that's the problem, but the COM object GUID (that's what a CLSID is - a GUID for a class). You must have defined an interop class for the shell object that implements
IDragSourceHelper
. See, you don't actually create an interface; an interface is abstract and can't be instantiated. What happens behind the scenes (in the CLR) is that the COM object is created and AddRef'd. The CLR QI's (QueryInterface) for the interface when you perform a cast and returns the interface you want (to which you're casting).Microsoft MVP, Visual C# My Articles
Perhaps I wasn't clear enough in my question... I already have all the interop classes created. (That's was my point in saying I have everything working for the IDropTargetHelper interface). I wasn't suggesting I was trying to create an interface - I was sparing a paragraph spelling out what my already working code does. My question was why I can get the IDropTargetHelper working but not the IDragSourceHelper using the same overall logic. Now - according to shlguid.h the IID for the drop helper (IID_IDropTargetHelper) is 4657278B-411B-11d2-839A-00C04FD918D0. That works - no problem there at all. It would stand to reason, then, that the guid for IID_IDragSourceHelper would work for using the IDragSourceHelper interface. IID_IDragSourceHelper is DE5BF786-477A-11d2-839D-00C04FD918D0. That's the part that doesn't work - when I create the object derived from the IDragSourceHelper interface I get the message specified in my first post. Oddly, the value 4657278B-411B-11d2-839A-00C04FD918D0 is in my registry in several places, while DE5BF786-477A-11d2-839D-00C04FD918D0 is not in my registry.
-
Perhaps I wasn't clear enough in my question... I already have all the interop classes created. (That's was my point in saying I have everything working for the IDropTargetHelper interface). I wasn't suggesting I was trying to create an interface - I was sparing a paragraph spelling out what my already working code does. My question was why I can get the IDropTargetHelper working but not the IDragSourceHelper using the same overall logic. Now - according to shlguid.h the IID for the drop helper (IID_IDropTargetHelper) is 4657278B-411B-11d2-839A-00C04FD918D0. That works - no problem there at all. It would stand to reason, then, that the guid for IID_IDragSourceHelper would work for using the IDragSourceHelper interface. IID_IDragSourceHelper is DE5BF786-477A-11d2-839D-00C04FD918D0. That's the part that doesn't work - when I create the object derived from the IDragSourceHelper interface I get the message specified in my first post. Oddly, the value 4657278B-411B-11d2-839A-00C04FD918D0 is in my registry in several places, while DE5BF786-477A-11d2-839D-00C04FD918D0 is not in my registry.
Look man, I don't know you. I don't know most of the people that show up in this forum looking for help. The only person I truly know here is Nick and I'm familiar with a few others that frequent this forum like Dave and Christian. When people come to this forum, I assume nothing. I don't know if you know what you're doing. Since you're peering into header files and based on other information, it appears you do know what you're doing; but how could've I known that? As I said, I don't know you. So please don't get testy. Sorry, it's just that I've been getting a lot of this crap lately because forums present faceless people sitting on a keyboard potentially on the other side of the world. As for your questions and comments... IIDs don't have to be registered, so the fact that IID_IDragSourceHelper isn't found in your registry isn't not surprising. Of course the CLSID must be registered, which I'm sure you know. The documentation for both the
IDropTargetHelper
andIDragSourceHelper
interfaces state that the COM object with CLSID_DragDropHelper implements both. When I import shell32.dll, however, this coclass isn't imported, so I'm curious where you got it (or did you declare the class yourself, which is entirely possible).Microsoft MVP, Visual C# My Articles
-
Perhaps I wasn't clear enough in my question... I already have all the interop classes created. (That's was my point in saying I have everything working for the IDropTargetHelper interface). I wasn't suggesting I was trying to create an interface - I was sparing a paragraph spelling out what my already working code does. My question was why I can get the IDropTargetHelper working but not the IDragSourceHelper using the same overall logic. Now - according to shlguid.h the IID for the drop helper (IID_IDropTargetHelper) is 4657278B-411B-11d2-839A-00C04FD918D0. That works - no problem there at all. It would stand to reason, then, that the guid for IID_IDragSourceHelper would work for using the IDragSourceHelper interface. IID_IDragSourceHelper is DE5BF786-477A-11d2-839D-00C04FD918D0. That's the part that doesn't work - when I create the object derived from the IDragSourceHelper interface I get the message specified in my first post. Oddly, the value 4657278B-411B-11d2-839A-00C04FD918D0 is in my registry in several places, while DE5BF786-477A-11d2-839D-00C04FD918D0 is not in my registry.
I three together the follow. The
ComImportAttribute
changes the metadata such that an instance is marked as imported and created from the attributed GUID. By casting, I am effectively QI'ing for the two interfaces. In both cases, "False" is printed to the console, showing that the object does implement both interfaces. Sorry I don't have time to throw together a better sample (and keep in mind that when using interfaces not every method has to be defined (so long as they're in the correct VTBL order):using System;
using System.Runtime.InteropServices;[
GuidAttribute("4657278A-411B-11d2-839A-00C04FD918D0"),
ClassInterface(ClassInterfaceType.None),
ComImport
]
public class DragDropHelper : IDropTargetHelper, IDragSourceHelper
{
}[
GuidAttribute("4657278B-411B-11d2-839A-00C04FD918D0"),
InterfaceType(ComInterfaceType.InterfaceIsIUnknown),
ComImport
]
public interface IDropTargetHelper
{
}[
GuidAttribute("DE5BF786-477A-11d2-839D-00C04FD918D0"),
InterfaceType(ComInterfaceType.InterfaceIsIUnknown),
ComImport
]
public interface IDragSourceHelper
{
}class Test
{
static void Main()
{
DragDropHelper helper = new DragDropHelper();IDropTargetHelper dropHelper = (IDropTargetHelper)helper; IDragSourceHelper dragHelper = (IDragSourceHelper)helper; Console.WriteLine(dropHelper == null); Console.WriteLine(dragHelper == null);
}
}Microsoft MVP, Visual C# My Articles