是否必须在Win32中运行CLR类库? [英] Does a CLR Class Library have to be run in Win32?
问题描述
我在VS2017中创建了一个CLR项目.
I created a CLR project in VS2017.
包含:
- CLR类库(C ++).NET Framework 4.5
- C#ConsoleApp
在库中定义了一个简单的ref类.该类是从我的C#代码中调用的.我对它的性能很好,但是它并不总是能正常工作.
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.
- 调试"和"x86"有效
- 调试"和"x64"不起作用
- 发布"和"x86"有效
- 发布"和"x64"不起作用
因此,在Debug and Release中,它仅在Win32中运行CLR类库时有效.
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?
提前谢谢!
推荐答案
回答我的问题.
Hans Passant写道:
Hans Passant wrote:
更改解决方案平台只会影响C ++/CLI项目,而不会影响C#项目.右键单击C#项目>属性">构建"选项卡,以选择要使用的抖动.取消选中x64解决方案配置的首选32位"复选框.再次进行Release配置.
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.
当我在构建"部分下的C#项目属性中取消选中首选32位"时,此方法有效.谢谢!
It worked when I unticked "Prefer 32-bit" in the C# project properties under the Build section. Thanks!
这篇关于是否必须在Win32中运行CLR类库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!