Click here to Skip to main content
15,877,675 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all
I want to run an exe file in Memorystream
Knowing that I use
.net core 6
chromedriver
When I'm working, I try to use the following code

What I have tried:

C#
if (fileZip.Count()== index)
                      {
                          foreach (var entryexe in fileZip)
                          {
                              if (entryexe.FullName.Contains("exe")|| entryexe.FullName.Contains("dll"))
                              {

                                  byte[] filebin = ms.ToArray();

                                  Assembly assembly = Assembly.Load(filebin);

                                  //MethodInfo method = a.EntryPoint;
                                  //if (method != null)
                                  //{
                                  //    object o = a.
                                  //    // invoke the application starting point
                                  //    method.Invoke(o, null);
                                  //}

                              }
                          }
                      }

This code shows the error

C#
Assembly assembly = Assembly.Load(filebin);


this error
System.BadImageFormatException: 'Bad IL format.'
Posted
Comments
Richard MacCutchan 10-Dec-23 3:18am    
foreach (var entryexe in fileZip)
{
    if (entryexe.FullName.Contains("exe")|| entryexe.FullName.Contains("dll"))
    {
        byte[] filebin = ms.ToArray();

It looks like you have not extracted the file contents to the memory stream.

1 solution

You cannot run an executable from anything other than an actual file on disk.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900