using Peak.Can.Basic Reference Not Found

The free CAN Software API (Application Programming Interface) for Windows®
Locked
tpitman
Posts: 5
Joined: Tue 28. Nov 2023, 23:21

using Peak.Can.Basic Reference Not Found

Post by tpitman » Tue 28. Nov 2023, 23:27

I know the answer is going to be really obvious once someone tells me, but I can't seem to figure this out.

I have a .NET Framework 4.8 Library project.

I added the Nuget package for PCAN Basic .NET latest version 4.8.0.830.

The reference line shows a yellow warning icon over the DLL for PCANBasic.NET.

When I add using Peak.Can.Basic to a .cs file it says it can't find the reference and maybe I need to add it to the project references.

This has to be something simple because so many people have it working.

Can someone tell me what is wrong with my project that it would behave this way?

K.Wagner
Software Development
Software Development
Posts: 1080
Joined: Wed 22. Sep 2010, 13:36

Re: using Peak.Can.Basic Reference Not Found

Post by K.Wagner » Wed 29. Nov 2023, 09:21

Hello,

to have this working you have to do two things:
  1. You need to install the nuget package for your project using the "Manage NuGet Package..." command in Visual Studio (browse for 'PCAN')
  2. You need to install the PCAN drivers and the PCAN-Basic native library.
No more is needed.

If you need help for installing the NuGet package, please refer to this Microsoft topic.
In order to install drivers and library, you need to use the device drivers setup from PEAK. This can be downloaded from this page.

You can find some help on other frequently asked questions here.
Best regards,
Keneth

tpitman
Posts: 5
Joined: Tue 28. Nov 2023, 23:21

Re: using Peak.Can.Basic Reference Not Found

Post by tpitman » Wed 29. Nov 2023, 15:00

Sadly I have done all you said.

Before I even installed the package in Visual Studio, I have been using a PCAN device (the USB Dongle) on my computer with the Windows PCAN-View free app that you guys provide.

Does that mean I should already have the drivers set up or does that driver package you reference include something more that would make this work?

It is really weird that the package in Visual Studio has that yellow warning icon on it. Does that tell us anything?

K.Wagner
Software Development
Software Development
Posts: 1080
Joined: Wed 22. Sep 2010, 13:36

Re: using Peak.Can.Basic Reference Not Found

Post by K.Wagner » Wed 29. Nov 2023, 15:21

Hello,
tpitman wrote:
Wed 29. Nov 2023, 15:00
Before I even installed the package in Visual Studio, I have been using a PCAN device (the USB Dongle) on my computer with the Windows PCAN-View free app that you guys provide.
OK, this means the drivers are installed, but you need to have the same main version of the PCANBasic.dll and the assembly, for instance: if you are using the nuget v4.8.0.830, then you have to install the driver package including the PCANBasic.dll native library v4.8.0 (this case would be PEAK-Drivers Setup v4.4.1.564, our current version).
tpitman wrote:
Wed 29. Nov 2023, 15:00
It is really weird that the package in Visual Studio has that yellow warning icon on it. Does that tell us anything?
This is odd. Indifferently whether the drivers and library are installed or not, you should be able to compile your project with the nuget package. You would get an error first when you launch the project (because neither the dll nor the drivers will be found). There is nothing special to take care of except of installing the nuget as I already explained. If this doesn't work, then it can be a configuration problem in your VS or PC. I never see this problem before. This NuGet package is actually very simple... it doesn't make any special configuration or complicated setup.

I just tested creating a C# library project for .NET Framework 4.8 with Visual Studio 2022 and it works.
VS_NuGet.JPG
VS_NuGet.JPG (84.08 KiB) Viewed 7585 times
_
You can download and test this project if you want. It is attached here.
Attachments
Test-Library.zip
(17.18 KiB) Downloaded 748 times
Best regards,
Keneth

tpitman
Posts: 5
Joined: Tue 28. Nov 2023, 23:21

Re: using Peak.Can.Basic Reference Not Found

Post by tpitman » Wed 29. Nov 2023, 15:24

I figured as much as what you just described.

I will try a new project and also try loading your project. There must be something fundamental not set up correctly.

tpitman
Posts: 5
Joined: Tue 28. Nov 2023, 23:21

Re: using Peak.Can.Basic Reference Not Found

Post by tpitman » Wed 29. Nov 2023, 15:32

The good news is that I can open and build your test project. Now I just need to figure out what is different between the solutions / projects that is causing this error.

If I figure it out I will post the answer here.

If you come across anything that might be helpful, please let me know.

tpitman
Posts: 5
Joined: Tue 28. Nov 2023, 23:21

Re: using Peak.Can.Basic Reference Not Found

Post by tpitman » Wed 29. Nov 2023, 15:48

I am not 100% sure what fixed it.

There were several other assemblies that also had yellow icons on them.

I removed all of them, removed the PCAN package, added it back and now it builds.

There must have been some conflict between some of the packages.

All of the packages were Microsoft packages like Microsoft.Win32.Primitives.dll and similar.

At least now I have it working.

Thank you for sharing your project and knowledge. It helped me have confidence that my system was ok and just needed to keep after it.

K.Wagner
Software Development
Software Development
Posts: 1080
Joined: Wed 22. Sep 2010, 13:36

Re: using Peak.Can.Basic Reference Not Found

Post by K.Wagner » Wed 29. Nov 2023, 15:51

You're welcome. Closed.
Best regards,
Keneth

Locked