Share via

Interop.UIAutomationClient private/internal starting with version 10.0.0

Domgrar 0 Reputation points
2023-02-24T18:59:10.24+00:00

Hi, I've got a semi-old code base that uses Interop.UIAutomationClient.dll v4.5.0.0

I'm looking to update that to v10.0.0.0 that I find in my Windows SDK here "C:\Program Files (x86)\Windows Kits\10\bin\10.0.19041.0\x64\UIAVerify"

Unfortunately I think it seems like there has been some change between the versions there.

With v4.5.0.0 the code base refers to it like so

using UIA = Interop.UIAutomationClient;

And has usages like this

public UIA.IUIAutomation3 NativeAutomation3 => GetAutomationAs<UIA.IUIAutomation3>();

When I swap out the .dll for the v10.0.0.0 I get this -

using UIA = Interop.UIAutomationClient; // 'Interop' is inaccessible due to it's protection level

Does anyone have any guidance here, I'm a little lost on how to proceed with this update.

Thanks!

Developer technologies | C#
Developer technologies | C#

An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.


2 answers

Sort by: Most helpful
  1. Jack J Jun 25,306 Reputation points
    2023-02-27T06:19:12.7833333+00:00

    @Domgrar, Welcome to Microsoft Q&A, based on my test, I almost reproduced your problem. And according to my research, there is no related doc to explain it. However, I find another way to use the code without any problems.

    Please remove the reference Interop.UIAutomationClient.dll in your project and install the nuget-package Interop.UIAutomationClient.

    After testing, I find the code will not generate that error(Tested in .NET Framework 4.8 console app):

    User's image

    Best Regards,

    Jack


    If the answer is the right solution, please click "Accept Answer" and upvote it.If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    Was this answer helpful?

    0 comments No comments

  2. Michael Taylor 61,221 Reputation points
    2023-02-24T20:17:34.8666667+00:00

    That isn't what you want to do. That interop assembly was auto-generated from the corresponding COM type library when they created the project. It is simply a wrapper around the COM object just like you should be doing in your code. The version # is irrelevant here. It is v10 of the DLL because the apps that ship with the Win 10 SDK are v10. This has nothing to do with the version of the COM type library necessarily. If you're running Win 10 then you can (and should) generate this same interop assembly. When they imported the typelib they defined the namespace as UIAutomationClient and therefore that is where all the code went.

    To do the same in your code remove any existing reference libraries for UI automation. Then add a COM reference to the UIAutomationClient library (which is currently v7 for Windows 10 it appears) and it'll add the necessary code that is equivalent to what this assembly has. You can go to your intermediate build directory to see the binary that was generated. Other than versioning it should be the same as what the SDK ships.

    Was this answer helpful?

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.