سؤال

I have seen before having a project reference another project, but then only that project can interact with the referenced project, the referenced project cannot interact with the other project. Is it possible to have multiple VB.Net projects in a solution, and have it where, say both projects and their forms can interact with each other, as if they were in the same project. I.e. modifying each others controls.

هل كانت مفيدة؟

المحلول

I've had this before, you have Project A which refernces Project B, but Project B cannot reference Project A because that would create a circular reference. What I have done in the past is use normal direct methods from Project A to act on Project B, but define events in Project B that your code in Project A can subscribe to and then handle. Depends on exactly what you are trying to do, but I've used this where a form from Project B is launched from project A, but that from has a button that will launch a form in Project A. So I added an event to Project B's form, that I subscribe to that while launching the form from Project A, when the event gets fired by Project B the code in project A can launch the correct form.

All in all a good workaround, but if you are doing this, in may mean your projects are not organized very well, and you should consider re-factoring your code.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top