Loading EXE in the Application [Assembly]?

  • Thread starter Thread starter sajin
  • Start date Start date
S

sajin

Hi,

I am trying to load an executable as assembly (this exe is not .net
made, it is just an exe made using install shield). I am using the
following code to load

Assembly myAssembly = Assembly.LoadFrom(@"C:\setup.exe");
it is giving me the error that "BadImageFormatException"


Plzzzz Help...
Regards
-Sajin
 
Hi,

Of course, because it;s not an assembly. It's not even managed code.

What are you trying to do?

I think that you want to execute the program, if that;s so use Process.Start
 
Sajin,

If the assembly is not managed, then you can not call the static methods
on the Assembly class to execute it.

If you need to execute the assembly, you will want to pass the path of
the executable to the static Start method on the Process class, like so:

Process.Start(@"C:\setup.exe");

Hope this helps.
 
Hi,
I have a setup file which is created by Install shield, it is signed
with test.cert and a private key, i want to read the public key from
the exe.if i use .net exe, it is giving me the answer


public X509Certificate GetAuthenticodeCertificate(Assembly target)
{
X509Certificate certificate = null;
foreach (object item in target.Evidence)
{
Publisher publisher = item as Publisher;
if (publisher != null)
{
certificate = publisher.Certificate;
break;
}
}

return certificate;
}

i have to pass the exe as assembly to this function.
 
That's the thing, it won't give you an answer because the Assembly is a
^managed^ assembly in the GetAuthenticodeCertificate method. You are not
working with a managed assembly, it's that simple.

You have to get the certificate through other means.
 
So is there any solution?

That's the thing, it won't give you an answer because the Assembly is a
^managed^ assembly in the GetAuthenticodeCertificate method. You are not
working with a managed assembly, it's that simple.

You have to get the certificate through other means.

--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)




Hi,
I have a setup file which is created by Install shield, it is signed
with test.cert and a private key, i want to read the public key from
the exe.if i use .net exe, it is giving me the answer
public X509Certificate GetAuthenticodeCertificate(Assembly target)
{
X509Certificate certificate = null;
foreach (object item in target.Evidence)
{
Publisher publisher = item as Publisher;
if (publisher != null)
{
certificate = publisher.Certificate;
break;
}
}
return certificate;
}
i have to pass the exe as assembly to this function.

- Show quoted text -
 
Back
Top