tags:

views:

43

answers:

2

I`m interested in using some MOSS dll's if my solution is deployed on MOSS.

For example, if using MOSS, i would like to use built-in logging capabilities.

Is this possible?

+1  A: 

Both WSS and MOSS use the same logging framework. There is no MOSS-specific code. See Using Event and Trace Logs in SharePoint.

If you specifically need to detect MOSS, read this post from Muhimbi. Their approach is to detect the existence of certain features that are only provided by MOSS.

Your assembly can reference MOSS assemblies without causing any problems on a WSS installation. It's only when a method from one of the MOSS assemblies is accessed that a problem will occur (FileNotFoundException). If you follow the Muhimbi post and ensure this can never happen then you will have no issues.

Alex Angas
I'm also interested in other things like using some MOSS specific classes for MOSS out-of-the-box caching if available.Is that possible?
Janis Veinbergs
@Janis: Yes, just set up two code paths that run through the "Do we have MOSS installed?" checkpoint. (In fact, that would be a perfect thing to cache.) As long as no MOSS APIs are called when running on WSS you should be fine. Worse case, you would need to separate the code into different assemblies but test first - it's unlikely.
Alex Angas
But how do you do developing in VS then? How do you reference assemblies that are not present in WSS but is present in MOSS? Can I just reference them and i`ll get no errors if I won't touch them under WSS?
Janis Veinbergs
I believe you can reference an assembly that is not present as long as you don't call any of its methods in the same function that you are carrying out a test for its existence. We do this, for example, in http://www.muhimbi.com/blog/2009/08/microsoft-giveth-and-taketh-mystery-of.html
Muhimbi
@Janis: Yes you are correct (see edit to my answer). As @Muhimbi states there is no problem as long as you don't call a MOSS method. I've tested this on a WSS-only installation.
Alex Angas
Thank you for your assistance - this is really an answer to my question.
Janis Veinbergs
+1  A: 

Yes, it is possible to log/ trace using the built in MOSS ULS.

See this MSDN article for more details. Based on this code, you can do something like this in your code:

    TraceProvider.WriteTrace(0, TraceProvider.TraceSeverity.High, Guid.Empty, 
"MyExeName", "Product Name", "Category Name", "Sample Message");
Magnus Johansson
This is also usefull, thankyou.
Janis Veinbergs