|
15 | 15 |
|
16 | 16 | namespace ExcelDNAVSExtension |
17 | 17 | { |
18 | | - /// <summary> |
19 | | - /// This is the class that implements the package exposed by this assembly. |
20 | | - /// </summary> |
21 | | - /// <remarks> |
22 | | - /// <para> |
23 | | - /// The minimum requirement for a class to be considered a valid package for Visual Studio |
24 | | - /// is to implement the IVsPackage interface and register itself with the shell. |
25 | | - /// This package uses the helper classes defined inside the Managed Package Framework (MPF) |
26 | | - /// to do it: it derives from the Package class that provides the implementation of the |
27 | | - /// IVsPackage interface and uses the registration attributes defined in the framework to |
28 | | - /// register itself and its components with the shell. These attributes tell the pkgdef creation |
29 | | - /// utility what data to put into .pkgdef file. |
30 | | - /// </para> |
31 | | - /// <para> |
32 | | - /// To get loaded into VS, the package must be referred by <Asset Type="Microsoft.VisualStudio.VsPackage" ...> in .vsixmanifest file. |
33 | | - /// </para> |
34 | | - /// </remarks> |
35 | 18 | [PackageRegistration(UseManagedResourcesOnly = true, AllowsBackgroundLoading = true)] |
36 | 19 | [Guid(VSPackage.PackageGuidString)] |
37 | 20 | [SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1650:ElementDocumentationMustBeSpelledCorrectly", Justification = "pkgdef, VS and vsixmanifest are valid VS terms")] |
| 21 | + [ProvideMenuResource("Menus.ctmenu", 1)] |
38 | 22 | public sealed class VSPackage : AsyncPackage |
39 | 23 | { |
40 | | - /// <summary> |
41 | | - /// VSPackage GUID string. |
42 | | - /// </summary> |
43 | 24 | public const string PackageGuidString = "8123a50c-24f3-4eb6-8e12-6e852e023779"; |
44 | 25 |
|
45 | | - /// <summary> |
46 | | - /// Initializes a new instance of the <see cref="VSPackage"/> class. |
47 | | - /// </summary> |
48 | 26 | public VSPackage() |
49 | 27 | { |
50 | | - // Inside this method you can place any initialization code that does not require |
51 | | - // any Visual Studio service because at this point the package object is created but |
52 | | - // not sited yet inside Visual Studio environment. The place to do all the other |
53 | | - // initialization is the Initialize method. |
54 | 28 | } |
55 | 29 |
|
56 | 30 | #region Package Members |
57 | 31 |
|
58 | | - /// <summary> |
59 | | - /// Initialization of the package; this method is called right after the package is sited, so this is the place |
60 | | - /// where you can put all the initialization code that rely on services provided by VisualStudio. |
61 | | - /// </summary> |
62 | | - /// <param name="cancellationToken">A cancellation token to monitor for initialization cancellation, which can occur when VS is shutting down.</param> |
63 | | - /// <param name="progress">A provider for progress updates.</param> |
64 | | - /// <returns>A task representing the async work of package initialization, or an already completed task if there is none. Do not return null from this method.</returns> |
65 | 32 | protected override async Task InitializeAsync(CancellationToken cancellationToken, IProgress<ServiceProgressData> progress) |
66 | 33 | { |
67 | | - // When initialized asynchronously, the current thread may be a background thread at this point. |
68 | | - // Do any initialization that requires the UI thread after switching to the UI thread. |
69 | 34 | await this.JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken); |
| 35 | + try |
| 36 | + { |
| 37 | + commands = new Commands(this); |
| 38 | + } |
| 39 | + catch (System.Exception e) |
| 40 | + { |
| 41 | + ExceptionHandler.ShowException(e); |
| 42 | + } |
70 | 43 | } |
71 | 44 |
|
72 | 45 | #endregion |
| 46 | + |
| 47 | + private Commands commands; |
73 | 48 | } |
74 | 49 | } |
0 commit comments