Build action in Visual Studio

Earlier today I was creating a new class file for a project of mine in Visual Studio.
Then I went on using the class defined in that file in a web form, but, to my surprise, the class was inaccessible.

I double checked the access level of the class, but it appears that wasn’t the issue, so I started googling for this problem, but I ended up looking at situation different from mine and not really useful.
After a few minutes of scratching my head on this unusual problem, I finally had a look at a pane I rarely look at:

compileIn the Properties pane, the Build Action was set to Content instead of Compile: this is the ways of telling the IDE to include this file in the project as a static resource. So, in this case, the class file was included as a simple plain text file with no action performed on it: no compilation mean of course no usable class, so that was the reason for the seemingly inexplicable behavior.

To have a deeper look into this topic, I strongly advise to read this interesting post on StackOverflow.

Advertisements

Author: lucamauri

First and foremost a geek and a Trekker, Luca Mauri is employed as an IT Manager. A Space Exploration enthusiast, avid reader and hobbyist photographer.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s