智能感知:“#using”需要启用 C++/CLI

发布于 2024-10-17 06:07:33 字数 330 浏览 2 评论 0原文

#using <mscorlib.dll>
#using <System.dll>
using namespace System;
using namespace System::Text;
using namespace System::IO;
using namespace System::Net;
using namespace System::Net::Sockets;
using namespace System::Collections;

错误:IntelliSense:“#using”需要启用 C++/CLI...

如何解决此问题!?

#using <mscorlib.dll>
#using <System.dll>
using namespace System;
using namespace System::Text;
using namespace System::IO;
using namespace System::Net;
using namespace System::Net::Sockets;
using namespace System::Collections;

Errors: IntelliSense: "#using" requires C++/CLI to be enabled....

how to fix this prob!?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

一城柳絮吹成雪 2024-10-24 06:07:33

您的项目设置错误。特别是配置属性、常规、公共语言运行时支持。

通过在 CLR 节点中选择一个项目模板来启动您的项目,从而陷入成功的深渊。

Your project settings are wrong. Specifically Configuration Properties, General, Common Language Runtime support.

Fall in the pit of success by starting your project by picking one of the project templates in the CLR node.

浊酒尽余欢 2024-10-24 06:07:33

选择项目 ->菜单栏中的属性。在“项目属性”窗口中的“配置”下“属性”-> 常规,确保将公共语言运行时支持设置为公共语言运行时支持(/clr)

在VS2019中,步骤如下:

  • < p>1/ 右键单击​​项目

  • 2/ 项目

  • 3/ 属性

  • 4/ 配置属性

  • 5/ 高级

  • 6/ 公共语言运行时支持 将其更改为 < code>Common Language Runtime Support(/clr)

Choose Project -> Properties from the menu bar. In the Project properties window, under Configuration Properties -> General, make sure that Common Language Runtime Support is set to Common Language Runtime Support (/clr)

In VS2019 it the steps would be :

  • 1/ Right click on the project

  • 2/ Project

  • 3/ Properties

  • 4/ Configuration Properties

  • 5/ Advanced

  • 6/ Common Language Runtime Support change it to Common Language Runtime Support(/clr)

哭了丶谁疼 2024-10-24 06:07:33

在项目设置中启用它(右键单击项目 -> 设置),第一个选项卡应提供该选项。

Enable it in your project settings (right click on the projet -> settings) the first tab should provide the option.

那一片橙海, 2024-10-24 06:07:33

MSDN 有一个很好的示例来测试 Parse 与 tryParse 的性能差异:
秒表示例

#include <stdio.h>
#using <System.dll>

using namespace System;
using namespace System::Diagnostics;

void DisplayTimerProperties()
{
    // Display the timer frequency and resolution.
    if (Stopwatch::IsHighResolution)
    {
        Console::WriteLine("Operations timed using the system's high-resolution performance counter.");
    }
    else
    {
        Console::WriteLine("Operations timed using the DateTime class.");
    }

    Int64 frequency = Stopwatch::Frequency;
    Console::WriteLine("  Timer frequency in ticks per second = {0}", frequency);
    Int64 nanosecPerTick = (1000L * 1000L * 1000L) / frequency;
    Console::WriteLine("  Timer is accurate within {0} nanoseconds", nanosecPerTick);
}

