0

I have a bad situation I'm trying to work through and would appreciate your help. We have a legacy .NET application that initiates a stored procedure call that is exceeding the default command timeout threshold. I know how to change the command timeout threshold in code (that's easy) - the problem is that we don't have the source code for this legacy application (trust me, no one's more upset about this than I).

We're working on optimizing the Stored Procedure, but we're facing some blockers. Namely, the database which the Stored Procedure runs against is a vendor database and they've said they can't add some indexes that would help. We're also facing an issue where the vendor's database has grown dramatically over the last few years and the size appears to be contributing to the problem.

Previous to our optimization efforts, the stored procedure was taking minutes to complete. We've now got it down to about 36 seconds, but we're not sure if we can get it below the default command timeout of 30 seconds.

I've read that there's no way to change the command timeout in the connection string, but I was wondering if any of you fabulous people had any ideas on how to change the command timeout outside of code.

Thanks!

Christopher Brown
  • 2,170
  • 1
  • 13
  • 19
  • Alas, CommandTimeout is something that needs to be applied to an SqlCommand instance at run time and can't be set through connection strings. I make it an application setting in the .config file for new applications so that we can change it without having to recompile. Without access to the source code, though, it sounds like you could be up that proverbial creek. – AlwaysLearning Oct 22 '20 at 00:14
  • If this is your own application that you've lost the source code to have you considered reverse engineering it? I was in a similar situation a number of years back and recovered source code for an old Windows Service (that was created before I joined the company) by way of .NET Reflector, ildasm and lots and lots of diffing until I had source that reproduced the same MSIL as the production code. I was then able to commit the recovered source and go to town fixing bugs and refactoring it. – AlwaysLearning Oct 22 '20 at 00:18
  • Yes. The issue we're facing is that we're in the middle of procuring a replacement for this system. That replacement is supposed to go live sometime in the next 6-9 months. The codebase for this application is massive and taking the time to re-engineer it just doesn't seem like a good use of time. – Christopher Brown Oct 22 '20 at 15:35

1 Answers1

0

You can use ildasm to alter what will get executed directly in the .net dll. e.g. see top answer in: dotnet dll decompile and change the code There's a bit of a learning curve, but it is possible.

Or could try something like DnSpy https://github.com/dnSpy/dnSpy , which looks promising. Some discussion of DnSpy at: Modify Compiled .Net Exe

Moe Sisko
  • 11,665
  • 8
  • 50
  • 80