为什么不能使用&quot&quot.writeline”在Winui3 App(C++)中?错误:' console':不是类或名称空间
我最近编写了一个简单的测试应用程序(这是一个 winUI3 应用程序(C++)),我想将一些消息发送到控制台,以帮助我进行调试。 我使用了“console.WriteLine”,但收到此错误:“Console”:不是类或命名空间。
我在微软网站上查找,但它也无法工作。(我无法在我的.cpp文件中包含“system”)
代码如下:
using namespace system; // would get this Error:'system': a namespace with this name does not exist
using namespace winrt::Windows::UI::Popups;
using namespace std;
using namespace winrt;
using namespace Windows::Foundation;
using namespace Microsoft::UI::Xaml;
namespace winrt::SampleApp::implementation
{
LoginPage::LoginPage()
{
InitializeComponent();
Console::WriteLine("hello!");
}
我查找了以下链接,但没有运气。 这是针对 c#
我只是想要一种显示消息以帮助我调试的方法。
Console是一个好方法,我也尝试了OutputDebugString但在输出窗口中没有消息输出。我哪里做错了?
有人可以帮助我吗?多谢!任何建议表示赞赏!
I recently write a simple test app(which is a winUI3 app (C++)), and I want to put some message to console, in order to help me with debugging.
I used "console.WriteLine" but get this error: 'Console': is not a class or namespace.
I looked up in the Microsoft website, but it couldn't work either.(I could not include "system" in my .cpp file)
the code is following:
using namespace system; // would get this Error:'system': a namespace with this name does not exist
using namespace winrt::Windows::UI::Popups;
using namespace std;
using namespace winrt;
using namespace Windows::Foundation;
using namespace Microsoft::UI::Xaml;
namespace winrt::SampleApp::implementation
{
LoginPage::LoginPage()
{
InitializeComponent();
Console::WriteLine("hello!");
}
I have looked up following links, but got no luck.
this is for c#
I just want a way to show the messages to help me debug.
Console is a good way, and I also tried OutputDebugString but no message output in the output window. Where did I do wrongly?
Can anyone help me? Thanks a lot! Any suggestion is appreciated!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
因为
System.Console
是一个 .NET API。如果您想在 WinUI 3 C++ 应用程序中的调试输出窗口中打印某些内容,您可以使用
OutputDebugStringA
函数:Because
System.Console
is a .NET API.If you want to print something to the debug output window in a WinUI 3 C++ app you could use the
OutputDebugStringA
function:您尝试过“cout <<”吗? “a 的值为”<<一个;'
Have you tried 'cout << "Value of a is " << a;'