我有一个c ++ WinRT组件,添加到我的控制台应用程序参考.它编译时没有任何错误,但在运行app时会出现以下错误
mscorlib.dll中发生了未处理的"System.TypeLoadException"类型异常
附加信息:找不到Windows运行时类型'ProcessorInfoComponent.ProcessorInfoProvider'. 我的错误
这是我的代码:
.h文件:
#pragma once
namespace ProcessorInfoComponent
{
public ref class ProcessorInfoProvider sealed
{
public:
bool IsNeonSupported();
};
}
Run Code Online (Sandbox Code Playgroud)
.cpp文件:
#include "pch.h"
#include "ProcessorInfoComponent.h"
using namespace ProcessorInfoComponent;
bool ProcessorInfoProvider::IsNeonSupported()
{
return IsProcessorFeaturePresent(PF_ARM_VFP_32_REGISTERS_AVAILABLE);
}
Run Code Online (Sandbox Code Playgroud)
在c#中使用是:.cs
static void Main(string[] args)
{
var processorInfoProvider = new ProcessorInfoComponent.ProcessorInfoProvider();
var isNeonSupported = processorInfoProvider.IsNeonSupported();
Console.WriteLine(isNeonSupported);
}
Run Code Online (Sandbox Code Playgroud)
这个WinRT在Windows手机和WPF APP中工作得很好,但在Windows窗体和控制台应用程序中无法正常工作.谢谢.