void TimeOperations()
{
    Int64 nanosecPerTick = (1000L * 1000L * 1000L) / Stopwatch::Frequency;
    const long numIterations = 10000;

    // Define the operation title names.
    array<String^>^operationNames = { "Operation: Int32.Parse(\"0\")","Operation: Int32.TryParse(\"0\")","Operation: Int32.Parse(\"a\")","Operation: Int32.TryParse(\"a\")" };

    // Time four different implementations for parsing 
    // an integer from a string. 
    for (int operation = 0; operation <= 3; operation++)
    {
        // Define variables for operation statistics.
        Int64 numTicks = 0;
        Int64 numRollovers = 0;
        Int64 maxTicks = 0;
        Int64 minTicks = Int64::MaxValue;
        int indexFastest = -1;
        int indexSlowest = -1;
        Int64 milliSec = 0;
        Stopwatch ^ time10kOperations = Stopwatch::StartNew();

        // Run the current operation 10001 times.
        // The first execution time will be tossed
        // out, since it can skew the average time.
        for (int i = 0; i <= numIterations; i++)
        {
            Int64 ticksThisTime = 0;
            int inputNum;
            Stopwatch ^ timePerParse;
            switch (operation)
            {
            case 0:

                // Parse a valid integer using
                // a try-catch statement.
                // Start a new stopwatch timer.
                timePerParse = Stopwatch::StartNew();
                try
                {
                    inputNum = Int32::Parse("0");
                }
                catch (FormatException^)
                {
                    inputNum = 0;
                }

                // Stop the timer, and save the
                // elapsed ticks for the operation.
                timePerParse->Stop();
                ticksThisTime = timePerParse->ElapsedTicks;
                break;

            case 1:

                // Parse a valid integer using
                // the TryParse statement.
                // Start a new stopwatch timer.
                timePerParse = Stopwatch::StartNew();
                if (!Int32::TryParse("0", inputNum))
                {
                    inputNum = 0;
                }

                // Stop the timer, and save the
                // elapsed ticks for the operation.
                timePerParse->Stop();
                ticksThisTime = timePerParse->ElapsedTicks;
                break;

            case 2:

                // Parse an invalid value using
                // a try-catch statement.
                // Start a new stopwatch timer.
                timePerParse = Stopwatch::StartNew();
                try
                {
                    inputNum = Int32::Parse("a");
                }
                catch (FormatException^)
                {
                    inputNum = 0;
                }

                // Stop the timer, and save the
                // elapsed ticks for the operation.
                timePerParse->Stop();
                ticksThisTime = timePerParse->ElapsedTicks;
                break;

            case 3:

                // Parse an invalid value using
                // the TryParse statement.
                // Start a new stopwatch timer.
                timePerParse = Stopwatch::StartNew();
                if (!Int32::TryParse("a", inputNum))
                {
                    inputNum = 0;
                }

                // Stop the timer, and save the
                // elapsed ticks for the operation.
                timePerParse->Stop();
                ticksThisTime = timePerParse->ElapsedTicks;
                break;

            default:
                break;
            }

            // Skip over the time for the first operation,
            // just in case it caused a one-time
            // performance hit.
            if (i == 0)
            {
                time10kOperations->Reset();
                time10kOperations->Start();
            }
            else
            {
                // Update operation statistics
                // for iterations 1-10001.
                if (maxTicks < ticksThisTime)
                {
                    indexSlowest = i;
                    maxTicks = ticksThisTime;
                }
                if (minTicks > ticksThisTime)
                {
                    indexFastest = i;
                    minTicks = ticksThisTime;
                }
                numTicks += ticksThisTime;
                if (numTicks < ticksThisTime)
                {
                    // Keep track of rollovers.
                    numRollovers++;
                }
            }
        }

        // Display the statistics for 10000 iterations.
        time10kOperations->Stop();
        milliSec = time10kOperations->ElapsedMilliseconds;
        Console::WriteLine();
        Console::WriteLine("{0} Summary:", operationNames[operation]);
        Console::WriteLine("  Slowest time:  #{0}/{1} = {2} ticks", indexSlowest, numIterations, maxTicks);
        Console::WriteLine("  Fastest time:  #{0}/{1} = {2} ticks", indexFastest, numIterations, minTicks);
        Console::WriteLine("  Average time:  {0} ticks = {1} nanoseconds", numTicks / numIterations, (numTicks * nanosecPerTick) / numIterations);
        Console::WriteLine("  Total time looping through {0} operations: {1} milliseconds", numIterations, milliSec);

    }
}

int main()
{
    DisplayTimerProperties();
    Console::WriteLine();
    Console::WriteLine("Press the Enter key to begin:");
    Console::ReadLine();
    Console::WriteLine();
    TimeOperations();

    getchar();
}



