-1

I need to make API calls to methods in an EXE provided by a software company. In the past very old .Net version, I was able to make it work by renaming the exe to dll (I guess?). This time around the EXE they have provided seems to have been compiled in 4.6.1. I am not able to make it work and it causes runtime errors: "Could not load file or assembly... A strongly-named assembly is required"

What are my options? Is it still possible to make API calls to an EXE whether or not I rename it to a DLL? Or Should I ask them to provide me a proper DLL?

Thank you.

9
  • If it is signed (strongly-named) .exe it will not work, when you renamed it. Anyway, as far as I know, you don't need to rename .exe to .dll to load it (if you are sure, that this .exe is managed)
    – vasily.sib
    Commented Oct 1, 2018 at 2:52
  • Thanks vasily. I hope it is not a typo. Please clarify: "If it is signed ... it will not work". Did you mean to say, "it will work"?
    – Aamir
    Commented Oct 1, 2018 at 2:55
  • If it signed and renamed, it will not work, because a name of file is a part of strong assembly name.
    – vasily.sib
    Commented Oct 1, 2018 at 2:58
  • 1
    ok, wait, this is a little misleading. 1st: you don't need to rename anything to load it as .net assembly regardless of whether it is .exe, .dll, or .txt. As long as there is a managed code inside - everything should work. 2nd: I think/believe, that as name of file is included in assembly strong name - changing it will broke assembly loading eventually. 3rd: If assembly is signed - you can't (without disassembling) sign it with your key/certificate, and you don't need to do this in most cases.
    – vasily.sib
    Commented Oct 1, 2018 at 5:20
  • 1
    No, not-strong-named (not signed) assembly may be strong-named by developer or anyone else, but most of the time developers doesn't signing (strong-naming) their assemblies. But if they do strong-named their assembly - it is hard to "re-strong-name" them.
    – vasily.sib
    Commented Oct 2, 2018 at 2:44

1 Answer 1

0

Thanks to @vasily.sib and the following link, I was able to resolve this issue.

I can in fact reference any EXE assembly in the project and call methods on it. An EXE (and for that matter a DLL) can be strong named and signed by anyone, and not just by the developer who has the source code for that EXE. See the following link for details.

Thank you.

https://chrisbenard.net/2009/07/16/strong-name-an-assembly-without-source-code/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.