I have two solutions which have some common code, so I'd like to extract it out and share it between them. Furthermore, I'd like to be able to release that library independently because it might be useful to others.
- What's the best way to do it with Visual Studio 2008?
- Is a project present in more than one solution?
- Do I have a separate solution for the separate piece of code?
- Can a solution depend on another one?
Two main steps involved are
1- Creating a C++ dll
In visual studio
Header File code
Cpp File
Check This
this option should be Dynamic Library(.dll) and build the solution/project now.
first_dll.dll file is created in Debug folder
2- Linking it in C# project
Open C# project
Add this line at top in C# project
Now function from dll can be accessed using below statement in some function
I created dll in c++ project in VS2010 and used it in VS2013 C# project.It works well.
Extract the common code into a class library project and add that class library project to your solutions. Then you can add a reference to the common code from other projects by adding a project reference to that class library. The advantage of having a project reference as opposed to a binary/assembly reference is that if you change your build configuration to debug, release, custom, etc, the common class library project will be built based on that configuration as well.
You can wild-card inline using the following technique (which is the way in which @Andomar's solution is saved in the .csproj)
Put in:
If you want to hide the files and/or prevent the wild-card include being expanded if you add or remove an item from a 'virtual existing item' folder like
MySisterProject
above.Now you can use the Shared Project
Shared Project is a great way of sharing common code across multiple application We already have experienced with the Shared Project type in Visual Studio 2013 as part of Windows 8.1 Universal App Development, But with Visual Studio 2015, it is a Standalone New Project Template; and we can use it with other types of app like Console, Desktop, Phone, Store App etc.. This types of project is extremely helpful when we want to share a common code, logic as well as components across multiple applications with in single platform. This also allows accessing the platform-specific API ’s, assets etc.
for more info check this