Skip to content

[Bug] Azure.AI.OpenAI v2.x fails to compile on .NET 9 SDK on Linux (CS0246), but v1.0.0-beta.12 works #52872

@CrisSTEM

Description

@CrisSTEM

Library name and version

Azure.AI.OpenAI, versions 2.0.0 and 2.1.0.

Describe the bug

When using version 2.0.0 or newer of the Azure.AI.OpenAI package on a Linux environment with the .NET 9 SDK, the build fails with error CS0246: The type or namespace name 'OpenAIClient' could not be found.

This happens despite having the correct using Azure.AI.OpenAI; directive and a valid project reference. The issue is reproducible in a minimal console application.

Downgrading the package to 1.0.0-beta.12 resolves the compilation issue. This suggests an assembly resolution problem in the v2.x packages on this specific environment, possibly related to the transitive dependency on the OpenAI package introduced in v2.0.0.

Expected behavior

The project should compile and run successfully without any errors.

Actual behavior

The build fails with the following compilation error:

error CS0246: The type or namespace name 'OpenAIClient' could not be found (are you missing a using directive or an assembly reference?)

Reproduction Steps

  1. Create a new console application targeting .NET 9.
    dotnet new console --framework net9.0
  2. Add a reference to a failing version of the package.
    dotnet add package Azure.AI.OpenAI --version 2.1.0
  3. Replace the content of Program.cs with the following code:
    using Azure.AI.OpenAI;
    using Azure;
    
    Console.WriteLine("Testing OpenAIClient initialization...");
    
    // This line fails to compile
    OpenAIClient client = new OpenAIClient(new Uri("[https://dummy.openai.azure.com/](https://dummy.openai.azure.com/)"), new AzureKeyCredential("dummy-key"));
    
    Console.WriteLine("SUCCESS! OpenAIClient class was found.");
  4. Try to build or run the project.
    dotnet run

Environment

  • OS: Debian GNU/Linux 13 (trixie)
  • Architecture: x86_64
  • .NET SDK Version: 9.0.305
  • IDE: Command Line / VS Code
Full `dotnet --info` output

.NET SDK:
Version:           9.0.305
Commit:            3fc74f3529
Workload version:  9.0.300-manifests.ddedba1d
MSBuild version:   17.14.21+8929ca9e3

Runtime Environment:
OS Name:     debian
OS Version:  13
OS Platform: Linux
RID:         linux-x64
Base Path:   /usr/share/dotnet/sdk/9.0.305/

.NET workloads installed:
There are no installed workloads to display.
Configured to use loose manifests when installing new manifests.

Host:
Version:      9.0.9
Architecture: x64
Commit:       893c2ebbd4

.NET SDKs installed:
9.0.305 [/usr/share/dotnet/sdk]

.NET runtimes installed:
Microsoft.AspNetCore.App 9.0.9 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 9.0.9 [/usr/share/dotnet/shared/Microsoft.NETCore.App]

Other architectures found:
None

Environment variables:
Not set

global.json file:
Not found

Metadata

Metadata

Assignees

No one assigned

    Labels

    ClientThis issue is related to a non-management packageOpenAIService AttentionWorkflow: This issue is responsible by Azure service team.customer-reportedIssues that are reported by GitHub users external to the Azure organization.needs-team-attentionWorkflow: This issue needs attention from Azure service team or SDK teamquestionThe issue doesn't require a change to the product in order to be resolved. Most issues start as that

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions