Windows Forms Recognition Problem.

Windows Forms Recognition Problem.

Why does SilkTest fail to recognize the .Net controls running within a Windows Forms application? When recording actions or Locators; the objects are all tagged with the generic 'Control' class, rather than the native class of the control:

One possible reason why recognition of .Net controls might fail is if the application runs on CLR 1.1; because CLR 1.1 applications are considered Win32 rather than Window Forms.

Typically a target .Net Framework would be specified within the Visual Studio project. However if no target framework is defined; the application may run on the lowest version framework available on the system.

If this is CLR 1.1 the application will be recognized as Win32 domain; however if CLR 2.2 or later is the lowest framework version on the machine, then Windows Forms recognition should work correctly.

You can confirm which version of the .Net framework an application is running on, by examining its process using a tool such as Process Explorer. This will expose all Dlls loaded into the process; some of which will be related to the .Net framework version, as shown in the following screenshot:

To resolve this issue you could request that the developers specify a target .Net framework in the project, and provide a new build of the application containing these configuration changes. However if you have no access to the developers; you can also force the application to use CLR 2.2 by creating a file.exe.config file with the following content:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <startup>
    <supportedRuntime version="v2.0.50727"/>
  </startup>
</configuration>

Note that the name of this file needs to match the name of the executable. For example if your executable was named 'sample.exe' you would save the file as 'sample.exe.config' in the same directory as the executable.

After restarting the Open Agent the application and its child controls should now be recognized by their native classes:

DISCLAIMER:

Some content on Community Tips & Information pages is not officially supported by Micro Focus. Please refer to our Terms of Use for more detail.
Top Contributors
Version history
Revision #:
1 of 1
Last update:
‎2016-11-16 16:15
Updated by:
 
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.