Reputation: 384
I want to use some code of Project 1 (VB.NET) in Project 2 (c# Windows Form) and vice-versa. I know we cannot create circular reference but is there any other way we can achieve it?
Upvotes: 0
Views: 83
Reputation: 2352
First, circular reference means wrong design. If you need something like this, you must change your design in one of these ways:
1. Extract "circular" code
In general, create another library, with functions, which are called from both "circular" libraries. Then make both Project1 and Project2 dependent on newly created Project3.
2. Use callbacks
Make just one lib dependent on second - without any example from your code, it is hard to decide, which one should be dependant on other, but from "Windows Form" I would assume, it would be better if Project2 is dependent on Project1. So it means, that Project2 knows everything Project1. And then, if you need to call something from Project1 back to Project2, just provide callback during initializing. E.g. Project1 contains function, which makes some long calculations, and you want to be notified when it's done. OK, no problem. Project2 starts the operation with callback (search for delegates) and continues with its own work. When the function in Project1 finishes, it uses the provided callback to call function from Project2 (even it doesn't know this function, but it is not necessary, because compiler manage, that "incompatible" function cannot be provided as callback).
It is hard to give you more advices, since you haven't provided any piece of code. If you need more help, please update your question with some simplified example.
Upvotes: 1