Zum Hauptinhalt springen
tsecurity.de LIVE
Echtzeit-Radar & Feeds
Alle RSS Feeds
👥 Community & Social
Sichere ProgrammierungThe Model Got Better. Your Judgment Got Worse.(22.09.2026 um 03:02 Uhr)
Sichere ProgrammierungAIFeed - signed content permissions for AI web crawlers(22.09.2026 um 03:10 Uhr)
Sichere ProgrammierungThanks, glad you liked it!(22.09.2026 um 03:15 Uhr)
Sichere ProgrammierungA request for /.env shouldn't render your React app(22.09.2026 um 03:17 Uhr)
Sichere ProgrammierungAI-Agent Marketplaces Need Verifiable Delivery, Not More Listings(22.09.2026 um 03:20 Uhr)
AI & KI NachrichtenBeyond Bigger Models: Toward a Modular Cognitive Architecture(22.09.2026 um 03:21 Uhr)
Sichere ProgrammierungMasa Depan Manajemen Data: Mengenal Konsep Data Mesh yang Revolusioner(22.09.2026 um 03:22 Uhr)
Sichere ProgrammierungHow to Search Your Claude Code Conversation History(22.09.2026 um 03:22 Uhr)
Sichere ProgrammierungThe Model Got Better. Your Judgment Got Worse.(22.09.2026 um 03:02 Uhr)
Sichere ProgrammierungAIFeed - signed content permissions for AI web crawlers(22.09.2026 um 03:10 Uhr)
Sichere ProgrammierungThanks, glad you liked it!(22.09.2026 um 03:15 Uhr)
Sichere ProgrammierungA request for /.env shouldn't render your React app(22.09.2026 um 03:17 Uhr)
Sichere ProgrammierungAI-Agent Marketplaces Need Verifiable Delivery, Not More Listings(22.09.2026 um 03:20 Uhr)
AI & KI NachrichtenBeyond Bigger Models: Toward a Modular Cognitive Architecture(22.09.2026 um 03:21 Uhr)
Sichere ProgrammierungMasa Depan Manajemen Data: Mengenal Konsep Data Mesh yang Revolusioner(22.09.2026 um 03:22 Uhr)
Sichere ProgrammierungHow to Search Your Claude Code Conversation History(22.09.2026 um 03:22 Uhr)
Intelligence View
⚡ tsecurity.de Intelligence

Understanding .NET Compilation: .NET Standard vs .NET Core, Roslyn vs csc.exe, and Dynamic Compilation

When working with .NET, it's crucial to understand how code is compiled and what tools are responsible for transforming your C# into executable binaries. This blog explores the differences between compilers used in .NET Standard and .NET…

0
↗ Quelle (dev.to)
Reagiere als Erste:r — dein Feedback zählt!

When working with .NET, it's crucial to understand how code is compiled and what tools are responsible for transforming your C# into executable binaries. This blog explores the differences between compilers used in .NET Standard and .NET Core and explains the role of Roslyn, csc.exe, and dynamic compilation in modern .NET development.






🔍 .NET Standard vs .NET Core Compilation



.NET Standard

What it is: A formal specification of .NET APIs that all .NET implementations (like .NET Framework, .NET Core, Xamarin) must implement.

Usage: Used to build libraries that are portable across all .NET platforms.

Compilation: Uses netstandard.dll as a reference library. The actual runtime compilation is handled by the consuming runtime (.NET Core, Mono, etc.).

.NET Core

What it is: A cross-platform runtime implementation of .NET.

Usage: Can build and run both applications and libraries.

Compilation: Uses Roslyn compiler directly or via dotnet build. Relies on System.Private.CoreLib, System.Console, and other runtime assemblies.





⚙️ Roslyn and csc.exe Explained



csc.exe – The Classic Compiler

What it is: Command-line compiler executable for C#.

Usage: Used in traditional build pipelines or directly via CLI.

Limitations: Not embeddable, harder to use programmatically.

Implementation: Originally implemented in C++ as part of the .NET Framework SDK.



Roslyn – Compiler as a Service

What it is: .NET compiler platform as a set of APIs (Microsoft.CodeAnalysis).

Usage: Used by modern tools like Visual Studio, OmniSharp, analyzers.

Benefits: Fully programmable, supports syntax trees, diagnostics, in-memory emit.

Implementation: Written in C#, and bootstrapped using Roslyn itself.

📝 Note: csc.exe is built on top of Roslyn. It's essentially a thin command-line wrapper around the Roslyn API.





🔄 Dynamic Compilation



Dynamic compilation refers to compiling code at runtime, allowing for runtime behaviors such as scripting, code evaluation, or plugin execution.



In Roslyn, dynamic compilation is achieved by using the Roslyn APIs to compile and execute code in memory, without writing to disk. This is useful for scenarios like:




  • Online code editors

  • Plugin systems

  • Educational tools

  • Runtime extensibility in applications





