Q # AggregateException не может быть найден - PullRequest
0 голосов
/ 06 июля 2018

После опробования этого кода из 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.

Как мне это исправить?

1 Ответ

0 голосов
/ 06 июля 2018

Можете ли вы поделиться своим кодом C #? Учитывая, что в сообщениях об ошибках упоминается даже Console, похоже, вам не хватает using System в вашем коде C #.

...