SQL Server Management Studio add-ins
In some cases, with various ApexSQL add-ins integrated into the same host, after an upgrade of one or more add-ins, the user might be unable to launch the host application successfully.
During the splash screen, a warning message is displayed with the following or similar text:
- The ‘Stub’ package did not load correctly.
- The problem may have been caused by a configuration change or by the installation of another extension. You can get more information by examing the file ‘C:\Users\BPetrovi\AppData\Roaming\Microsoft\AppEnv\15.0\ActivityLog.xml’
- Restarting Visual Studio could help resolve this issue.
- Continue to show this error message?
The above message is shown for a split second followed by multiple “Object reference not set to an instance of an object” dialog boxes as shown below in a way that has or seems to have no end:
The only way to get SSMS to startup is to quickly close all of those “Object reference not set to an instance of an object” dialog boxes by clicking the OK button (best to hold Enter from the keyboard). Besides, the warning about the Stub package not being loaded correctly should also be closed by clicking either the Yes or No button.
When all of the piled-up messages are closed, the host application is started. However, this workaround is only temporary as with each SSMS launch the issue is continuing firmly.
This problem usually occurs because of the order in which the ApexSQL add-ins are installed and integrated into SQL Server Management Studio. Namely, some ApexSQL add-ins are less frequently released and include references to some files and versions that don’t exist in the configuration files or are named incorrectly.
For example, if we have ApexSQL Refactor 2021 pre-installed into SSMS 18, and then an installation of ApexSQL Unit Test is run and integrated into the same host – this behavior is most likely to occur as, during the ApexSQL Unit Test installation, configuration files are overwritten forcing the incorrect name convention.
First of all, we need to check if the root cause is what’s described above or something else. A good starting point is to check the ActivityLog.xml file listed in the first warning message
Close the host application if it’s “running” using the method described in the problem description section and follow these steps:
Go to the path from the warning message and open the ActivityLog.xml file in any text editor (preferably Notepad++)
- Note: AppData folder is a hidden folder, make sure to enable showing hidden files and folders in the File Explorer
Go to Search | Find… of press Ctrl + F from the keyboard and type “apexsql” in the Find what box and click Find All in Current Document option
See if an error is logged with the following description (there should be 4 identical entries):
<description>CreateInstance failed for package [Stub]Source: 'mscorlib' Description: Could not load type 'ApexSql.Common.Extensibility.Stub' from assembly 'ApexSql.Common.Extensibility.Stub.18, Version=7.0.978.0, Culture=neutral, PublicKeyToken=3b936d7fbc8f6b28'.
System.TypeLoadException: Could not load type 'ApexSql.Common.Extensibility.Stub' from assembly 'ApexSql.Common.Extensibility.Stub.18, Version=7.0.978.0, Culture=neutral, PublicKeyToken=3b936d7fbc8f6b28'.
at System.Reflection.RuntimeAssembly.GetType(RuntimeAssembly assembly, String name, Boolean throwOnError, Boolean ignoreCase, ObjectHandleOnStack type)
at System.Reflection.RuntimeAssembly.GetType(String name, Boolean throwOnError, Boolean ignoreCase)
at System.Activator.CreateInstanceFromInternal(String assemblyFile, String typeName, Boolean ignoreCase, BindingFlags bindingAttr, Binder binder, Object args, CultureInfo culture, Object activationAttributes, Evidence securityInfo)
at System.AppDomain.CreateInstanceFrom(String assemblyFile, String typeName)</description>
If the above or similar error is logged, then we need to examine the content of the configuration .pkgdef file.
Go to the following path: C:\Program Files (x86)\Microsoft SQL Server Management Studio 18\Common7\IDE\Extensions\ApexSQLStub and open ApexSql.Common.Extensibility.Stub.18.pkgdef in any text editor
Note: The path might be different depending on the SSMS version. The easiest way to get to the targeted path is to right-click the SQL Server Management Studio icon, choose the Properties option, and then Open File Location:
This will get you to the IDE folder in File Explorer where you’re just two steps from the configuration file. Simply navigate to Extension | ApexSQLStub for all of SSMS versions:
Change the highlighted text from “ApexSql” to “ApexSQL” and save changes
Another possible solution is to examine Programs and Features from Control Panel and look for the last installed ApexSQL add-in that caused the issue. In this case, ApexSQL Unit Test was the last installed add-in.
Re-run the installation of an add-in that was installed on an older date to fix the issue. For example, ApexSQL Refactor was installed a day before when everything was fine, meaning it will overwrite the configuration file and make things alright again:
Waiting for fix in future releases of ApexSQL add-ins.