Example: Dynamic Compilation in Action



Here's a simple example using the Roslyn API for dynamic compilation:




using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using System;
using System.IO;
using System.Reflection;

class Program
{
static void Main()
{
var code = @"
using System;
public static class Example
{
public static void Main()
{
var tuple = (Part1: \"hello\", Part2: \"world\");
Console.WriteLine($\"{tuple.Part1} {tuple.Part2}\");
}
}
";

// Resolve paths to needed assemblies
string coreDir = Path.GetDirectoryName(typeof(object).Assembly.Location)!;

var references = new[]
{
MetadataReference.CreateFromFile(typeof(object).Assembly.Location), // System.Private.CoreLib.dll
MetadataReference.CreateFromFile(typeof(Console).Assembly.Location), // System.Console.dll
MetadataReference.CreateFromFile(Assembly.Load("System.Runtime").Location), // System.Runtime.dll
MetadataReference.CreateFromFile(Assembly.Load("netstandard").Location), // netstandard.dll
MetadataReference.CreateFromFile(Assembly.Load("System.Console").Location), // System.Console.dll again, to be sure
};

var syntaxTree = CSharpSyntaxTree.ParseText(code);
Console.WriteLine(syntaxTree.ToString());

var compilation = CSharpCompilation.Create(
"HelloWorld",
new[] { syntaxTree },
references,
new CSharpCompilationOptions(OutputKind.ConsoleApplication)
);

using var ms = new MemoryStream();
var result = compilation.Emit(ms);

if (!result.Success)
{
Console.WriteLine("Compilation failed:");
foreach (var diag in result.Diagnostics)
Console.WriteLine(diag.ToString());
return;
}

ms.Seek(0, SeekOrigin.Begin);
var assembly = Assembly.Load(ms.ToArray());

var type = assembly.GetType("Example");
var method = type?.GetMethod("Main", BindingFlags.Public | BindingFlags.Static);
method?.Invoke(null, null); // Output: hello world
}
}









✅ Conclusion



Understanding the .NET compilation process is key to mastering modern .NET development. Whether you're writing cross-platform libraries with .NET Standard or building apps with .NET Core, knowing how your code turns into binaries helps you troubleshoot, optimize, and innovate with confidence.

Roslyn has redefined what a compiler can do—turning it from a black box into a programmable service. It powers not only Visual Studio and analyzers but also enables powerful scenarios like dynamic compilation, custom tooling, and interactive scripting.

Whether you're using csc.exe for straightforward builds or Roslyn APIs for advanced scenarios, understanding these tools gives you the flexibility and insight to choose the right approach for your project.

Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten Understanding .NET Compilation: .NET Standard vs .NET Core, Roslyn vs csc.exe, and Dynamic Compilation

Thematisch verwandte Begriffe: Understanding, Compilation, Standard, Core · 6 Treffer

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Zum Aktualisieren ziehen
ZERO-DAY CVE-2026-49449 | Joplin is an open source note-taking and to-do application that organise…
Advisory →
TTS Reader • tsecurity.de Voice
tsecurity.de Icon
tsecurity.de App
Offline-Lesen, Eilmeldungen & 0ms Ladezeit

Installiere tsecurity.de direkt auf deinen Home-Bildschirm für das ultimative Vollbild-Magazinerlebnis ohne Browser-Leisten.

Nächster Beitrag
Themen-Radar & Intelligence Matrix
Echtzeit-Taxonomie nach Angriffsvektoren & Plattformen

tsecurity.de Live Threat Radar

🔴 LIVE RADAR
MONITORING
AKTIV
CVE-DATENBANK
LIVE
🔍
Community Radar & Live Chat
Sentinel Bot online • Live-Stream
Dein Cluster: Security Explorer
Match:
lädt…
Verbindung zum Community-Stream wird aufgebaut...
Bearbeitungsmodus — Senden überschreibt deine Nachricht
Community-Puls — was gerade passiert
lädt…
Aktivitäten deiner Analysten
lädt…
Neues Thema oder Eilmeldung einreichen

Reiche interessante Links, Zero-Days oder Debatten ein. Die Community entscheidet per Upvote über die Veröffentlichung.

Heiß diskutierte Einreichungen
🔖 Gespeicherte Artikel
📂 Keine gespeicherten Artikel vorhanden.
Zurück Ziehen Vor
Links: vorheriger Artikel Rechts: nächster Artikel unten: schließen
News NIS-2 Frühwarnung Tier-1 Intel ⏱️ 3 Min vor 10 Min
Artikeldaten werden geladen...

Zurück: vorheriger Vor: nächster
↗ Original-Quelle
Social Reaktionen Deine Reaktion zählt
Einstufung & Relevanz-Poll 0 Stimmen
In sozialen Netzwerken teilen 1-Klick