How to use VS 2010 and .NET 4.0 with Ranorex 2.X

Best practices, code snippets for common functionality, examples, and guidelines.
anton.purin
Posts: 5
Joined: Thu Jul 01, 2010 4:47 pm

How to use VS 2010 and .NET 4.0 with Ranorex 2.X

Post by anton.purin » Fri Jul 02, 2010 8:10 am

Hello, i have some problems with Ranorex library using.

Environment:
Win 7 x64
Ranorex version: 2.3.1.8466 Evaluation period

if have created simple project to use Ranorex library.
Here is steps to reproduce:
1. Create Windows Forms .NET 4.0 C# project in VS 2010
2. Add Ranorex.Core.dll from ranorex\bin\ folder as reference
3. Add following line to form contructor

Code: Select all

Ranorex.Form form = Ranorex.Host.Local.FindChild<Ranorex.Form>("Calculator");
4. Start project
5. Press Continue evaluation on "Evaluation period" window.

Ranorex code throws following exception:
Failed to load default plugins. Please reinstall Ranorex.

Inner exception: {"Cannot load required flavor 'win32' from any of the plugins."}
Stack trace:

Code: Select all

   at Ranorex.Core.PluginManager.LoadPluginsWithDependencies(IList`1 flavorPlugins)
   at Ranorex.Core.PluginManager.LoadDefaultPlugins()
TargetSite:

Code: Select all

{Int32 LoadPluginsWithDependencies(System.Collections.Generic.IList`1[Ranorex.Core.PluginManager+FlavorPluginInfo])}
I have tried following workarounds but with no success:
1. Add all *.dll's from bin\ folder as references
2. Remove all renorex references and add all *.dll's from bin\x64\ folder as references

Also
  • I have both VS 2010 and VS C# Express. And this error happens only in VS 2010. All works greatly in VS C# express.
  • Ranorex studio and Ranorex spy works normally

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Cannot load required flavor 'win32' from any of the plugins

Post by Support Team » Fri Jul 02, 2010 1:49 pm

Microsoft did change the way mixed-mode assemblies are loaded in the .NET Framework 4.0 and Ranorex uses mixed-mode assemblies to interact with the Windows API. So, when using VS 2010 you can either change the target framework to .NET Framework 3.5 or below or when you select the .NET Framework 4.0 as the target framework, you have to instruct the .NET runtime to load mixed-mode assemblies in legacy style. To do that you need to set the useLegacyV2RuntimeActivationPolicy attribute in your application configuration. Add "app.config" file to your project and add the following XML code to it:
<configuration>
  <startup useLegacyV2RuntimeActivationPolicy="true">
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
    <supportedRuntime version="v2.0.50727"/>
  </startup>
</configuration>
See the following MSDN page for more info on that configuration attribute:
http://msdn.microsoft.com/en-us/library/bbx34a2h.aspx

Regards,
Alex
Ranorex Team
.
Image

anton.purin
Posts: 5
Joined: Thu Jul 01, 2010 4:47 pm

Re: How to use VS 2010 and .NET 4.0 with Ranorex 2.X

Post by anton.purin » Fri Jul 02, 2010 4:13 pm

Thank you very much!

User avatar
Aracknid
Posts: 342
Joined: Tue Aug 10, 2010 3:23 pm
Location: Toronto, Ontario, Canada

Re: How to use VS 2010 and .NET 4.0 with Ranorex 2.X

Post by Aracknid » Thu May 12, 2011 3:28 pm

Sorry to re-open this old thread, but I was wondering if this is all still required with Ranorex 3.01 now that you support .Net 4 and VS2010 ?

Thanks,

Aracknid

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: How to use VS 2010 and .NET 4.0 with Ranorex 2.X

Post by Support Team » Thu May 12, 2011 3:51 pm

If you compile your tests with .NET Framework 4.0 in VS 2010, the app.config file is no longer needed. Ranorex ships all mixed-mode assemblies build for the .NET Framework 2.0 and 4.0 since version 3.X.

If you target Framework 3.5 or below, you can still automate .NET 4.0 controls using the app.config file.

Regards,
Alex
Ranorex Team
.
Image

madhugu
Posts: 6
Joined: Tue Jun 14, 2011 12:16 pm

Re: How to use VS 2010 and .NET 4.0 with Ranorex 2.X

Post by madhugu » Wed Jun 22, 2011 2:18 pm

Hi,

I have Ranorex 2.1 trial version and I have been using it with .net 2.0. Now I have upgraded my automation package to .net 4.0 and added the config item that is given in this mail thread and I get an error saying "Failed to load Ranorex.Core.WinApi.dll. I noticed that Ranorex.Core.WinApi.dll was being copied locally to my application's bin directory when my automation application was in .net 2.0. I have tried copying the dll into my bin folder of the .net 4.0 application, yet I get the same error. Even if I add the dll as a reference to the project the same error occurs.

- Madhu

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: How to use VS 2010 and .NET 4.0 with Ranorex 2.X

Post by Support Team » Thu Jun 23, 2011 6:16 pm

Hi,

Is this issue solved now with following thread?
http://www.ranorex.com/forum/identify-f ... html#p9202

Regards,
Peter
Ranorex Team
.
Image

madhugu
Posts: 6
Joined: Tue Jun 14, 2011 12:16 pm

Re: How to use VS 2010 and .NET 4.0 with Ranorex 2.X

Post by madhugu » Tue Jun 28, 2011 12:03 pm

Hi,

I am evaluating version 3.0.2 before we purchase it. Will post any issues that I see on that soon.

Thanks,
Madhu.