//Operations timed using the system's high-resolution performance counter.
//Timer frequency in ticks per second = 3319338
//Timer is accurate within 301 nanoseconds
//
//Press the Enter key to begin :
//
//
//
//Operation : Int32.Parse("0") Summary :
//  Slowest time : #4483 / 10000 = 95 ticks
//  Fastest time : #3 / 10000 = 0 ticks
//  Average time : 0 ticks = 99 nanoseconds
//  Total time looping through 10000 operations : 1 milliseconds
//
//  Operation : Int32.TryParse("0") Summary :
//  Slowest time : #7720 / 10000 = 187 ticks
//  Fastest time : #1 / 10000 = 0 ticks
//  Average time : 0 ticks = 109 nanoseconds
//  Total time looping through 10000 operations : 1 milliseconds
//
//  Operation : Int32.Parse("a") Summary :
//  Slowest time : #3701 / 10000 = 2388 ticks
//  Fastest time : #2698 / 10000 = 102 ticks
//  Average time : 116 ticks = 35109 nanoseconds
//  Total time looping through 10000 operations : 352 milliseconds
//
//  Operation : Int32.TryParse("a") Summary :
//  Slowest time : #8593 / 10000 = 23 ticks
//  Fastest time : #1 / 10000 = 0 ticks
//  Average time : 0 ticks = 88 nanoseconds
//  Total time looping through 10000 operations : 1 milliseconds

The MSDN has a nice example for testing the difference in performance, Parse vs tryParse:
Stopwatch Example

#include <stdio.h>
#using <System.dll>

using namespace System;
using namespace System::Diagnostics;

void DisplayTimerProperties()
{
    // Display the timer frequency and resolution.
    if (Stopwatch::IsHighResolution)
    {
        Console::WriteLine("Operations timed using the system's high-resolution performance counter.");
    }
    else
    {
        Console::WriteLine("Operations timed using the DateTime class.");
    }

    Int64 frequency = Stopwatch::Frequency;
    Console::WriteLine("  Timer frequency in ticks per second = {0}", frequency);
    Int64 nanosecPerTick = (1000L * 1000L * 1000L) / frequency;
    Console::WriteLine("  Timer is accurate within {0} nanoseconds", nanosecPerTick);
}

void TimeOperations()
{
    Int64 nanosecPerTick = (1000L * 1000L * 1000L) / Stopwatch::Frequency;
    const long numIterations = 10000;

    // Define the operation title names.
    array<String^>^operationNames = { "Operation: Int32.Parse(\"0\")","Operation: Int32.TryParse(\"0\")","Operation: Int32.Parse(\"a\")","Operation: Int32.TryParse(\"a\")" };

    // Time four different implementations for parsing 
    // an integer from a string. 
    for (int operation = 0; operation <= 3; operation++)
    {
        // Define variables for operation statistics.
        Int64 numTicks = 0;
        Int64 numRollovers = 0;
        Int64 maxTicks = 0;
        Int64 minTicks = Int64::MaxValue;
        int indexFastest = -1;
        int indexSlowest = -1;
        Int64 milliSec = 0;
        Stopwatch ^ time10kOperations = Stopwatch::StartNew();

        // Run the current operation 10001 times.
        // The first execution time will be tossed
        // out, since it can skew the average time.
        for (int i = 0; i <= numIterations; i++)
        {
            Int64 ticksThisTime = 0;
            int inputNum;
            Stopwatch ^ timePerParse;
            switch (operation)
            {
            case 0:

                // Parse a valid integer using
                // a try-catch statement.
                // Start a new stopwatch timer.
                timePerParse = Stopwatch::StartNew();
                try
                {
                    inputNum = Int32::Parse("0");
                }
                catch (FormatException^)
                {
                    inputNum = 0;
                }

                // Stop the timer, and save the
                // elapsed ticks for the operation.
                timePerParse->Stop();
                ticksThisTime = timePerParse->ElapsedTicks;
                break;

            case 1:

                // Parse a valid integer using
                // the TryParse statement.
                // Start a new stopwatch timer.
                timePerParse = Stopwatch::StartNew();
                if (!Int32::TryParse("0", inputNum))
                {
                    inputNum = 0;
                }

                // Stop the timer, and save the
                // elapsed ticks for the operation.
                timePerParse->Stop();
                ticksThisTime = timePerParse->ElapsedTicks;
                break;

            case 2:

                // Parse an invalid value using
                // a try-catch statement.
                // Start a new stopwatch timer.
                timePerParse = Stopwatch::StartNew();
                try
                {
                    inputNum = Int32::Parse("a");
                }
                catch (FormatException^)
                {
                    inputNum = 0;
                }

                // Stop the timer, and save the
                // elapsed ticks for the operation.
                timePerParse->Stop();
                ticksThisTime = timePerParse->ElapsedTicks;
                break;

            case 3:

                // Parse an invalid value using
                // the TryParse statement.
                // Start a new stopwatch timer.
                timePerParse = Stopwatch::StartNew();
                if (!Int32::TryParse("a", inputNum))
                {
                    inputNum = 0;
                }

                // Stop the timer, and save the
                // elapsed ticks for the operation.
                timePerParse->Stop();
                ticksThisTime = timePerParse->ElapsedTicks;
                break;

            default:
                break;
            }

            // Skip over the time for the first operation,
            // just in case it caused a one-time
            // performance hit.
            if (i == 0)
            {
                time10kOperations->Reset();
                time10kOperations->Start();
            }
            else
            {
                // Update operation statistics
                // for iterations 1-10001.
                if (maxTicks < ticksThisTime)
                {
                    indexSlowest = i;
                    maxTicks = ticksThisTime;
                }
                if (minTicks > ticksThisTime)
                {
                    indexFastest = i;
                    minTicks = ticksThisTime;
                }
                numTicks += ticksThisTime;
                if (numTicks < ticksThisTime)
                {
                    // Keep track of rollovers.
                    numRollovers++;
                }
            }
        }

        // Display the statistics for 10000 iterations.
        time10kOperations->Stop();
        milliSec = time10kOperations->ElapsedMilliseconds;
        Console::WriteLine();
        Console::WriteLine("{0} Summary:", operationNames[operation]);
        Console::WriteLine("  Slowest time:  #{0}/{1} = {2} ticks", indexSlowest, numIterations, maxTicks);
        Console::WriteLine("  Fastest time:  #{0}/{1} = {2} ticks", indexFastest, numIterations, minTicks);
        Console::WriteLine("  Average time:  {0} ticks = {1} nanoseconds", numTicks / numIterations, (numTicks * nanosecPerTick) / numIterations);
        Console::WriteLine("  Total time looping through {0} operations: {1} milliseconds", numIterations, milliSec);

    }
}

