Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Visual Studio.NET / Extensibility / September 2004

Tip: Looking for answers? Try searching our database.

Getting IServiceProvider

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Bill Foust - 28 Sep 2004 00:15 GMT
Is there a way to get an IServiceProvider without being given it? Some
static global function is what I'd like to find.

Bill
"Gary Chang" - 28 Sep 2004 10:48 GMT
Hi Bill,

> Is there a way to get an IServiceProvider without being given it? Some
static global function is what I'd like to find.

What's the exact scenario(the specific object's IServiceProvider) do you
concern on?

Thanks!

Best regards,

Gary Chang
Microsoft Online Partner Support

Signature

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
Bill Foust - 28 Sep 2004 16:23 GMT
One that can get to services I've proffered in my VSIP Package.
Bill

> Hi Bill,
>
[quoted text clipped - 14 lines]
> This posting is provided "AS IS" with no warranties, and confers no rights.
> --------------------
"Ed Dore [MSFT]" - 28 Sep 2004 17:14 GMT
Hi Bill,

Are you attempting to retrieve an IServiceProvider from within a VSIP
package? I've found a number of instances where I needed to query for a
particular service, only to find I didn't have an actual IServiceProvider
handy.

In these cases you might find it handy to create a static Instance property
for your package object, and a public GetService method that you can use to
retrieve a service. For example::

  .....
  public class SomePackage : MSVSIP.Package
  {
     public static SomePackage Instance = null;
 
     public SomePackage()
     {
        Instance = this;
     }

     public new object GetService(Type serviceType)
     {
        return base.GetService(serviceType);
     }

     .........
  }

Then you can just use
SomePackage.Instance.GetService(typeof(ISomeService)), to retrieve the
interface you're looking for.

Sincerely,
Ed Dore [MSFT]

This post is 'AS IS' with no warranties, and confers no rights.
Bill Foust - 28 Sep 2004 19:34 GMT
Except that the class wanting to get the services doesn't know about the
package and is in a different assembly. Otherwise, I'd agree! :)

Bill

> Hi Bill,
>
[quoted text clipped - 33 lines]
>
> This post is 'AS IS' with no warranties, and confers no rights.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.