Home > Back-end >  Are Shared Projects a good way to add C# code to a VB.NET-based Office VSTO add-in solution?
Are Shared Projects a good way to add C# code to a VB.NET-based Office VSTO add-in solution?

Time:07-18

For an Office VSTO written in VB.NET I would like to add some C# functions that can be written more cleanly in C# (for instance using pattern matching).

I understand there is the option to add a Shared C# Project to a VB.NET VSTO solution (I tried it and VS lets me add it without errors), this is possible although not documented well by Microsoft see here (as you will see the links to the general documentation about Shared Projects no longer work).

I am the only one writing the code, I would prefer to keep everything in one solution to be able to quickly switch between the VB.NET and C# code when working on the solution, so a .NET class library in C# isn't the ideal option.

Are Shared Projects a good way to add C# code this way or am I overlooking some pretty big drawbacks? Thank you for sharing your insights!

CodePudding user response:

A Shared C# Project is a multiplatform solution which is not required in case of VSTO add-ins. COM add-ins are supported on Windows only. There is no COM technology available on other platforms. So, you can use a regular class library project in case of VSTO add-ins. See Tutorial: Create a .NET class library using Visual Studio for more information.

  • Related