简体   繁体   中英

Does a CLR Class Library have to be run in Win32?

I created a CLR project in VS2017.

Included:

  • CLR Class Library(C++) .NET Framework 4.5
  • C# ConsoleApp

There is a simple ref class defined in the Library. The class is called from my C# code. I am fine with its performance but it does not work always.

It depends on how I run it.

  • "Debug" and "x86" works
  • "Debug" and "x64" does not work
  • "Release" and "x86" works
  • "Release" and "x64" does not work

So in Debug and Release it only works when the CLR Class Library is run in Win32.

Do I make a mistake or is this intended behaviour?

Thanks in advance!

Usually the purpose of using C++/CLI language (I assume that's what you mean by "CLR Library") is to use both native and .Net objects. Because of native code, the binary library is tied to either 32-bit or 64-bit platform. Apparently, in your case, this is 32-bit (x86).

To answer my question.

Hans Passant wrote:

Changing the solution platform only affects the C++/CLI project, not the C# project. Right-click the C# project > Properties > Build tab to select the jitter you want to use. Untick the "Prefer 32-bit" checkbox for the x64 solution configuration. Again for the Release configuration.

It worked when I unticked "Prefer 32-bit" in the C# project properties under the Build section. Thanks!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM