【问题标题】:Q# AggregateException could not be foundQ# AggregateException 找不到
【发布时间】:2018-07-06 12:25:43
【问题描述】:

https://docs.microsoft.com/en-us/quantum/quantum-simulatorsandmachines?view=qsharp-preview试用此代码后

try
{
    using (var sim = new QuantumSimulator())
    {
        /// call your operations here...
    }
}
catch (AggregateException e)
{
    // Unwrap AggregateException to get the message from Q# fail statement.
    // Go through all inner exceptions.
    foreach (Exception inner in e.InnerExceptions)
    {
        // If the exception of type ExecutionFailException
        if (inner is ExecutionFailException failException)
        {
            // Print the message it contains
            Console.WriteLine($" {failException.Message}");
        }
    }
}

我收到以下错误:

Driver.cs(29,20): error CS0246: The type or namespace name 'AggregateException' could not be found (are you missing a using directive or an assembly reference?) [/home/tinkidinki/Quantum/Bell/Bell.csproj]
Driver.cs(33,26): error CS0246: The type or namespace name 'Exception' could not be found (are you missing a using directiveor an assembly reference?) [/home/tinkidinki/Quantum/Bell/Bell.csproj]
Driver.cs(38,25): error CS0103: The name 'Console' does not exist in the current context [/home/tinkidinki/Quantum/Bell/Bell.csproj]

The build failed. Please fix the build errors and run again.

我该如何解决这个问题?

【问题讨论】:

标签: c# error-handling exception-handling quantum-computing q#


【解决方案1】:

你能分享你的整个 C# 代码吗?鉴于错误消息甚至提到了 Console,看起来您在 C# 代码中缺少 using System

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-03-28
    • 2018-09-07
    • 2019-03-19
    • 1970-01-01
    • 1970-01-01
    • 2016-01-27
    • 1970-01-01
    相关资源
    最近更新 更多