简体   繁体   中英

How can I get waitFor to work when using canopy?

I'm using canopy, and I can't get the waitFor method to work.

I'm trying to use it like this:

waitFor noBlockUI

where the noBlockUI function is:

let noBlockUI () =
    (someElement "div.blockUI").IsNone

Now the waitFor call is in a function in an F# module, and I'm calling that function from a C# project.

I've found that I have to add FSharp.Core to my C# project to get any of the calls to work. There are a couple of Microsoft-authored NuGet packages for FSharp:

If I use the 4.0.0 package, then when execution hits method with the waitFor, I get this error:

System.MissingMethodException : Method not found: 'Microsoft.FSharp.Core.FSharpOption`1 canopy.core.someElement(System.String)'.

But if I use the 4.3.0.0 package, then immediately when I try to run my tests, I get this:

System.TypeInitializationException : The type initializer for '.$canopy.core' threw an exception. ----> System.IO.FileLoadException : Could not load file or assembly 'FSharp.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

Any ideas what I can to do get waitFor to work?

Try adding an app.config file containing something like this:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="FSharp.Core" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-4.3.0.0" newVersion="4.3.0.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
</configuration>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM