views:

108

answers:

1

I'm building a set of assemblies that need to work on both Silverlight and WPF. Up till now, I've been using log4net to handle logging. It's not compatible with Silverlight though, so now I'm facing the prospect of ripping it out, which I don't want to do.

My question is this. Assuming I recreate the assemblies as Silverlight assemblies, I could wrap (using #ifdef or similar) the logging calls. However, is there any way to 'conditionally' reference the log4net dll? I'm reluctant to give up log4net, and would rather not have to have two versions of every project.

Any help would be appreciated.

A: 

For my common code classes I add them to the Silverlight project using the add as link option. I do use a few ifdefs but try to stay awy from them if possible. For things like log4net I create a "shell" interface for the Silverlight assembly. Below is the one I currently have for log4net.

namespace log4net
{
    public class ILog
    {
        public void Debug(string message)
        { }

        public void Error(string message)
        { }

        public void Info(string message)
        { }

        public oid Warn(string message)
        { }
    }
}
sipwiz