OK, this was much harder than it should have been. I was in the process of creating my own custom Silverlight project templates (I don’t consider the default template usable since it requires you to put your business entities in the host web project!).
Anyway, the host web project needs to get a reference to the Silverlight project–specifically the project’s GUID. Here are the steps you need to take to get this information:
- Install the Visual Studio 2010 SDK: http://www.microsoft.com/downloads/en/details.aspx?FamilyID=47305cf4-2bea-43c0-91cd-1b853602dcc5&displaylang=en
- Add these assemblies to your project:
- Now you can use the following code to retrieve a project’s GUID:
Guid projectGuid= Guid.Empty;
IServiceProvider serviceProvider = new ServiceProvider(project.DTE as Microsoft.VisualStudio.OLE.Interop.IServiceProvider);
IVsSolution solution = serviceProvider.GetService(typeof(Microsoft.VisualStudio.Shell.Interop.SVsSolution)) as IVsSolution;
if (hierarchy != null)
solution.GetGuidOfProject(hierarchy, out projectGuid);
President, Oak Leaf Enterprises, Inc.
Eight-time recipient Microsoft .NET MVP Award
Chief Software Architect, MM .NET Application Framework