I have a Visual Studio Package where items are dynamically added to the menu bar. However, only the fixed entries are shown because the extension is not loaded correctly.
The package is only loaded when you click on a fixed entry. But it should be loaded at the start of the studio.
I tried everything with ProvideAutoLoad, the dynamic items are not shown. I don't know why. What is the problem ?
I hope someone can help me here
thx
[ProvideAutoLoad(VSConstants.UICONTEXT.NoSolution_string, PackageAutoLoadFlags.BackgroundLoad)]
[ProvideAutoLoad(VSConstants.UICONTEXT.SolutionExists_string, PackageAutoLoadFlags.BackgroundLoad)]
should be enough to automatically load a package on Visual Studio startup.
using System;
using System.Diagnostics.CodeAnalysis;
using System.Runtime.InteropServices;
using Microsoft.VisualStudio;
using Microsoft.VisualStudio.Shell;
using Microsoft.VisualStudio.Shell.Interop;
using System.Windows.Forms;
namespace VSIXOpenSCE
{
[PackageRegistration(UseManagedResourcesOnly = true)]
[InstalledProductRegistration("#110", "#112", "1.0", IconResourceID = 400)] // Info on this package for Help/About
[SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1650:ElementDocumentationMustBeSpelledCorrectly", Justification = "pkgdef, VS and vsixmanifest are valid VS terms")]
[ProvideMenuResource("Menus.ctmenu", 1)]
[Guid(MenuControlPackage.PackageGuidString)]
[ProvideAutoLoad(VSConstants.UICONTEXT.NoSolution_string, PackageAutoLoadFlags.BackgroundLoad)]
[ProvideAutoLoad(VSConstants.UICONTEXT.SolutionExists_string, PackageAutoLoadFlags.BackgroundLoad)]
public sealed class MenuControlPackage : Package
{
public const string PackageGuidString = "f5c6cb4a-bb86-48e4-92e6-f0ee6de2de3a";
public MenuControlPackage()
{
// Inside this method you can place any initialization code that does not require
// any Visual Studio service because at this point the package object is created but
// not sited yet inside Visual Studio environment. The place to do all the other
// initialization is the Initialize method.
}
#region Package Members
/// <summary>
/// Initialization of the package; this method is called right after the package is sited, so this is the place
/// where you can put all the initialization code that rely on services provided by VisualStudio.
/// </summary>
protected override void Initialize()
{
base.Initialize();
MenuControl.Initialize(this);
}
#endregion
}
}
Related
In beta 5 the intellisense in VS2015 doesn't work for taghelpers.
I fixed the missing attribute error message with adding this stub to my project
How can I fix this?
using System;
namespace Microsoft.AspNet.Mvc
{
/// <summary>
/// Specifies that a property or parameter value should be initialized via the dependency injection
/// container for activated types.
/// </summary>
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Parameter, AllowMultiple = false)]
public sealed class ActivateAttribute : Attribute
{
}
}
Found IT. I used beta 6 for a moment. But forgot to rename _ViewImports to _GlobalImport
I'm developing with Silverlight 4 and Prism 4.
I'm also using Unity as my injection container.
I'm trying to create the module catalog from xaml, but I get this error "IModuleCatalog does not contain a definition of CreateFromXaml...".
My code snippet is:
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Practices.Prism.UnityExtensions;
using Microsoft.Practices.ServiceLocation;
using Microsoft.Practices.Prism.Modularity;
using Microsoft.Practices.Prism.MefExtensions;
namespace MyModularityProject {
public class MyBootStrapper : UnityBootstrapper {
protected override DependencyObject CreateShell() {
return ServiceLocator.Current.GetInstance<Shell>();
}
protected override void InitializeShell() {
base.InitializeShell();
Application.Current.RootVisual = (UIElement)Shell;
}
protected override IModuleCatalog CreateModuleCatalog() {
// This is the isntruction that doesn't compile
return ModuleCatalog.CreateFromXaml(new
Uri("/MyProject.Silverlight;component/ModulesCatalog.xaml",
UriKind.Relative));
}
}
}
What could I be missing here?
The reason that you need to add the full path to the ModuleCatalog type is that there is a ModuleCatalog property within the Bootstrapper base class that UnityBootstrapper inherits. If you don't qualify the name, you are essentially calling an accessor on a property which returns IModuleCatalog. The interface definition does not include this function.
Is it possible to get DLL's names and version information from a appmanifest.xml which resides in a VS2010 project corresponding to a PRISM Module ?
My Silverlight 4 application loads on demand all modules listed in the modules catalog. I guess this means that it has downloaded all the modules corresponding XAP files, appmanifest.xml files – to load the necessary resources (DLL’s, etc)
So, at this point, how can I access DLL's names and if possible DLL's version number of every module from within my "main" Silverlight project ??
Thanks for your feedback!
You can do this in the ModuleInit.cs of each PRISM module. Somewhat like:
public class ModuleInit : IModule
{
private readonly IUnityContainer _container;
private readonly IRegionManager _regionManager;
public ModuleInit(IUnityContainer container, IRegionManager regionManager)
{
_container = container;
_regionManager = regionManager;
// Add this assembly details to a global collection
Global.ClientAssemblies.Add(GeneralHelper.GetAssemblyInfo(System.Reflection.Assembly.GetExecutingAssembly()));
}...
Helper function:
public static string GetAssemblyInfo(Assembly assembly)
{
return assembly.ToString();
}
I am using MEF, MVVM and Silverlight4 and below is my code
Main.cs:
using System;
using System.ComponentModel;
using System.ComponentModel.Composition;
using System.ComponentModel.Composition.Diagnostics;
using System.ServiceModel.DomainServices.Client.ApplicationServices;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Navigation;
public partial class Main : UserControl
{
public Main()
{
InitializeComponent();
// Satisfy the MEF imports for the class.
if (!DesignerProperties.IsInDesignTool)
{
CompositionInitializer.SatisfyImports(this);
}
}
/// <summary>
/// Sets the datacontext to the viewmodel for this view
/// </summary>
[Import(ViewModelTypes.MainViewModel)]
public object ViewModel
{
set
{
this.DataContext = value;
}
}
}
Viewmodel:
using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.Windows.Input;
[Export(ViewModelTypes.MainViewModel)]
[PartCreationPolicy(CreationPolicy.NonShared)]
public class MainViewModel : ViewModelBase
{
[ImportingConstructor]
public MainViewModel(IAuthenticationModel authModel, IprospectManagementModel managementModel)
{
this.authenticationModel = authModel;
this.managementModel = managementModel;
}
/// <summary>
/// The authentication model.
/// </summary>
private IAuthenticationModel authenticationModel;
/// <summary>
/// The Iprospect management model.
/// </summary>
private IprospectManagementModel managementModel;
}
Below is the error i am getting, Please do help me out trace the same.
The composition remains unchanged. The changes were rejected because of the following error(s): The composition produced a single composition error. The root cause is provided below. Review the CompositionException.Errors property for more detailed information.
1) No valid exports were found that match the constraint '(exportDefinition.ContractName == "MainViewModel")', invalid exports may have been rejected.
Resulting in:
Cannot set import 'IProspectCommonApp.Client.Main.ViewModel (ContractName="MainViewModel")' on part 'IProspectCommonApp.Client.Main'.
Element: IProspectCommonApp.Client.Main.ViewModel (ContractName="MainViewModel") --> IProspectCommonApp.Client.Main
It is probably failing because there is no IAuthenticationModel and/or IprospectManagementModel exported. The MainViewModel imports these via the ImportingConstructor, so it can't be created if they haven't been exported.
For more information on MEF debugging, see How to Debug and Diagnose MEF Failures.
I've got some C++/CLI software which is all nice and documented in a C#'ish kind of way which means DOxygen is able to pull it out into some nice html. Is there any way I can get that same information to appear in the intellisense tool tips the way that the .net framework does?
For example, lets say this is my header file (MyApp.h):
/*************** MyApp.h ***************/
/// My namespace containing all my funky classes
namespace MyNamespace
{
using namespace System;
ref class WorldHunger;
/// A truly elegent class which solves all the worlds problems
public ref class MyClass
{
public:
/// Constructs a MyClass
MyClass()
{
}
/// <summary>Attempts to fix world hunger</summary>
/// <param name="problem">The problem to try and fix</param>
/// <returns>Whether or not the problem was solved</param>
bool FixWorldHunger( WorldHunger^ problem );
};
}
...and this it's corresponding implementation:
/*************** MyApp.cpp ***************/
#include "MyApp.h"
using namespace MyNamespace;
MyClass::MyClass()
{
}
bool MyClass::FixWorldHunger( WorldHunger^ problem )
{
bool result = false;
/// TODO: implement something clever
return result;
}
Here's what intellisense does for built in functions when I'm typing:
http://www.geekops.co.uk/photos/0000-00-02%20%28Forum%20images%29/BrokenIntellisense1.jpg
Here's what intellisense does for my own functions when I type:
http://www.geekops.co.uk/photos/0000-00-02%20%28Forum%20images%29/BrokenIntellisense2.jpg
Surely there's a way to do this?
Just to summarise, for this to work you need your comments in a compatible form:
/// <summary>
/// Retrieves the widget at the specified index
/// </summary>
/// <param name="widgetIndex">Index of the widget to retrieve.</param>
/// <returns>The widget at the specified index</returns>
Widget* GetWidget(int widgetIndex);
Then you simply right-click on the project in Visual Studio and go to properties > configuration properties > C/C++ > Output Files and change Generate XML Documentation Files to Yes.
When you rebuild your project ad import it somewhere else, you should see fully documented tooltips appear.