首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >找不到Q# AggregateException

找不到Q# AggregateException
EN

Stack Overflow用户
提问于 2018-07-06 12:25:43
回答 1查看 120关注 0票数 1

在从https://learn.microsoft.com/en-us/quantum/quantum-simulatorsandmachines?view=qsharp-preview中试用这段代码之后

代码语言:javascript
复制
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}");
        }
    }
}

我得到了以下错误:

代码语言:javascript
复制
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.

我该怎么解决这个问题?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-07-06 15:18:43

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

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/51210455

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档