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?

1 Answer 1


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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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