int main()
{
    DisplayTimerProperties();
    Console::WriteLine();
    Console::WriteLine("Press the Enter key to begin:");
    Console::ReadLine();
    Console::WriteLine();
    TimeOperations();

    getchar();
}



//Operations timed using the system's high-resolution performance counter.
//Timer frequency in ticks per second = 3319338
//Timer is accurate within 301 nanoseconds
//
//Press the Enter key to begin :
//
//
//
//Operation : Int32.Parse("0") Summary :
//  Slowest time : #4483 / 10000 = 95 ticks
//  Fastest time : #3 / 10000 = 0 ticks
//  Average time : 0 ticks = 99 nanoseconds
//  Total time looping through 10000 operations : 1 milliseconds
//
//  Operation : Int32.TryParse("0") Summary :
//  Slowest time : #7720 / 10000 = 187 ticks
//  Fastest time : #1 / 10000 = 0 ticks
//  Average time : 0 ticks = 109 nanoseconds
//  Total time looping through 10000 operations : 1 milliseconds
//
//  Operation : Int32.Parse("a") Summary :
//  Slowest time : #3701 / 10000 = 2388 ticks
//  Fastest time : #2698 / 10000 = 102 ticks
//  Average time : 116 ticks = 35109 nanoseconds
//  Total time looping through 10000 operations : 352 milliseconds
//
//  Operation : Int32.TryParse("a") Summary :
//  Slowest time : #8593 / 10000 = 23 ticks
//  Fastest time : #1 / 10000 = 0 ticks
//  Average time : 0 ticks = 88 nanoseconds
//  Total time looping through 10000 operations : 1 milliseconds
云淡月浅 2024-10-24 06:07:33

如果您使用Visual Studio,您可能需要预先进行一些安装。要安装它们,请从 Windows“开始”菜单打开 Visual Studio 安装程序。确保选中使用 C++ 进行桌面开发磁贴,并在可选组件部分中选中C++/CLI 支持

If you are using Visual Studio, you might have to do some installations pre-hand. To install those, open the Visual Studio Installer from the Windows Start menu. Make sure that the Desktop development with C++ tile is checked, and in the Optional components section, also check C++/CLI Support.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文