Compiler error for obsolete COMType using DirectShow

145 views Asked by At

I am coding a small app that takes a users picture to be printed on an ID card. I have looked around and found a number of different examples of this in C# that would be perfect for me to use except for 2 issues both attaining to a UCOM element now being obsolete in the newer .NET frameworks.

This is the code that gives the error:

int hr = devEnum.CreateClassEnumerator(FilterCategory.VideoInputDevice, out classEnum, CDef.None);

And this is the exact wording of the error:

Error 2 Argument 2: cannot convert from 'out System.Runtime.InteropServices.ComTypes.IEnumMoniker' to 'out System.Runtime.InteropServices.UCOMIEnumMoniker' E:\Programming\Application Files\WebCamControl2\WebCamControl2.cs 108 89 WebCamControl2

I am using the DirectShow dll that was last used in 2005 and it uses a UCOMIEnumMoniker and UCOMIMoniker that have been changed to IEnumMoniker and IMoniker respectively.

How can i get around this compile error? Can I cast the newer type as the old one even if its obsolete or do I have to scrap the idea of using the DirectShow lib?

1

There are 1 answers

0
Roman Ryltsov On

You don't normally deal with UCOMxxx types unless you are working with ancient .NET versions. From DirectShow.NET source:

#if USING_NET11
            [Out] out UCOMIEnumMoniker ppEnumMoniker,
#else
            [Out] out IEnumMoniker ppEnumMoniker,
#endif

You should find out where you get UCOMIEnumMoniker in your project exactly, and most likely it should not be there.