Replies: 3 comments
-
|
If you've created a class that inherits from |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
Unfortunately I need to support cocreateinstance, Microsoft Office is the
one who is initialising my class (there's some explanation here
https://learn.microsoft.com/en-us/microsoft-365/cloud-storage-partner-program/plus/sync-client/metadata
)
For some reason my vanara implementation isn't working, so I was comparing
it to a working one (C++) and the first thing I noticed was that the C++
version allows the cast to occur whereas vanara won't cast
…On Sun, 14 Sept 2025, 8:25 am David Hall, ***@***.***> wrote:
If you've created a class that inherits from IStorageProviderHandler, you
can just new it to create an instance. You shouldn't use CoCreateInstance.
—
Reply to this email directly, view it on GitHub
<#559 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AABBRBRADG5ODVWBQ42DLM33SSKWLAVCNFSM6AAAAACGJVAR22VHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTIMZZGM2DGMA>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
0 replies
-
|
Does this work? It uses .NET RCW instead of direct COM. Type comType = Type.GetTypeFromCLSID(new Guid("{2d1275b6-7d67-454e-b204-4effb9ecb034}"));
object comObject = Activator.CreateInstance(comType);
IStorageProviderHandler storageProviderHandler = (IStorageProviderHandler)comObject; |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello I have a class which implements IStorageProviderHandler, when I run the following code for other such classes it works, but when I use my CLSID I get an error:
System.InvalidCastException: 'Unable to cast object of type 'IngressStorageProviderHandler.StorageProviderHandler' to type 'IStorageProviderHandler'.'Here is the code:
If I inspect type.ImlementedInterfaces I get a list of one which is: {Name = "IStorageProviderHandler" FullName = "Vanara.PInvoke.Shell32+IStorageProviderHandler"}
Perhaps there is another way to cast objects in this situation?
Beta Was this translation helpful? Give feedback.
All reactions