我可以替换 ASP.NET 页面使用的供应商提供的方法吗?

发布于 2024-09-07 18:21:23 字数 793 浏览 2 评论 0原文

我们的内部人力资源应用程序是由供应商开发的,但我被要求在没有他们的帮助的情况下更改某些功能的行为(我不想这样做,但正在调查......)。所讨论的功能是一个 .ashx 页面,它执行大量数据库查找,并通过网页上的 javascript 函数进行调用。我们想要添加进一步的数据库查找。

我们可以控制 javascript 代码,因此这不是问题,但 .ashx 页面的代码保存在已编译的程序集中。我找到了它在哪里,并使用 .Net Reflector 对其进行了研究。如果技术上可行的话,重新实现所涉及的方法并不困难。

我可以创建一个新程序集,将使用 Reflector 获取的源代码粘贴到其中,进行修改,将 DLL 添加到应用程序,然后设置一个新的 .ashx 来引用它吗?

我担心不可能的部分是:

代码引用了其他程序集中保存的某些供应商类;我可以在 Visual Studio 中添加对这些程序集的引用以允许其编译,然后当它被编译并放在服务器上时,它就可以正常工作了吗?

鉴于通常这个应用程序不是我们自己进行更改的,我在让 Web 应用程序接受新的 DLL 时是否会遇到困难?

编辑: 一些澄清:我实际上并不打算用我自己的 DLL 替换供应商的 DLL,这听起来确实有点太过分了。相反,我会创建一个新的 DLL,其中仅包含我需要的一个函数(基于使用 Reflector 从现有 DLL 中获取的内容)。我需要该代码来引用其他实用程序供应商代码,以便它可以获取访问框架所需的类。我将创建一个全新的 .ashx 页面来提供新 DLL 中的代码。

幸运的是,在这一切之后我摆脱了困境,因为我的客户同意事情还没有到让我们尝试这一切的程度!但感谢您的帮助,这绝对有用。

Our internal HR application is developed by the vendor, but I've been given a requirement to change the behaviour of a certain piece of functionality without their assistance (which I don't want to do, but am investigating...). The functionality in question is an .ashx page which does a number of database lookups, and is called via javascript functions on a web page. We want to add one further database lookup.

We have control over the javascript code, so that's not a problem, but the code for the .ashx page is held in a compiled assembly. I've found where it is, and looked into it using .Net Reflector. Reimplementing the methods involved wouldn't be difficult, if it were technically feasible.

Can I create a new assembly, paste the source taken using Reflector into it, make my modifications, add the DLL to the application, and then set up a new .ashx to refer to it?

The bits I'm worried about not being possible are:

The code refers to some vendor classes held in other assemblies; can I just add references to those assemblies in Visual Studio to allow it to compile, and then when it's compiled and put on the server it'll all work?

Will I have trouble getting the web application to accept the new DLL, given that generally this application is not something we make changes to ourselves?

EDIT:
Some clarification: I'm not actually planning to replace the vendor's DLL with one of my own, that does sound like going a bit too far. Instead, I would make a new DLL with just the one function in it I need (based on stuff taken from the existing DLL using Reflector). I'd need that code to reference other utility vendor code so that it can get at classes needed to access the framework. I'd make a brand new .ashx page to serve up the code in the new DLL.

Luckily after all this I'm off the hook, because my customer agrees that things aren't desperate enough for us to attempt all this! But thanks for the assistance, which is definitely useful.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

猫性小仙女 2024-09-14 18:21:26

如果您只是想获取一些额外的数据,我只需实现自己的查找并从 Javascript 调用它,而不是搞乱反射器。你有什么理由不能这样做吗?

If you are just looking to get some additional data, I'd just implement my own lookup and call it from Javascript, rather than messing with reflector. Is there any reason that you can't do that?

情话难免假 2024-09-14 18:21:25

请参阅我对您正在考虑的方法的风险的评论。

我真的不推荐整体方法,但是,是的,可以引用您没有源代码的程序集;只需添加对将使用它们的项目的引用即可。

可能可以替换 .ashx 的代码隐藏,具体取决于它是否已预编译。如果不是,那么我相信替换 BIN 文件夹中的 DLL 应该可以解决问题。 (假设没有其他程序集引用它。)(免责声明:我从未尝试过此操作,并且我不推荐它。)

See my comment about the risk of the approach you're considering.

I really don't recommend the overall approach, but yes, it is possible to reference assemblies you don't have the source for; just add references to the project which will use them.

Replacing the code-behind for the .ashx may be possible depending on whether it's precompiled. If it's not, then I believe replacing the DLL in the BIN folder should do the trick. (Assuming no other assemblies are referencing it.) (DISCLAIMER: I've never tried this, and I don't recommend it.)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文