Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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;
    else
        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

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.

share|improve this answer

Your Answer

 
discard

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.