How to Read an embedded resource as array of bytes without writing it to disk?

You are actually already reading the stream to a byte array, why not just stop there? public static byte[] ExtractResource(String filename) { System.Reflection.Assembly a = System.Reflection.Assembly.GetExecutingAssembly(); using (Stream resFilestream = a.GetManifestResourceStream(filename)) { if (resFilestream == null) return null; byte[] ba = new byte[resFilestream.Length]; resFilestream.Read(ba, 0, ba.Length); return ba; } } edit: See comments for a … Read more

Using C# 6 features with CodeDomProvider (Roslyn)

Update: March 2018 Word of caution, NuGet version 1.0.6 … 1.0.8 will not copy the /roslyn folder to the build output directory on non-web projects. Best stick with 1.0.5 https://github.com/aspnet/RoslynCodeDomProvider/issues/38 Run-time compilation using C#6 features requires a new compiler, as @thomas-levesque mentioned. This compiler can be installed by using the nuget package Microsoft.CodeDom.Providers.DotNetCompilerPlatform. For desktop … Read more

Microsoft Roslyn vs. CodeDom

Disclaimer: I work for Microsoft on the Roslyn team. CodeDom is a precursor to Roslyn, but is only marginally related. Essentially, CodeDom is a simple and (somewhat) langage agnostic way to generate code that was added in .NET 1.0 to support designers (a la WinForms). Because CodeDom was an attempt at providing a unified model … Read more