Skip to content

.NET: [Bug]: MissingMethodException in ProcessDataContentAttachmentsAsync due to binary incompatibility with GitHub.Copilot.SDK #3869

@normalian

Description

@normalian

Description

When using the NuGet package Microsoft.Agents.AI.GitHub.Copilot (version 1.0.0-preview.260209.1), a MissingMethodException occurs when sending messages with attachments.

Code Sample

using GitHub.Copilot.SDK;
using Microsoft.Agents.AI;
using Microsoft.Agents.AI.GitHub.Copilot;
using Microsoft.Extensions.AI;

using var copilotClient = new CopilotClient();
var config = new SessionConfig { Model = "claude-3.5-sonnet" };
var agent = new GitHubCopilotAgent(copilotClient, config);

await agent.CreateSessionAsync();

string filePath = "Program.cs"; 
byte[] fileBytes = await File.ReadAllBytesAsync(filePath);
string mimeType = "text/plain"; 

var message = new ChatMessage(ChatRole.User, "What's the best practice to test private methods?");

message.Contents.Add(new DataContent(fileBytes, mimeType));

var messages = new List<ChatMessage> { message };

try
{
    Console.WriteLine($"Sending message with attachment: {filePath}...");
    var response = await agent.RunAsync(messages);
    Console.WriteLine("--- Agent Response ---");
    Console.WriteLine(response);
}
catch (Exception ex)
{
    Console.WriteLine($"Error: {ex.Message}");
    if (ex.InnerException != null)
        Console.WriteLine($"Inner: {ex.InnerException.Message}");
}

Error Messages / Stack Traces

Method not found: 'Void GitHub.Copilot.SDK.UserMessageDataAttachmentsItem.set_Type(GitHub.Copilot.SDK.UserMessageDataAttachmentsItemType)'.
at Microsoft.Agents.AI.GitHub.Copilot.GitHubCopilotAgent.<ProcessDataContentAttachmentsAsync>d__33.MoveNext()

Package Versions

Microsoft.Agents.AI.GitHub.Copilot: 1.0.0-preview.260209.1

.NET Version

.NET 9.0

Additional Context

Investigation
The Cause: The property UserMessageDataAttachmentsItem.Type in the latest GitHub.Copilot.SDK appears to have changed its setter (e.g., from set to init), breaking binary compatibility with the pre-compiled NuGet package.

Evidence: - Using the NuGet package results in the error above.

However, cloning this repository and referencing the source code directly works perfectly, because the code is re-compiled against the latest SDK during the local build.

Metadata

Metadata

Labels

.NETbugSomething isn't workingv1.0Features being tracked for the version 1.0 GA

Type

Projects

Status

No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions