0

I've been trying to reference to custom .exe file to debug it.

  • related .pdb file was generated with ildasm, ilasm utilities
  • reference to executable file was added

,but in then end when debug was started i came across with issue:

enter image description here

I read that such behavior possible when some reference can't be resolved, but actually the *.exe file doesn't contains any specific refs (dotPeek screenshot):

enter image description here

I've encountered a lot at first sight similar questions at stackoverflow, but couldn't fined suitable for my situation

Q: Can anyone propose solution for the issue?

AllmanTool
  • 1,384
  • 1
  • 16
  • 26
  • If you just reference the file then it's weird that this exception would be thrown. Could you post the full stacktrace? Also, is this file downloadable somewhere? Given the name, I guess it's part of some kind of challenge – Kevin Gosse Nov 18 '19 at 23:03
  • Did you download or copied it into the Project or Output directory? My best guess would be a right issues preventing accessing it wherever you put it. – Christopher Nov 18 '19 at 23:06
  • Hi, yes it is some kind of challenge task. There is no stacktrace, i try to start debug, click start and as result get above error. Actually the program ever didn't start the execution – AllmanTool Nov 18 '19 at 23:06
  • The .exe file is the same folder where debug application running – AllmanTool Nov 18 '19 at 23:08
  • There's always a stacktrace. When Visual Studio breaks on the exception, open the quickwatch window (shift + F9), evaluate `$exception.ToString()`, and get the result – Kevin Gosse Nov 18 '19 at 23:08
  • (Also, make sure you've disabled "Just my code" in Tools -> Options -> Debugging) – Kevin Gosse Nov 18 '19 at 23:10
  • After start console application state change to break mode with above error, there is not stack trace or call stack etc. – AllmanTool Nov 18 '19 at 23:11
  • yes, i unchecked "Just my code" – AllmanTool Nov 18 '19 at 23:11
  • What happens if you evaluate `$exception.ToString()` in a watch window when the application state change to break mode? – Kevin Gosse Nov 18 '19 at 23:12
  • Ever "main" method doesn't start executing – AllmanTool Nov 18 '19 at 23:13
  • $exception.ToString() => "Unable to execute expression" (Watch window or intermediate window) – AllmanTool Nov 18 '19 at 23:13
  • Hm ok, I'm out of ideas. Might be some subtlety related to .net 2 runtime, or something specific to your setup. If you can upload the file somewhere I can try experimenting with it some more – Kevin Gosse Nov 18 '19 at 23:16
  • Yes, without problem. Where can i share .exe file for you ? Kevin Gosse – AllmanTool Nov 18 '19 at 23:18
  • @Kevin Gosse sample file: https://files.fm/u/mmx5am5t#sign_up Thanks – AllmanTool Nov 18 '19 at 23:20
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/202607/discussion-between-allmantool-and-kevin-gosse). – AllmanTool Nov 18 '19 at 23:22

1 Answers1

1

The assembly name is different from the file name (Assembly name is CrackMe, file name is TaskApp.exe). By renaming the file to CrackMe.exe, I'm able to reference it without errors.

To be honest, I don't know why it's a problem at all. I'm fairly certain that I've renamed assemblies in the past without any issue. I'll probably try to dig further in the coming days.

For future reference, I was able to find the issue by using fuslog (https://learn.microsoft.com/en-us/dotnet/framework/tools/fuslogvw-exe-assembly-binding-log-viewer). With the fusion log enabled, you can clearly see that it's trying to load CrackMe.exe, even when you reference TaskApp.exe.

Kevin Gosse
  • 38,392
  • 3
  • 78
  • 94