Sharing classes between projects and catching events

Guido Esse 21 Reputation points
2021-01-29T19:02:57.783+00:00

I've two projects in the same solution. The first one has a class that fires events on calling some functions. The second project use the same class and i add it as link to the first project so i can do any changes to the class without copying the code on the other project.
In this scenario i've create two object as instance of that class, one in a project and another in the second project. Now, in the first project, if I call a function of that class that fires an event, this event is cached also in the second project... It's very strange.... If I make a call to the object in the first project the same event is cached also in the second project.
How can I prevent this behaviour? I need to link that class for better management of the code but i'd want to have separate object in the two projects.

Thanks in advance
Guido S.

Visual Studio
Visual Studio
A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.
4,698 questions
VB
VB
An object-oriented programming language developed by Microsoft that is implemented on the .NET Framework. Previously known as Visual Basic .NET.
2,605 questions
0 comments No comments
{count} votes

Accepted answer
  1. Duane Arnold 3,216 Reputation points
    2021-01-29T21:15:41.267+00:00

    It seems to me that you should be using a classlib project with the sharable class in it. That why, the other two projects can set project reference to the classlib project that will result in the two projects that have reference to the classlib project being able to instance the shared code object separately.

    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Guido Esse 21 Reputation points
    2021-01-30T07:42:56.533+00:00

    Thanks for replay...I'll try it but this behaviour is very strange!

    0 comments No comments