hexagon-oss / openhardwaremonitor

Open Hardware Monitor - a tool for monitoring hardware performance. Includes support for various temperature sensors, disk I/O ratings and power consumption.
Mozilla Public License 2.0
187 stars 21 forks source link

For Clr/C++ and C# mix-programming #58

Open WJMBZM opened 9 months ago

WJMBZM commented 9 months ago
I’m used to use C/C++ to program,but in this project,I must use some C# language,so I choose the way of Clr/C++.In old version,everything goes Ok.But now I need to suit to Intel 12\13 CPU,so I replace the DLL file named "OpenHardwareMonitorLib.dll" by your version.And then it throw a wrong,it's "未经处理的异常: System.I0.FileNotFoundException: 未能加载文件或程序集“System.Runtime,Version=6.0.0.0,Culture=neutral,PublicKeyToken=b03f5f7f11d50a3a”或它的某一个依赖项。系统找不到指定的文件。"
It seems to be that I'm lack of something.Could you help me to find what wrong I'm making.Thank you!
WJMBZM commented 9 months ago

This wrong is "Unhandled exception: System. I0. FileNotFound Exception: Could not load file or assembly 'System. Runtime, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the specified file."

pgrawehr commented 9 months ago

How exactly are you starting your process? The new version uses .NET 6.0 and therefore might need a change in how you start the application.

WJMBZM commented 9 months ago
Yeah,I find it,the previous version uses .Net Framework 4.8, and this new version use .Net core 6.0.So this may be the problem that I meet.
This Image shows what mode I can choose.

CLR_Mode There are 3 usual mode (there is no CLR || .Net runtime support(clr/.net:core) || .Net Framework runtime support(clr)). I use CLR(Common language runtime support) so that I can use this C# DLL(dynamic link lib) in C++\CLI platform(visual studio),It seems that .Net Core cant use C# DLL ,or I should use some other methods. I try to change .Net Core to .Net Framework,or I try to find another way to use C# DLL in C++\CLI platform with .Net Core. I'm the beginner of C#,It's so sorry to bother u so much.

/*   And I have another question,It's how to get the family or model of CPUs.
I can find "AlderLake" of 12th generation CPU,"RaptorLake" of 13th generation CPU .But the code of CPU family(model),like 0x97(Intel Core 12th in PC),0x9A(Intel Core 12th in Mobile),0xB7\0XBA(Intel Core 13th).
How should I get this.(when 14th 15th......appear)   */

I have found the mothod of getting family and model.- o -`
Thanks for ur help.
pgrawehr commented 9 months ago

Yea, you need to use the /clr:netcore setting, and then (in one of the other dropdown boxes) select .NET 6.0. You might need to close and reopen the dialog to get the correct list of options there.

About your other questions: We don't know. We need to wait until the new CPUs come out and then add the new family IDs.

mcendu commented 8 months ago

Does C++/CLI even exist for .NET Core?

pgrawehr commented 8 months ago

@mcendu Yes, C++/CLI support is still available in .NET 6.0 and above. It looks like it's not getting that much attention, so things may get a bit ugly (e.g. referencing other C# libraries may need a bit of trickery), but if you just need it as a wrapper for an unmanaged library, it still works.