I am developing an Outlook Addin Project using C#.NET 4.5
But After I deploy, Sometimes outlook disables my addin, and shows this message.
"This addin caused outlook to start slowly"" I dont know whats wrong with my addin.
This has only a few codes, and ThisAddIn_Startup is empty in this project.
Here is the code...
public partial class ThisAddIn
{
private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
}
private void ThisAddIn_Shutdown(object sender, System.EventArgs e)
{
}
protected override Microsoft.Office.Core.IRibbonExtensibility CreateRibbonExtensibilityObject()
{
return new Ribbon1();
}
#region VSTO generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InternalStartup()
{
this.Startup += new System.EventHandler(ThisAddIn_Startup);
this.Shutdown += new System.EventHandler(ThisAddIn_Shutdown);
}
#endregion
}
<?xml version="1.0" encoding="UTF-8"?>
<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui" önLoad="Ribbon_Load">
<contextMenus>
<contextMenu idMso="ContextMenuContactItem">
<menuSeparator id="mniMailItemMenuSeparator" />
<button id="customButton"
label="Call using Software" insertBeforeQ="Copy"
imageMso="Call"
önAction="OnMyButtonClick" />
</contextMenu>
<contextMenu idMso="ContextMenuMailItem">
<menuSeparator id="mailmenusep1" />
<button id="mailbutton" insertBeforeQ="Copy"
label="Call using Software"
imageMso="Call"
önAction="MailItemCallNumbers" />
</contextMenu>
</contextMenus>
</customUI>
Starting with Outlook 2013, Microsoft introduced new performance criteria for add-ins. For more information see http://msdn.microsoft.com/en-us/library/office/jj228679.aspx#ol15WhatsNew_AddinDisabling
In your case, Outlook is loading the .Net framework and is considering the cost as part of your add-in. Native COM add-ins tend to load faster than .Net add-ins.
As the article points out (in the section "System Administrator control over add-ins", there is a Group Policy setting that allows you to specify which add-ins are always enabled, always disabled (blocked), or configurable by the user.
Though not recommended, as Outlook does when "Always enable this Add-In" is selected (as described here), you could directly add your add-in to the following registry key.
HKCU\Software\Microsoft\Office\15.0\Outlook\Resiliency\DoNotDisableAddinList
For improving the performance of VTSO based add-in, see Performance Improvements Coming Soon to a Service Pack Near You
For changing when an add-in is loaded, see Delay-loading the CLR in Office Add-ins.
This can happen on an empty project if you build your add-in in debug mode and attach the debugger to it. The added time required to load all the symbols files into the debugger when it get attached might take longer than Outlook is expecting for a "stable" plugin to initialize.
You shouldn't worry about this unless it happens in a release build with no debugger attached. During development, you can simply tell outlook to never disable your plugin.
Try delay loading of your addins. Try setting Load Behaviour to 8 or 9 for On-Demand loading.
Check this for more
http://blogs.msdn.com/b/andreww/archive/2008/04/19/delay-loading-the-clr-in-office-add-ins.aspx
I know this is an older post, but I found something online that helped me out.
Your post says "This addin caused outlook to start slowly I dont know whats wrong with my addin." I found if you add a particular Environment Variable that more robust messages will appear.
From the Start menu, right click Computer -> Properties -> Advanced System Settings -> click the Environment Variables button. Click New button under the bottom pane called System Variables and add the following. Enter 'VSTO_SUPPRESSDISPLAYALERTS' with a variable value of 0 (Zero). Should look like this.
Now re-open the application that your add-in was attached too, for me it was Outlook. When the add-in starts the error message should now appear with a Details button, click and read through the Exception. For me it looked like this.
Related
I'm currently doing some cross-platform mobile development through Visual Studio using Xamarin (so in C#) and am about to start the iOS portion. I've never done iOS development before and thought I could get myself acquainted with their "Hello, iOS" Tutorials. Unfortunately, things have not been going smoothly. I constantly get NSInvalidArgumentExceptions from my TouchUpInside actions:
Foundation.MonoTouchException: Objective-C exception thrown.
Name: NSInvalidArgumentException Reason:
-[ViewController TranslateButton_TouchUpInside:]:
unrecognized selector sent to instance 0x7b6200d0
I can occasionally remedy it for a moment by literally remaking the Buttons, but it breaks pretty much right afterwards. The actual error itself occurs in my Main.cs file:
using UIKit;
namespace CheckinIOS
{
public class Application
{
static void Main(string[] args)
{
UIApplication.Main(args, null, "AppDelegate"); //this line is where it breaks
}
}
}
In case it is any helpful, I am trying to deploy to iPhone 5S simulator running iOS 9.3 (but it breaks on iPhone 6 simulator as well). I could also post more of my code if necessary, but I copypasted all the C# from Xamarin's tutorial, and did the same thing as them for Main.storyboard.
I have spent a while looking for people with the same problem as me, but their solutions either did not work, or they got the error for slightly different reasons. Any assistance is appreciated.
EDIT: Here is my implementation of TranslateButton_TouchUpInside:
TranslateButton.TouchUpInside += (object sender, EventArgs e) =>
{
// Convert the phone number with text to a number
// using PhoneTranslator.cs
translatedNumber = PhoneTranslator.ToNumber(PhoneNumberText.Text);
// Dismiss the keyboard if text field was tapped
PhoneNumberText.ResignFirstResponder();
if (translatedNumber == "")
{
CallButton.SetTitle("Call", UIControlState.Normal);
CallButton.Enabled = false;
}
else
{
CallButton.SetTitle("Call " + translatedNumber, UIControlState.Normal);
CallButton.Enabled = true;
}
};
The iOS Runtime is looking for a method called (in Obj-C land) TranslateButton_TouchUpInside: in your ViewController class. However there is no method exported to Obj-C with that name. A first guess is that you added an event to the button in the storyboard that perhaps had that name, but you either deleted that method or never implemented it.
Try opening your storyboard in iOS Designer and removing any event from the Properties->Events tab when your button is selected on the canvas. Also I assume your button has the name TranslateButton in the Properties->Widget pane when the button is selected on the canvas.
There are a couple ways to attach events to controls in Xamarin iOS. One, and the preferred way, is to create an event in iOS Designer for the control. If you do this, a partial method stub will be in the .designer.cs file with an Export attribute that exports the method name to the Obj-C runtime. You will then need to implement this method, using the same signature (without the Export Attribute), in your main .cs file for the ViewController. This is called, in Obj-C land, an action.
The other way is to do as is shown in your code snippet. In this case you ONLY need to give the control a name in the Properties->Widget pane that you can then use in code to subscribe to the TouchUpInside event. This is called, in Obj-C land, an outlet.
My guess is that you did both but without ever implementing the TranslateButton_TouchUpInside: method in your ViewController. Note that this is the Obj-C name used in the Export attribute of the method stub created in the .designer.cs file when you add an event to a control.
But it is hard to say without seeing the storyboard and both the main ViewController.cs file and the ViewController.designer.cs file
I'm using VSTO to design an application with an Excel interface. I want to hide the ribbon on startup (shouldn't be needed in the application) and re-display it on exit (if the user had it originally displayed), to avoid irritating people who use the application and want a ribbon the next time they open Excel.
I can hide the ribbon using essentially the following code in ThisWorkbook_Startup (from this question Excel 2007 Minimize the Ribbon programatically but Not the menu bar):
Office.CommandBars cbs = null;
cbs = Application.CommandBars;
foreach (Office.CommandBar commandBar in cbs)
{
if (commandBar.Name == "Ribbon")
{
this.Application.ActiveWindow.Activate();
Application.SendKeys("^{F1}", true);
}
}
However, the same code or similar variations from the previously referenced question do not seem to work when placed in either the ThisWorkbook_Shutdown or ThisWorkbook_BeforeClose methods. The code is hit but never seems to execute - the ribbon is never restored.
Is there another way to restore the ribbon on exit?
Thanks,
Andrew
I am creating a small Visual Studio 2010 extension in C# which uses the IWpfTextViewCreationListener and TextViewCreated to capture when a new TextView is opened in the VS environment. The problem I am having is that this method only fires when a new window is opened via the VS Solution Explorer window, and not fired when VS already contains opened windows when started, and switching window tabs. I have tried looking for something like TextViewChanged, but could not find such method. Is there anyway to capture the new TextView when another tabbed window is selected?
Any help would be greatly appreciated.
This question has also been posted on the MSDN VS Extensibility forum:
VSX 2010 - Alternative to TextViewCreated such as (TextViewChanged)?
Thanks
John
There is no TextViewCreated, but if you register to IWpfTextView.GotAggregateFocus as it is created, you get a hook to every switch between files:
public void TextViewCreated(IWpfTextView textView)
{
textView.GotAggregateFocus += TextViewCameToFocus;
// Do stuff when a new IWpfTextView is created...
}
void TextViewCameToFocus(object sender, EventArgs e)
{
var focusedTextView = (IWpfTextView)sender;
// Do stuff when a specific IWpfTextView comes to focus...
}
You may also want to keep track of the IWpfTextView objects, if you want to be able to link between the fired events to your logic of each textview.
I plan to add functionalities to TextBox with the following:
public class TextBoxExt : TextBox
{
protected override void OnKeyPress(KeyPressEventArgs e)
{
base.OnKeyPress(e);
}
}
The question is how can we use this TextBoxExt? Is there anyway to get this class onto the ToolBox so that we can just drag and drop it onto the form? If not, what is the best way to use the TextBoxExt?
Build you project with TextBoxExt, make sure it compiles ok.
With the form that you want TextBoxExt on, open the toolbox, right click and select "choose items"
Browse to you .exe or dll that you compiled in 1)
make sure that TextBoxExt has a tick next to it, press ok
TextBoxExt should appear in the toolbox, drag it onto your form
(There is another way of doing this, opening the designer file and renaming the instances of TextBox to TextBoxExt but manual editing of designer files can be considered hazardous by some)
I know this is super old question, but maybe still useful for someone else that has same problem like me - as it's still on the top Google :)
You might interest to use ToolboxItemAttribute (http://msdn.microsoft.com/en-us/library/system.componentmodel.toolboxitemattribute(v=vs.110).aspx).
I did this at my end to resolve the problem.
[ToolboxItem(true)]
public class PanelTitle : LabelControl {
// Whatever code to override LabelControl here...
}
Rebuild the solution and the extended control should be shown in the toolbox.
Any custom control in your project should show up in the Toolbox automatically. I have found that sometimes the controls won't show until you close a re-open Visual Studio. I assume the issue has something to do with caching of the contents of the Toolbox.
You need to add a constructor to your derived class.
public class TextBoxExt : TextBox
{
public TextBoxExt()
{
}
protected override void OnKeyPress(KeyPressEventArgs e)
{
base.OnKeyPress(e);
}
}
Your control should appear in the toolbox for your solution automatically. To have it appear for other projects, you have to do Choose Toolbox items, as others have said.
If you want to provide special design-time functionality, then you will also need to provide some additional designer related attributes and probably your own class derived from ControlDesigner.
I fell into this trap just a couple of hours ago.
I've got a .NET 2.0 Windows Application project with some custom UserControls; it worked fine.
So I decided to order my files in subfolders, to make my project a little bit cleaner.
After that, Visual Studio 2010 designer stopped loading my forms, and ToolBox won't show my controls anymore.
I freaked out, moving back source files in project root, resetting ToolBox, but nothing seemed to work.
After that, I remembered I used ReSharper "Remove Unused References", so I tried to put back unused reference, in particular System.Data: problem solved! :O
I can't say you why, but this worked for me.
Hope my experience can help someone else. :)
Bye,
Nando
I created an empty constructor for my custom implementation of UltraGridBagLayoutPanel. Although david.healed is right it isn't necessary, it is quite useful to put a breakpoint in to check that when the form initialises it is using your class to implement your custom control.
It would have been a lot easier to edit the designer file, but I tried it and changed both the field type for the control and also changed the assignment of the field to a new instance of my custom control.
private Infragistics.Win.Misc.UltraGridBagLayoutPanel ultraGridBagLayoutPanel1;
this.ultraGridBagLayoutPanel1 = new Infragistics.Win.Misc.UltraGridBagLayoutPanel();
to
private Athia.Reports.ultraGridBagLayoutPanel1 ultraGridBagLayoutPanel1;
this.ultraGridBagLayoutPanel1 = new Athia.Reports.ultraGridBagLayoutPanel1();
Doing this destroys Visual Studio every time, and to fix it requires using a text editor to put it back again. Therefore unless anyone can describe what is wrong with my implementation of this approach, perhaps calling the class the same as the control name isn't a great idea, I think the only safe and reliable way to achieve this is as Calanus describes in steps 1 to 5 or as an small deviation from that as Rob Windsor rightly points out restarting VS will bring the control into the Toolbox automatically. Unfortunately for me I then have to change all of the child controls over from the original class to my customised class :-(.
Within the same Solution this should work automatically. However, I have found that if the Target Framework aren't matching the Toolbox does not populate. ( I'm assuming really Reference needs to be of version same or lower than target of Reference. ) ( I did get a warning about non-matching Frameworks )
By making these the same Target Framework, Recompile, Restart VS. the control populated correctly. ( I also added the ToolboxItem(true) Attribute)
Calling all Visual Studio gurus — when I'm working on a .ascx or .aspx file in a c# web project, the events do not show up in the properties panel unless I switch into the design view from the code view. Is this an intentional functionality of Visual Studio? Both VS2005 and VS2008 seem to work this way.
And is there any way to get the events to show up in the properties panel all the time?
I don't know if that's the way VS is 'intended to work, but yes that's a limitation. In case you've noticed sometimes clicking on the control and pressing F4 (or clicking on the properties tab) fails to load the properties for the correct control, and then you gotta select it from the list.
Sigh
That apart, if you make a usercontrol of your own, and give it an event, that event will not show up in the properties tab when you put it on a page. You'll have to capture it manually in the Page_Init event (like demonstrated by fallen888).
These days I don't bother with going to the properties tab to see an event. You can just as well type the event's name in the mark-up and then write it in the code-behind file.
Yes, that's how Visual Studio is intended to work. This doesn't help you view them in properties panel, but you can get a list of events (among other things) by typing the following in the code-behind:
"this." and intellisense should show you a list.
What I typically do is override the OnInit method and put all event handler mappings in there. So that it looks something like this:
override protected void OnInit(EventArgs e)
{
this.Load += new System.EventHandler(this.Page_Load);
this.myButton.Click += new System.EventHandler(this.myButton_Click);
base.OnInit(e);
}
If you do it using intellisense, as soon you type in "+= " you'll have the option to auto-complete that line and the event handler method's signature as well.
Yep, I wish we had a similar level of event autocompletion that we get with WPF where you can see the event name in IntelliSense and get it to automatically create a new stub event for you in code behind :(