Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
WJMBZM opened this issue Nov 15, 2023 · 7 comments
Open

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

WJMBZM opened this issue Nov 15, 2023 · 7 comments

Comments

@WJMBZM
Copy link

WJMBZM commented Nov 15, 2023

No description provided.

@WJMBZM WJMBZM closed this as completed Nov 15, 2023
@WJMBZM WJMBZM reopened this Nov 15, 2023
@WJMBZM WJMBZM changed the title For Clr/C++ and mix-programming For Clr/C++ and C# mix-programming Nov 15, 2023
@WJMBZM WJMBZM closed this as completed Nov 15, 2023
@WJMBZM
Copy link
Author

WJMBZM commented Nov 15, 2023

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 WJMBZM reopened this Nov 15, 2023
@WJMBZM
Copy link
Author

WJMBZM commented Nov 15, 2023

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
Copy link
Collaborator

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
Copy link
Author

WJMBZM commented Nov 24, 2023

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
Copy link
Collaborator

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
Copy link

mcendu commented Dec 23, 2023

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

@pgrawehr
Copy link
Collaborator

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants