Using Shared Projects in ASP.NET

Shared projects are used to facilitate cross platform development. This allows you to reference an entire project as opposed to just a single assembly.

Shared project is a shred bucket of code. At compile time, any project that reference the shared project will have all of the files (including folder structure) and then they will be compiled. You wouldn’t see any separate DLL as you might have seen in PCL (Portable class libraries).

A shared project is not going to be compiled on its own. The code in the shared project is incorporated into assembly that reference it and compiled within that assembly.

Let’s create a shared project;

Create a class Math with a static method Add.

namespace SharedProject1
    public class Math
        public static int Add(int x, int y)
            return (x + y) + 3;
            return (x + y) + 13;

Add SharedProject reference to your project. If your project is targeting .NET Core 1.1, the relevant piece of code in #if/#endif will run.

//.NET Core 1.1
SharedProject1.Math.Add(3, 4);      //return 10

//.NET Core 1.0
SharedProject1.Math.Add(3, 4);      //return 20

Here is some recommendation of using Shared Projects and Portable Class Libraries;

How the code is reused

  1. Shared Projects: Source Code (All source code is available to your reference project)
  2. PCL: Reference is available at Assembly level (for example MyLibrary.dll)

Compile time behavior

  1. Shared Projects: All source code is copied into each referenced project and compiled there
  2. PCL: Nothing new. Its compiled as usuall.

Visual Studio support

  1. Shared Projects: Full Support
  2. PCL: Each plateform is compiled separately. This can be accomplished thru IOC.

#IFDEF Support

  1. Shared Projects: Full Support
  2. PCL: Unsupported

.NET Framework Support

  1. Shared Projects: Full Support
  2. PCL: Limited

The core problem with shared project is difficulty of code testing because of conditional compilation directives. This in turn introduce errors that you wouldn’t know until you have actually compiled your application.


Visual Studio Debugger Failed to launch debug adapter

All of sudden I started getting this error;

If I change launchBrowser to false in launchSetting.json file,  I can successfully start the project, and then open the browser and navigate to the url manually.

launchBrowser: false

If I run project “without debugging” by pressing CTRL+F5, it runs fine but I loose debugging feature.

The quick fix is to never use JavaScript debugging in Visual Studio. The Chrome JavaScript debugger is a much better alternative for debugging.

To turn off debugging and fix the problem follow this;

You can confirm this change;

The pain is gone.


Updating SSIS packages for specific SQL server version

Updating SSIS packages for a specific SQL server target version (valid only for SQL Server 2012 and above)

  1. Right click on a project, click properties and select your target server version from the drop down

Click Apply, read the warning then click Yes as shown below, and finally click Ok

Re-open the packages and notice how the development platform (control flow and data flow tabs) changes



Check for any odd behavior (discontinued/deprecated tasks), build/rebuild your packages, test your packages, and deploy/redeploy them.

Start Debugging vs Start Without Debugging

Start Debugging

Start Debugging (pressing F5) is the normal way of launching your application in visual studio. Debugger would be attached automatically and you can expect to see debugging messages and breakpoints in your application.

A popular misconception is that Debugger doesn’t come into play for Release build. This isn’t true. Set a breakpoint in a Release build and then press F5 to see if it stops there. Some debugging messages are not happening in Release build for example message from System.Diagnostics.Debug class.

Start without Debugging

This will start the application (pressing CTRL + F5) without the debugger attached. That’s it. If we need to attached the debugger to this process afterwards, we can select Debug->Attach to Process option.

For further info, please follow this link;