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 / August 2004

Tip: Looking for answers? Try searching our database.

Using a service I have Proffered (Its not working!)

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Bill Foust - 10 Aug 2004 19:08 GMT
I've created and proffered a service successfully (at least I think so, no
errors were generated when it was added) but im unable to retrieve the
service later on.

I have an assembly which defines the interface the service uses.
In another assembly, I define the class and give it a Guid attribute. In the
same assembly, I  have a custom package which creates an instance of the
object and proffers the service in its Initialize function. It also carries
the ProvideService attribute.

I'm trying to use the service in a 3rd assembly. I have a custom UI editor
implemented in this assembly. The Edit function of the UITypeEditor receives
an IServiceProvider, but calling GetService with my service information
returns null. The only thing I can think of is that the IServiceProvider
given in the UITypeEditor is different then the one I added my service to.
But I have no idea how to verify this or how to get around it.

Thanks!

Bill

Heres a quick code dump...

1st Assembly (the interface assembly)
public interface IArcherEditorProviderService

{

ICodeField ViewCode(ICodeField fld);

}

2nd Assembly  (the package)

[Guid("22E837BC-7CBA-4352-8963-9999022EDCFE")]

public class ArcherEditorProviderService : IArcherEditorProviderService

{

public ArcherEditorProviderService(InstrumentPackage pkg)

{

m_Pkg = pkg;

}

private InstrumentPackage m_Pkg;

public ICodeField ViewCode(ICodeField fld)

{

return m_Pkg.ViewCode(fld);

}

}

[MSVSIP.Helper.ProvideService("22E837BC-7CBA-4352-8963-9999022EDCFE",
ServiceName="ArcherEditorProviderService")]

public class InstrumentPackage :
MSVSIP.Helper.Package,MSSHELL.IVsRunningDocTableEvents3,MSSHELL.IVsSolutionE
vents3,MSSHELL.IVsTaskProvider2

{

protected override void Initialize()

{

// even though the docs dont specify this, the PackageHelper does implement
IServiceContainer so this cast is safe.

((IServiceContainer)this).AddService(typeof(IArcherEditorProviderService),
new ArcherEditorProviderService(this), true);

}

}

3rd Assembly (the consumer)

public class CodeFieldEditor : System.Drawing.Design.UITypeEditor

{

public override object EditValue(ITypeDescriptorContext context,
IServiceProvider provider, object value)

{

IArcherEditorProviderService svc =
(IArcherEditorProviderService)provider.GetService(typeof(IArcherEditorProvid
erService));

if (svc != null)

{

return svc.ViewCode(f);

}

}

}
"Ed Dore [MSFT]" - 10 Aug 2004 23:46 GMT
Hi Bill,

I believe you are correct that the IServiceProvider passed to the
UITypeEditor is not the same as the one your package gets via it's SetSite.
You may want to try Querying for IServiceProvider off of the DTE automation
object instead, and then use it to call QueryService to retrieve your
service. Just a guess.

Sincerely,
Ed Dore [MSFT]

This post is 'AS IS' with no warranties and confers no rights.
Bill Foust - 11 Aug 2004 17:19 GMT
I'm sorry Ed, I'm not getting something here. The DTE doesnt have an
IServiceProvider that I can find.

Bill

> Hi Bill,
>
[quoted text clipped - 8 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.