I'm not even sure if this is possible, so apologize if not. I searched Google quite widely and did not find what I was looking for.
Basically, we have an application created by a third party, which, being completely dumb, is garbage. We have a particular problem, and we were able to trace the problem using ILSpy to a method in the DLL. Obviously, we do not have (and cannot get) the source code, and the company in question does not want to fix the problem in a reasonable amount of time.
So, we explored various areas of the investigation and came up with nothing. I am studying whether this can be done through reflection, and this is pretty much the last hope we have for getting this to work. In short, I would like to do the following:
- Create a simple class library with the same name as the existing DLL
- Use reflection to import methods from an existing DLL
- Somehow override the method in question with my own correct code
- Rebuild the code, so I have a new DLL containing 99% of the functionality of the existing DLL, but with my redefinition code providing the correct functionality.
During my research, I found TypeBuilder.DefineMethodOverride, as well as a page from StackOverflow, which seems similar, but not quite what I am looking for.
http://msdn.microsoft.com/en-us/library/system.reflection.emit.typebuilder.definemethodoverride.aspx
Is there a way to override the reflection method?
Any advice appreciated!
Andrew
Edit
Another possible idea I had was to create a partial class containing an override function, but that also seemed impossible.
reflection c # dll
Andrew
source share