如果没有引用,是否可以强制 .net 应用程序从一开始就加载另一个 .net 程序集?
是否可以通过 app.config 操作或任何其他方式强制 .net 应用程序从一开始加载另一个 .net 程序集?
我想创建另一个应用程序来在程序集启动时将其加载到其进程边界中。请不要问我为什么:)我只是尝试解决遗留应用程序缺乏可扩展性的问题。
有一个问题 - 我必须通过访问控件树来扩展旧应用程序 UI。所以我希望将主窗体实例作为 System.Windows.Forms.Form 实例类访问。从另一个进程中这是不可能的,所以我有一些想法如何在遗留应用程序边界中注入程序集并进一步使用我的程序集代码。
我遇到的问题: WinForms:Form.FromHandle 对于加载到 .net 可执行文件中的代码的进程主窗体返回 null
Is it possible to force .net application to load another .net assembly from the start via app.config manipulation or any other way?
I want to make another application to load my assembly in it's process boundaries when it starts. Please, don't ask me why :) I just try to to walkaround legacy application lack of extensibility.
There is a problem - I have to extend legacy application UI by accessing controls tree. So I wish to access Main Form instance as System.Windows.Forms.Form instance class. It's impossible from another process so I have some thoughts how to inject assembly in legacy application boundaries and use my assembly code further.
The problem I fight with: WinForms: Form.FromHandle returns null for process main form for code loaded into .net executable
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果程序使用了 Debug 或 Trace 语句,您可以创建一个虚拟 TraceListener,它会在第一次调用 Write 或 WriteLine 时连接到 UI。
If the program makes any use of Debug or Trace statements, you can create a dummy TraceListener, that hooks up to the UI the first time Write or WriteLine is called.
使用 Assembly.Load 和该系列方法应该可以做到这一点。如果这不起作用,因为应用程序需要预先提供所有引用(这仅取决于启动应用程序时发生的情况),也许您可以将内容加载到不同的应用程序域中并以这种方式执行操作?
当然,目前的设计可能会阻止这样的事情发生。你尝试过什么?
That should be possible to do using Assembly.Load and that family of methods. If that doesn't work because the application requires all references upfront (it jut depends on what's going on at the time of starting your app), maybe you could load things in a different app domain and do things that way?
Of course the current design may prevent such a things. What have you tried?