Skip to content

Fix MissingMethodException in GitHub Copilot attachment handling#3881

Closed
Copilot wants to merge 4 commits intomainfrom
copilot/fix-missingmethodexception-issue
Closed

Fix MissingMethodException in GitHub Copilot attachment handling#3881
Copilot wants to merge 4 commits intomainfrom
copilot/fix-missingmethodexception-issue

Conversation

Copy link
Contributor

Copilot AI commented Feb 12, 2026

Motivation and Context

Binary incompatibility with GitHub.Copilot.SDK v0.1.18+ caused MissingMethodException when sending messages with DataContent attachments. The SDK changed from a base class with settable Type property to specific typed attachment classes.

Description

Updated GitHub.Copilot.SDK to v0.1.23

  • Changed from v0.1.18 in Directory.Packages.props

Fixed attachment API usage in GitHubCopilotAgent.cs

- attachments.Add(new UserMessageDataAttachmentsItem
+ attachments.Add(new UserMessageDataAttachmentsItemFile
  {
-   Type = UserMessageDataAttachmentsItemType.File,
    Path = tempFilePath,
    DisplayName = Path.GetFileName(tempFilePath)
  });

The new SDK provides three typed classes for attachments:

  • UserMessageDataAttachmentsItemFile - for file attachments
  • UserMessageDataAttachmentsItemDirectory - for directory attachments
  • UserMessageDataAttachmentsItemSelection - for text selections

Each has a read-only Type property with the appropriate constant value.

Contribution Checklist

  • The code builds clean without any errors or warnings
  • The PR follows the Contribution Guidelines
  • All unit tests pass, and I have added new tests where possible
  • Is this a breaking change? If yes, add "[BREAKING]" prefix to the title of the PR.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • www.nuget.org
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node /home/REDACTED/work/_temp/ghcca-node/node/bin/node --enable-source-maps /home/REDACTED/work/_temp/copilot-developer-action-main/dist/index.js (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>.NET: [Bug]: MissingMethodException in ProcessDataContentAttachmentsAsync due to binary incompatibility with GitHub.Copilot.SDK</issue_title>
<issue_description>### 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.</issue_description>

<agent_instructions>Fix the bug reported in this issue. As part of the fix update to the latest version of the GitHub.Copilot.SDK and fix any other breaking changes.</agent_instructions>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

…hange

Co-authored-by: markwallace-microsoft <127216156+markwallace-microsoft@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix MissingMethodException in ProcessDataContentAttachmentsAsync Fix MissingMethodException in GitHub Copilot attachment handling Feb 12, 2026
@markwallace-microsoft markwallace-microsoft marked this pull request as ready for review February 13, 2026 14:32
Copilot AI review requested due to automatic review settings February 13, 2026 14:32
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot wasn't able to review any files in this pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

2 participants