Last post Jun 10, 2009 12:47 PM by kettch19
May 14, 2009 10:40 AM|kettch19|LINK
I recently upgraded a DLL from VB6 to .Net and am encountering a confusing error. This DLL is used as a reference in a .Net web application and now in certain locations in the application I am getting the following error:
Unable to cast COM object of type 'System.__ComObject' to class type 'rjsDocMan.Folder'. Instances of types that represent COM components cannot be cast to types that do not represent COM components; however they can be cast to interfaces as long as the underlying COM component supports QueryInterface calls for the IID of the interface.
treeview += AddChildren(Session("DocMan").RootFolder)
COM vb6 upgrade DLL class cast
May 14, 2009 04:15 PM|kettch19|LINK
All classes are in their own .vb files and all are marked as "COM Visible" being true. All classes are currently marked with "COM Class" set to False, however toggling "COM Class" to True does not fix the exception. These are the only settings I can see
in the class properties related to COM...
Has no one ever run into this error before updating a DLL from VB6? I find that hard to believe...
May 14, 2009 05:05 PM|kettch19|LINK
Furthermore, the exception only occurs when an class object in the DLL is being assigned to a local variable in the web application. Calling methods from the class objects work perfectly fine.
Thus, this works without problem:
childFolders = parentFolder.ChildFolders
May 15, 2009 09:45 AM|kettch19|LINK
I've tried completely recreating the classes from scratch to see if some of the behind-the-scenes voodoo was simply not quite connecting, but no dice on that either.
Jun 10, 2009 12:47 PM|kettch19|LINK