Page 1 of 2

Issues with Phidget22 after migrating to .NET 6.0 framework

Posted: Mon Mar 21, 2022 6:54 am
by Arnaud
Hello there,

Ive been working with the Phidget nuget package 1.6.20200709 in a NetCore3.1 WPF application for a while and everything went fine.
We recently decided to move to the .NET6 framework and I came across a new issue : When calling DigitalOutput methods the exe crashes. All information I have are from the event viewer :

Application: Phoenix.Ui.exe
CoreCLR Version: 6.0.322.12309
.NET Version: 6.0.3
Description: The process was terminated due to an unhandled exception.
Exception Info: System.DllNotFoundException: Dll was not found.
at Phidget22.Phidget22Imports.Phidget_setOnAttachHandler(IntPtr phid, AttachEvent fptr, IntPtr ctx)
at Phidget22.Phidget.uninitializeBaseEvents()
at Phidget22.Phidget.uninitializeEvents()
at Phidget22.DigitalOutput.Finalize()

An interesting fact is that I have the crash when I launch a published exe , but it works perfectly in VS2022, in both debug and release mode.
I updated the Phidget22 package to the last version 1.10.20220211 and I still have the same problem.

Im wondering if these Phidget22 packages are already compatible with the NET6 framework ? If so any idea on the causes of my issue ?

Thanks a lot!

Re: Issues with Phidget22 after migrating to .NET 6.0 framework

Posted: Thu Mar 24, 2022 10:50 am
by Arnaud
Any ideas ?

Re: Issues with Phidget22 after migrating to .NET 6.0 framework

Posted: Wed Mar 30, 2022 1:54 pm
by Patrick
This is likely an issue where the embedded C libraries aren't getting published along with the .net dll - you may have to manually include them. The .net library looks for the C library at dll/x86/phidget22.dll or dll/x64/phidget22.dll depending on architecture.

-Patrick

Re: Issues with Phidget22 after migrating to .NET 6.0 framework

Posted: Wed Apr 13, 2022 3:19 am
by Arnaud
Hello Patrick,

and thanks for your answer. Unfortunately the phidget22.dll is included in my published application. The issue must be somewhere else.

Thanks for the tip anyway

Re: Issues with Phidget22 after migrating to .NET 6.0 framework

Posted: Wed Apr 13, 2022 2:54 pm
by Patrick
Hi,

I'll need to replicate the issue and get back to you.

-Patrick

Re: Issues with Phidget22 after migrating to .NET 6.0 framework

Posted: Mon May 02, 2022 9:02 am
by rvb
Hello Patrick,
I worked with Arnaud (who left the project) and I would like to provide you more insights about the issue faced with Phidget22 package since we moved to .Net6 framework.

Actually the issue is systematically faced when we build our application using the option '-p:PublishSingleFile=true'.

As soon as this option is removed all works well. It is like if Phidget22 package were not compatible with that option from .Net6 framework. Previously same project was under .NetCore3.1 and we never faced same issue whereas we already built a singlefile solution.

Last week I updated the package to the latest stable version 1.10 20220413 and the issue is still there.

Can you try to reproduce that issue, then to fix it and keep us posted.
Thanks for your support.

PS: just to be fully transparent find thepublish cmd reproducing the issue with .Net6 only : "dotnet publish Phoenix.Ui -c Release -o ./Phoenix -p:PublishSingleFile=true -r win-x86 --self-contained true"

rv

Re: Issues with Phidget22 after migrating to .NET 6.0 framework

Posted: Mon May 02, 2022 1:26 pm
by Patrick
Hi,

Thanks for the insight. This issue is on my list to look into.

-Patrick

Re: Issues with Phidget22 after migrating to .NET 6.0 framework

Posted: Mon May 16, 2022 6:33 am
by rvb
Hi Patrick,
just to keep you posted I solved critical crash issue we got by porting our Phidget DLL on .Net6 framework by upgrading VS to version 17.2.

Issue was faced with VS v17.1.3 and was due to runtime dedicated to win-x86.

rv

Re: Issues with Phidget22 after migrating to .NET 6.0 framework

Posted: Mon May 16, 2022 11:29 am
by rvb
To complete the picture it seems mandatory to have the control panel installed with the same version (v1.10.20220413) than the nuggets package in use on the test station to have the solution working.

Re: Issues with Phidget22 after migrating to .NET 6.0 framework

Posted: Thu May 19, 2022 12:26 pm
by Patrick
This probably means that it's grabbing the C dll from the control panel install instead of the embedded one. I still need to work through what's going on here.

-Patrick