Home Forums Software Development InteractionLib, how to use it properly?

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #18535
    Roman
    Participant

    Hi! I’ve taken the Tobii.InteractionLib.Wpf.SampleApp and copied all the code and references in a fresh project, to experiment with it myself. I’ve copied the “lib” directory into my project too. I’ve added tobii_interaction_lib_wpf.dll and tobii_interaction_lib_cs.dll as references. But when I try to run my project, it builds successfully but doesn’t run. Windows Event Log reports a DllNotFoundException:

    Description: The process was terminated due to an unhandled exception.
    Exception Info: System.DllNotFoundException
       at Tobii.InteractionLib.InteractionLibCImports.IL_CreateInteractionLib(IntPtr ByRef, Tobii.InteractionLib.FieldOfUse)
       at Tobii.InteractionLib.Wpf.InteractionLibWpfHost..ctor()

    Am I missing something? How do I use the Interaction Library correctly? It doesn’t want to work outside the sample apps…

    #18537
    Roman
    Participant

    btw, the documentation mentions there is Tobii.InteractionLib in NuGet also, but it’s not there. Is it obsolete or what?

    #18545
    Grant [Tobii]
    Keymaster

    Hi @sapp, sorry to hear about your issues. Can you kindly confirm for us what happens if you follow our WPF Guide @ https://tobiitech.github.io/interaction-library-docs/wpf/html/index.html

    You should only need to unzip the Interaction Library ZIP and use the Visual Studio Developer Prompt command to get the program running:

    msbuild samples/wpf/Tobii.InteractionLib.Wpf.SampleApp/Tobii.InteractionLib.Wpf.SampleApp.csproj /p:Configuration=Release /p:Platform=x64 /verbosity:minimal

    Which produces the relevant exe. I had to first install the Microsoft .NET Framework 4.7.1 Developer Pack available @ https://www.microsoft.com/en-us/download/confirmation.aspx?id=56119

    Please let us know the output from this command. Best Wishes.

    #18553
    Roman
    Participant

    @grant-rogers, I’m fine running the sample app itself. Now I’m trying to use the library for my own project. That’s where I have a problem, because apparently just using the DLLs is not exactly enough. Can you describe how Interaction Library is intended to be used outside the sample app?

    #18554
    Grant [Tobii]
    Keymaster

    Hi @sapp, could you kindly clarify what kind of language bindings and technologies (C++,C#,WPF, etc) you intend on using? Thereafter I will be better placed to offer a ‘blank’ template.

    That being said, in the meantime you could simply strip the sample application down to the bare components and build your project upon that, but I will look at providing details otherwise.

    #18557
    Roman
    Participant

    @grant-rogers, oh right, I’m using C# WPF. Just created a new .NET Framework project. Copied the “lib” directory with the DLLs to the project. Added tobii_interaction_lib_cs.dll and tobii_interaction_lib_wpf.dll to References. Thought it would suffice, but apparently missing something.

    Thank you for your advice, I’ll try to strip down the sample app too. Just want a clear understanding, what is needed for correct usage.

    #18560
    Roman
    Participant

    Ok @grant-rogers, I’ve found the missing parts. They were all hidden in the project file: Tobii.InteractionLib.Wpf.SampleApp.csproj
    I’m not sure if the missing fields can be set up via Visual Studio’s GUI, I couldn’t find them there. I’ve edited my .csproj file directly to add the missing stuff. I believe the crucials were these:

      <PropertyGroup>
        <IsWindows>false</IsWindows> 
        <IsOSX>false</IsOSX>
        <IsLinux>false</IsLinux>
        <IsWindows Condition="'$(OS)' == 'Windows_NT'">true</IsWindows>
      </PropertyGroup>
      <PropertyGroup Condition="'$(MSBuildRuntimeType)' == 'Core'">
        <IsWindows Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Windows)))' == 'true'">true</IsWindows>
        <IsOSX Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::OSX)))' == 'true'">true</IsOSX>
        <IsLinux Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Linux)))' == 'true'">true</IsLinux>
      </PropertyGroup>
      <PropertyGroup>
        <LibPath>../../../lib/$(Platform)</LibPath>
        <LibPath Condition="'$(BuildLibPath)' != ''">$(BuildLibPath)</LibPath>
      </PropertyGroup>

    …and these:

      <ItemGroup Condition="$(IsWindows)">
        <NativeDlls Include="$(LibPath)/tobii_interaction_lib_c.dll" />
        <NativeDlls Include="$(LibPath)/tobii_interaction_lib.dll" />
        <NativeDlls Include="$(LibPath)/tobii_stream_engine.dll" />
      </ItemGroup>
      <ItemGroup Condition="$(IsOSX)">
        <NativeDlls Include="$(LibPath)/libtobii_interaction_lib_c.dylib" />
        <NativeDlls Include="$(LibPath)/libtobii_interaction_lib.dylib" />
        <NativeDlls Include="$(LibPath)/libtobii_stream_engine.dylib" />
      </ItemGroup>
      <ItemGroup Condition="$(IsLinux)">
        <NativeDlls Include="$(LibPath)/libtobii_interaction_lib_c.so" />
        <NativeDlls Include="$(LibPath)/libtobii_interaction_lib.so" />
        <NativeDlls Include="$(LibPath)/libtobii_stream_engine.so" />
      </ItemGroup>
      <Target Name="AfterBuild">
        <Copy SourceFiles="@(NativeDlls)" DestinationFolder="$(OutputPath)" SkipUnchangedFiles="true" />
      </Target>

    So now with these things in my .csproj file I can successfully build and run the app. All good. Thank you for participation!

    #18567
    Grant [Tobii]
    Keymaster

    Great! Thanks for sharing Roman and glad to hear you got your project up and running 🙂

Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.