0

First place, I embedded into my C# project an unmanaged EXE (pdftotext.exe, actually). I wrote a method to call it using the traditional:

    Assembly assembly = Assembly.GetExecutingAssembly();
    Stream stream = assembly.GetManifestResourceStream(assembly.GetName().Name +".pdftotext.exe");
    byte[] ba = new byte[stream.Length];
    stream.Read(ba, 0, ba.Length);

I worked perfectly, until I decided to build a library to hold all my functions, including this one. Accordingly, I embedded the unmanaged EXE into my new DLL. Now I try to call the method from my project, but it stops in byte[ba] as 'stream' would have 'null' value. Any help would be appreciated, because I'm currently lost.

UncleO
  • 8,299
  • 21
  • 29
argledhel
  • 167
  • 2
  • 3
  • 16
  • Have the namespaces inside the assembly changed and/or the name of the assembly? It's possible that that has caused the fully qualified name of the resource to change, and no longer have a name that works with your code. Try changing assembly.GetName().Name to this.GetType().Namespace. – Martin Costello Apr 07 '14 at 20:32
  • The resource name is wrong. Look at the assembly with ildasm.exe, double-click the manifest. The .mresource directive shows you the name you must use. Hiding executable files is going to get you in trouble with your customer's IT staff and the anti-malware they use. – Hans Passant Apr 07 '14 at 20:58
  • Both of you thanks! Specially Hans, I didn't know the ildasm tool (I'm a newbie). Actually, I don't like to embed the exe, but right now I'm in a hurry and needed to do it. – argledhel Apr 08 '14 at 13:03

0 Answers0