Drizin / Drizin/CodegenCS

Visual Studio 2026 XmlDocument not found

Open
#38 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
307
Forks
40
PR merge metrics
No merged PRs in 30d

Description

I am using the NuGet Package `CodegenCS.SourceGenerator` 3.5.2, this is working well with VS 2022 and `XmlDocument` in the .csx files:

```
#r "System.Xml.dll"
#r "System.Xml.ReaderWriter.dll"
// Requires CodegenCS.SourceGenerator NuGet package
using CodegenCS.Runtime;
using Newtonsoft.Json;
using System.IO;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using System.Xml;
using System.Reflection;

public class UserTemplate
{
...
async Task GenerateConfig(ICodegenTextWriter writer, ICodegenTextWriter logWriter)
{
string prefix = string.Empty;
string key = string.Empty;

try
{
string fileName = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".apk", "ionos_dns.xml");
if (File.Exists(fileName))
{
XmlDocument doc = new XmlDocument();
doc.Load(fileName);
XmlNode nodeDns = doc.SelectSingleNode("/dns_info/api");
if (nodeDns != null)
{
XmlAttribute attribPrefix = nodeDns.Attributes["prefix"];
if (attribPrefix != null)
{
prefix = attribPrefix.Value;
logWriter.WriteLine($"Api: Prefix={prefix}");
}
XmlAttribute attribKey = nodeDns.Attributes["key"];
if (attribKey != null)
{
key = attribKey.Value;
logWriter.WriteLine($"Api: Key={key}");
}
}
}
else
{
logWriter.WriteLine($"Configuration file not found: {fileName}");
}
}
catch (Exception ex)
{
logWriter.WriteLine($"Exception: {ex.Message}");
return false;
}
...
}

```
When using it with VS2026 I get the error message:
1>CSC : error CODEGENCS002: Failed to build CodegenCS Template 'User.csx' (line 64 column 17): 'Der Typname "XmlDocument" konnte nicht im Namespace "System.Xml" gefunden werden. Dieser Typ wurde an Assembly "System.Xml.ReaderWriter, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" weitergeleitet. Sie sollten einen Verweis auf die Assembly hinzufügen.'
Is this simply not compatible with VS2026 or is a different #r command required?

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with User.csx and the #r references shown in the report, comparing how CodegenCS.SourceGenerator resolves System.Xml under VS 2022 and VS 2026. Confirm whether the reported assembly reference needs adjustment; done means the template builds with XmlDocument under the newer Visual Studio version.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.