Quantcast
Channel: Visual Studio Integrate forum
Viewing all articles
Browse latest Browse all 4410

Custom project creation in VS 2012 fails throwing "Class not registered.Looking for object with CLSID: {020CD351-2EA1-4645-9AA7-E139DDF12419}" error

$
0
0

I am currently working on a product that has integration with Visual Studio 2005. The integration uses a managed VSPackage(developed using C#),
the PackageUI(developed using VC++), to integrate with VS Shell to provide our product functionality in VS IDE. The package and it's UI were developed using VS2005. The package implements functionality for creating custom projects in VS using "FlavoredProjectFactory" class contained in "Microsoft.VisualStudio.Shell.Flavor" namespace - a factory for creating
flavored projects - otherwise known as project subtypes.Now we are in the process of upgrading the integration support to VS 2010 and VS 2012. As part of it, we used the same VS 2005 Package as is with shell
references updated to VS 2010 SP1 and some code changes in the package to support the upgradations. With these changes the product functionality is working fine in VS 2010. But, in VS 2012, the custom project
creation is failing throwing an error "Class not registered.Looking for object with CLSID: {020CD351-2EA1-4645-9AA7-E139DDF12419}". We noticed that the project creation is being successful and product functionality absolutely working fine in VS 2012, in case if the machine also contained VS 2005 install. After investigating the issue for a while, it was found that the custom project creation in VS 2012
is depending on a VS 2005 shell dll named "ProjectAggregator". If it is able to find the shell dll in VS installation path(For example: "C:\Program Files (x86)\Microsoft Visual Studio 8\Common7\IDE") and its related entries in the windows registry, custom project creation is successful or else it's failing. This dependency is not there with VS 2010.

Following are the shell references used in the VSPackage:

1. Microsoft.VisualStudio.OLE.Interop
2. Microsoft.VisualStudio.ProjectAggregator
3. Microsoft.VisualStudio.Shell
4. Microsoft.VisualStudio.Shell.Interop
5. Microsoft.VisualStudio.Shell.Interop.8.0
6. Microsoft.VisualStudio.TextManager.Interop

and following is the code snippet that resides in a class inherited from "Microsoft.VisualStudio.Shell.Flavor.FlavoredProjectFactory" class to create the custom project:

/// <summary>
  /// Create an instance of our project. The initialization will be done later
  /// when VS call InitalizeForOuter on it.
  /// </summary>
  /// <param name="outerProject">This is only useful if someone else is subtyping us</param>
  /// <returns>An uninitialized instance of our project</returns>
  protected override object PreCreateForOuter(object outerProject)
  {
   VerifyCreate();

   // Note: to support being aggregated (flavored) ourself, we must use
   // CreateInstance (passing in the outer object) rather than new

   // Using the ILocalRegistry implementation means we can register our
   // CLSID under the VS registry hive rather then globaly (although this
   // approach still support creating globaly registered CLSID).
   ILocalRegistry localRegistry = (ILocalRegistry)package.GetPackageService(typeof(SLocalRegistry));

   // Create an instance of our project
   IntPtr newProjectIUnknown;
   Guid riid = VSConstants.IID_IUnknown;
   ErrorHandler.ThrowOnFailure(
    localRegistry.CreateInstance(typeof(SpecializedProject).GUID, outerProject, ref riid, 0, out newProjectIUnknown)
   );

   SpecializedProject newProject = (SpecializedProject)Marshal.GetObjectForIUnknown(newProjectIUnknown);
   Marshal.Release(newProjectIUnknown);
   newProject.Package = package;

   return newProject;
  }

The "Class not registered...." error is thrown at the line of code execution highlighted in bold and "{020CD351-2EA1-4645-9AA7-E139DDF12419}" CLSID in the error message is the GUID of  "SpecializedProject"class derived from "Microsoft.VisualStudio.Shell.Flavor.FlavoredProject" class which is the base class for implementing flavored/project sub types in Visual Studio IDE. I checked the windows registry and found the CLSID with all its entries there. Per my understanding, the type with the CLSID in the error message is getting successfully registered in the windows registry, but is depending on VS 2005 "ProjectAggregator" shell dll during custom project creation in VS 2012. 

Can someone help me in understanding the dependency mentioned above? How can we eliminate this dependency to successfully create our projects in VS 2012? Please suggest me the right way of doing it.



Viewing all articles
Browse latest Browse all 4410

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>