SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I em working with wss3.0 and moss. I need to define a constant which is true for wss3.0 and false for moss. I am using the following method to detect whether my custom webpart is running under wss or moss.

public static bool IsMOSS()
    SPFeatureDefinitionCollection features = SPContext.Current.Site.WebApplication.Farm.FeatureDefinitions;
    if (features["OssNavigation"] != null && features["Publishing"] != null)
        return true;
        return false;

But how can I set the above result(true or false) to the csproj constants?is is possible? if not then how can I load the assembly(dll) based on wss or moss in the project?

share|improve this question

Your code is executed at run-time. A constant is hard coded in the assembly. So it won't possible to create a constant on the fly (even semantically, it does not make sense).

As Moss is a superset of WSS, do you actually have to distinguish? In such cases, I would simply put all WSS compatible in a first project and its set of features, and all Moss-specific code in a second project.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.