开发者

ASP.NET: How to override a non-virtual method from a compiled assembly?

I'm in a bit of a predicament.

I've been assigned the task of maintaining an existing ASP.NET web application for which the source code is not available - all code is compiled and put into the bi开发者_如何转开发n folder.

Now I need to change a few methods' implementations, this is the first time that I'm dealing with such a situation so I would really appreciate your suggestions and recommendations regarding the best way to do this.


Along with what @codymanix said.

Just decompile the assembly with ILDASM. Make the needed methods virtual (or unsealed). Recompile with ILASM. Done.

You may have to fixup calls to these methods to use callvirt, instead of call.


You could try to decompile it for example with the tool Reflector. The real question is: If have don't have the source code are you allowed to change this application?


Do you need to change the implementation such that all internal references inside your legacy assembly uses the new implementation? If so, it can't be done as it would require you to change the legacy binaries (not in a way that's plausible to maintain at least).

As of refacs for client needs (i.e. references from assemblies you have control over), I suggest you write proxies and replace all references to the legacy library with proxies. This allows you to gradully extend/change the behaviour of the legacy library. Down the road this will allow you to change the legacy library with something else.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