Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8977843
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T19:27:59+00:00 2026-06-15T19:27:59+00:00

I want to decouple some things in my code so that I don’t have

  • 0

I want to decouple some things in my code so that I don’t have to include DLLs that are used in the main project also in the sub-project. For this i have created the following method to register services (which uses the MS Common Practices Service Locator):

public static void RegisterService<TInterface>(SPSite site) where TInterface : IServiceLocatorRegisterable, new()
        {
            GetServiceLocatorConfig(site).RegisterTypeMapping<IServiceLocatorRegisterable, TInterface>(typeof(TInterface).FullName);
            InvalidateCache();

So, as you see I created the Interface “IServiceLocatorRegisterable” so that I’m not bound to a specific interace yet.

In the sub project I have a specific interface I want to register with the service locator, so I added the “IServiceLocatorRegisterable” to the declaration:

public interface ISapProcess : IServiceLocatorRegisterable
{ // details omitted.. }

And this is the code where I try to register this interface:

public static void RegisterSapProcess(SPSite site)
{
    ServiceLocator.RegisterService<ISapProcess>(site);
}

But I cannot compile it as I get the follwing compiler error:

ISapProcess must be a non-abstract type with a public parameterless
constructor in order to use it as parameter ‘TInterface’ in the
generic type or method ‘….RegisterService(SPSite)’

.. and as I know see it doesn work either when I would try to register the “base interface” directly (which of course wouldn’t make any sense, as I want to register and locate the specific interfaces/implemenations):

ServiceLocator.RegisterService<IServiceLocatorRegisterable>(site);

I have the feeling that I’m missing something important here.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T19:28:00+00:00Added an answer on June 15, 2026 at 7:28 pm

    Well yes – look at your constraint:

    where TInterface : IServiceLocatorRegisterable, new()
    

    You can’t write:

    ISapProcess x = new ISapProcess();
    

    can you? That’s what the constraint requires.

    You either need to ditch the constraint, or change your type argument. (It’s not clear what you’re trying to do given the code you’ve provided.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some JavaScript code that creates some div elements and it sets their
I want to to decouple some parts in my rather large app and delegate
I have an existing VS 2005 Std .NET Compact Framework application that I want
Does anyone have experience with message transports that are both decoupled(senders and receivers don't
Want to run javascript function from parent window in child window Example I have
want to have a Hyperlink-Button in a gridView in which I can display a
Want to code a key pad for an calculator. What I want to make
Greetings! I have a working iPhone app (huzzah!) that uses a MainView.xib containing a
I'm trying to decouple some of the bits of our big-ball-of-mud architecture, and identified
I'll be using a datePicker several places in my app. I don't want to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.