Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6254083
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T14:07:39+00:00 2026-05-24T14:07:39+00:00

In CodeDom, it is possible to add an embedded resource to your dynamically created

  • 0

In CodeDom, it is possible to add an embedded resource to your dynamically created file by using the CompilerParameters.EmbeddedResources property. In my project, I am adding some bytes of data as an embedded resource to my dynamically created file (as shown below).

Byte[] bytes = new byte[] {1,2,3,4,5};

// Write the data to disk (I would like to avoid this step!).
File.WriteAllBytes(@"C:\EmbeddedResource.exe", bytes); 

CompilerParameters cp;
cp.EmbeddedResources.Add(@"C:\EmbeddedResource.exe");

Is there some way I can store the data of ‘bytes’ in memory, and add it as an embedded resource directly from memory.

Thank you for any advice,

Evan

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T14:07:39+00:00Added an answer on May 24, 2026 at 2:07 pm

    I’m afraid you can’t. Looking into the CSharpCodeGenerator (with Telerik’s JustDecompile or Redgate’s .NET Reflector), I found the usage of the CompilerParameters class:

    private string CmdArgsFromParameters(CompilerParameters options)
    {
        StringBuilder stringBuilder = new StringBuilder(128);
        // ...
        StringEnumerator stringEnumerator = options.EmbeddedResources.GetEnumerator();
        try
        {
            while (stringEnumerator.MoveNext())
            {
                string str = stringEnumerator.Current;
                stringBuilder.Append("/res:\"");
                stringBuilder.Append(str);
                stringBuilder.Append("\" ");
            }
        }
        finally
        {
            IDisposable disposable2 = stringEnumerator as IDisposable;
            if (disposable2 != null)
            {
                disposable2.Dispose();
            }
        }
        // ...
        return stringBuilder.ToString();
    }
    

    They use it to create a string with all command-line parameters that are passed to the C# compiler exe (http://msdn.microsoft.com/en-us/library/6ds95cz0%28v=VS.100%29.aspx). So, at the end, I guess your code is simply compiled with csc.exe.

    []’s

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is it possible to load the CodeDOM from a .NET binary created using C#?
I managed to create a class using CodeDom and add a single method to
What are some pros/cons for using the Reflection.Emit library versus CodeDOM for dynamically generating
I just generated the .cs file using codeDom. Can someone explain how do I
I've built some Types dynamically using System.CodeDom.CodeCompileUnit, want to compile those into IL code
I'm trying to dynamically compile source code using the CodeDom.Compiler stuff, which means I
I am working on a c# codedom project which provides users to dynamically compile
I am dynamically generating some c# code using the CodeDom. I want to ad
Is it possible to add a Finalizer to a CodeDom generated class (other than
I'm using FSharp.Compiler.CodeDom (from the PowerPack ) to dynamically create F# classes. The problem

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.