none
Sharing classes between projects RRS feed

  • Question

  • I have a MikesStringList class which adds LoadFromFile and SaveToFile methods to List<>. Whenever I want to use it in a new project I copy the source into the new project's folder and edit it with a text editor to set the namespace to my new project's namespace. I then add it to the project.

    This is very tedious.

    What do I have to do to make MikesStringList "just available" like other native classes?

    Tuesday, February 21, 2017 3:59 PM

Answers

  • Whoops!

    I had a look at "Sharing classes between projects in a solution in Visual Studio Express Edition" and found the answer which I was seeking.

    Mike.
    P.S. I'm not allowed to post a link yet which is why the above, in quotes, is not the proper link which it should be.
    Tuesday, February 21, 2017 5:57 PM

All replies

  • What you do is create a DLL out of the class you want to share. In your new project, add a reference to the DLL. It's easy-peasy.
    Tuesday, February 21, 2017 4:15 PM
  • Thanks, Brian.

    However, if I do that I'll need to ship the DLL with every application - not too hard but a bit messy I think.

    I came across this article http://dailydotnettips.com/2015/07/28/using-shared-project-across-multiple-applications-in-visual-studio-2015/ which implies, to me, that you can use the source code from a shared project in other projects. Which I interpret as meaning that the shared source code will be compiled into a new project as if it was coded in the new project's namespace.

    I tried what they say in VS 17, although it was meant for VS 15, and when I tried to add the shared project as reference the Reference Manager opened with Shared Projects->Solutions expanded but it said "No items found".

    Has it all changed in VS 17 or am I just completely confused?

    Mike.

    Tuesday, February 21, 2017 5:00 PM
  • Whoops!

    I had a look at "Sharing classes between projects in a solution in Visual Studio Express Edition" and found the answer which I was seeking.

    Mike.
    P.S. I'm not allowed to post a link yet which is why the above, in quotes, is not the proper link which it should be.
    Tuesday, February 21, 2017 5:57 PM