Page 1 of 2

Error referencing KMotion_dotnet dll on .NET 6.0 project

Posted: Wed Jan 10, 2024 11:50 pm
by gui_marchioro
Hello,

I am getting an error when trying to reference the KMotion_dotnet on a .NET 6.0 project. It states that it is not possible to load file or assembly.
kmotion_dotnet_error.png
Is there a workaround that I can do in this situation?

Here you can see the reference to the dll:
kmotion_dotnet_error2.png
Sincerely,
Guilherme

Re: Error referencing KMotion_dotnet dll on .NET 6.0 project

Posted: Thu Jan 11, 2024 3:10 am
by TomKerekes
Hi Guilherme,

Please read this Thread.

Re: Error referencing KMotion_dotnet dll on .NET 6.0 project

Posted: Thu Jan 11, 2024 8:12 pm
by gui_marchioro
Hello,

Thanks for the reply.
I upgraded the library to the same version as my app but still the same error occurs, so perhaps this was not the problem.

Sincerely,
Guilherme

Re: Error referencing KMotion_dotnet dll on .NET 6.0 project

Posted: Thu Jan 11, 2024 8:29 pm
by TomKerekes
Hi Guilherme,

Did you rebuild the Debug | x86 Configuration libraries?

You might try building/running the SimpleFormsCS example to see if it works.

Re: Error referencing KMotion_dotnet dll on .NET 6.0 project

Posted: Thu Jan 11, 2024 9:24 pm
by gui_marchioro
Hello

Do you mean the ones from BuildAllLibs.sln? If so, yes I did.

I tested upgrading SimpleForms and it worked. However, the same is not true for SimpleGCodeWPF, which is issuing the same error as my app does.

Sincerely,
Guilherme

Re: Error referencing KMotion_dotnet dll on .NET 6.0 project

Posted: Sat Jan 13, 2024 5:06 pm
by gui_marchioro
Hello,

Well I think I'll be forced to use the old .NET framework in my project, since I can't solve the problem and don't want to spend more time on it.

Maybe if someone reading this is able to use newer versions please comment here how it can be done.

Sincerely,
Guilherme

Re: Error referencing KMotion_dotnet dll on .NET 6.0 project

Posted: Sun Jan 14, 2024 8:12 pm
by TomKerekes
Hi Guilherme,

I tested SimpleGCodeWPF without any problem.

I think your App might be building as AnyCPU rather than what is consistent with the KMotion_dotNet Library.

Here is what I did:

Fresh Install 5.3.1
Open BuildAllLibs.sln
Upgrade KMotion_dotNet to .NET 7
Select Configuration to Debug | x86
ReBuild
Open BuildExamples.sln
Upgrade SimpleGCodeWPF to .NET 7
Note VS22 seems to have a bug that doesn't allow Configuration Manager to select x86 platform to be selected
Removing and re-Adding the SimpleGCodeWPF project to the Solution fixes something
Set Configuration Manager Debug | x86 to build SimpleGCodeWPF as Debug | x86
Select Configuration to Debug | x86
ReBuild SimpleGCodeWPF

HTH

Re: Error referencing KMotion_dotnet dll on .NET 6.0 project

Posted: Thu Jan 18, 2024 6:36 pm
by gui_marchioro
Hello Tom, thanks for the reply.

Yes, as you said both KMotion_dotNet and SimpleGCodeWPF were targeting AnyCPU configuration.
I've made the changes you listed step by step, but still I get the same error.

Is there anything else I could try?

Sincerely,
Guilherme

Re: Error referencing KMotion_dotnet dll on .NET 6.0 project

Posted: Mon Jan 22, 2024 11:20 pm
by TomKerekes
Hi Guilherme,

I tried Upgrading to .NET 7 on another computer (HP Laptop W11 64-bit) and had a few issues but eventually got it to work.

You are using Upgrade Assistant correct? This needs to be installed.

My VS22 was somewhat old 17.4 and upgraded assistant wouldn't work correctly. I updated VS22 to the current latest 17.8.5

I had to install .NET 7 SDK. Even though I only planned to use 32-bit (x86) I found I had to install 32-bit and 64-bit .NET 7 SDKs to get Upgrade to work. I installed Version 7.0.312 for both. Also I installed the 7.0.405 Security Patch.

I noticed code was being placed in C:\KMotion5.3.1\KMotion\Debug\net7.0-windows instead of C:\KMotion5.3.1\KMotion\Debug. Running from VS gave the KMotion_dotNet.dll error. But looking at the inner exception details it shows a root problem loading KMotion_dotNet_Interop.dll I think VS is running from thenet7.0-windows folder which doesn't contain KMotion_dotNet_Interop.dll

I found 2 solutions:

#1 - tell VS to set the working directory to C:\KMotion5.3.1\KMotion\Debug so it finds all the necessary dlls.

WorkingDirectory.png

#2 - is probably the better solution is to place the output properly in C:\KMotion5.3.1\KMotion\Debug. There doesn't seem to be any way to stop from appending the Target Framework folder for the output except by manually editing the C# project file. Within the PropertyGroup set the AppendTargetFrameworkToOutputPath to false.

AppendFalse.png

Note there seems to be an issue/bug in VS2022 where right click project | Edit Project File sometimes doesn't appear in the context menu unless the project is unloaded first.

Re: Error referencing KMotion_dotnet dll on .NET 6.0 project

Posted: Thu Feb 01, 2024 3:38 am
by gui_marchioro
Hi Tom,

I am currently using VS 2022 (64-bit) V 17.8.6, which indeed has the Upgrade Assistant.
I installed the SDKs that you mentioned and retried the process, but still the error persisted. I also noticed that the code was being placed inside the folder you pointed, and tried the workarounds proposed, which were not successful. :cry:
I don't know what else I could be missing in the upgrade.

Did you get the same error when trying to upgrade?
error_SimpleGCodeWPF.png
Sincerely,
Guilherme