4

I am having an heck of a time trying to get two separately scoped solutions to work together.

The first solution is scoped for Farm and does nothing more than add a custom SPDiagnosticService. When this is deployed it appears to be fine as I can see my custom diagnostic categories in Central Administration.

The second solution depends on the first and is responsible for testing the first solution by writing events to the SharePoint diagnostic infrastructure. It does this by initiating an instance of the MyDiagnosticService class and executing methods on that class. This second solution is a webpart and scope for site. When I deploy this and add the web part to the page still all is well until I attempt to have it write a diagnostic event using a button click event.

In the button click event the failure occurs on this line:

MyDiagnosticService diagSrvc = MyDiagnosticService.Local;

This is the error msg:

   SPDuplicateObjectException An object of the type MyDiagnosticService named "My Diagnostics" already exists under the parent Microsoft.SharePoint.Administration.SPFarm named "SP_Config_Farm".  Rename your object or delete the existing object.

It was my thought that when the first solution is deployed the MyDiagnosticService class is installed in the GAC and available to any subsequent solution that may want to use it. I want to know what I am doing wrong. Thanks for the help.

1 Answer 1

1

It does not appear to be a Feature Scope problem as the title says. The most likely reason I could think of is that your diagnostic service has been registered twice with the Farm. To verify that, can you write a small Console app like:

SPServiceCollection services = SPFarm.Local.Services;
            var diagServices = from service in services
                               where service is MyDiagnosticService
                                   select service;
Console.WriteLine(diagServices.Count());

If you see more than 1, you may want to delete the duplicate service..

Your Answer

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

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