Word add-in: The add-in could not be started with displayDialogAsync - ms-word

I'm calling Office.context.ui.displayDialogAsync() in a word add-in. The dialog displays the message "ADD-IN ERROR The add-in could not be started. Please restart all Office applications and try again." But the displayDialogAsync() callback gives the succeeded status.
The page is a https URL with the same domain. (I'm testing on localhost.)
I can open the same URL with window.open() so I know the page exist.
Anyone knows what could be the reason for the error message, or how to get better diagnostics?

If you specified callback when calling the displayDialogAsync method, you may check result.error.code and result.error.message. As soon as you know what the actual error is, you can start troubleshooting, for example:
var dialog;
Office.context.ui.displayDialogAsync('https://myDomain/myDialog.html',
function (asyncResult) {
if (asyncResult.status === Office.AsyncResultStatus.Failed) {
showNotification(asyncResult.error.code = ": " + asyncResult.error.message);
} else {
dialog = asyncResult.value;
dialog.addEventHandler(Office.EventType.DialogMessageReceived, processMessage);
}
});
Check out the Handle errors and events in the Office dialog box for well-known errors.
Also you may find the Troubleshoot development errors with Office Add-ins page helpful.
Also make sure that the Protected mode is turned off in Windows.
In Windows 11, Protected Mode settings are missing in Internet Options, but you still can modify them via registry editor. These settings are stored in HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones. Under Zones is a subkey for each zone, named numerically:
0 is the Local Machine zone
1 is the Intranet zone
2 is the Trusted Sites zone
3 is the Internet zone
4 is the Restricted Sites zone
Under each numerically-named key, you can create or set a REG_DWORD value named 2500 to control whether Protected Mode is enabled for the zone. Setting that value to 0 enables Protected Mode; a setting of 3 disables it.
So, to disable Protected Mode for the Internet zone, set this entry to 3:
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\3\2500

Related

Wait until a symbol provider is available

I am writing a Go adapter extension for the Test Explorer extension for Visual Studio Code. My extension uses language services from Microsoft's Go extension:
const symbols = await vscode.commands.executeCommand('vscode.executeDocumentSymbolProvider', uri)
However, I have an issue. When I specify extensionDependencies and activationEvents correctly (in package.json), symbols don't initially load (the command returns undefined). If I set activationEvents to * or if I delay for long enough in my activate handler, symbols load. I thought about retrying until the command returns something, but "this file has no symbols" and "there is no symbol provider for this type of document" both return undefined.
Is there a way to delay until a symbol provider has been defined for a specific file extension/language? Waiting for the Go extension to be activated is not enough. I would use GoDocumentSymbolProvider directly, but the extension doesn't export anything.
It looks like it will be possible to add a delay time before your extension is activated. See https://github.com/microsoft/vscode/issues/98083 (Add support to eventually activate an extension on startup). And https://github.com/microsoft/vscode/issues/98990 (Delayed startup activation events).
Will be in v1.46. From v1.46 release notes onStartupFinished activation event:
We now have a new activation event, similar to the already existing *
activation event. The new onStartupFinished activation event should
be used when an extension wishes to be activated sometime soon after
VS Code startup, but not as part of the startup.
However, it is just a hard-coded delay, not based on other events but may still help your situation.
There is a new activation event which looks like e.g. onStartup:1000
or onStartup:5000. This means that the extension wants to be
activated 1000ms or 5000ms after startup. This is very similar to *
activation, but the extension indicates that it can wait a bit.

Why does my Outlook add in randomly stop working?

I have a plugin running in Outlook 2013 that is intended to filter out spam. It looks at incoming emails, runs through a half-dozen heuristics, and if 1 or 2 of them return positive, it moves the mail to another folder for inspection; if three or more are tripped, it permanently deletes the mail.
My problem is that it randomly stops working. The add in isn't marked as "disabled" or "inactive"; it just doesn't work anymore. Disabling it and then enabling it brings it back on line, and then it will work fine, including on the mail that it just failed on. And then it will fail randomly again a few messages later. No error is being raised as far as I can see; no exception is being thrown.
I feel like this has something to do with Outlook's limits for add-ins, since it is (a) non-deterministic and (b) seems to happen more often the more checks I do. But nothing I am doing is very heavy; most of it is just checking things in the email address, subject, and headers, or looking for key phrases in the body. Eyeballing it, every message appears to be processed in just a fraction of a second. I guess the first question is, is there a way to see Outlook's decision process on this, i.e. the specific perf statistics it is tracking? (ETA: Does Outlook enforce its restrictions when the add-in is invoked, or just at startup? Everything I can find only refers to startup.)
No single one of the checks seems to be responsible; I've disabled each one individually and it keeps happening.
Here's the central code. SpamMarkerCheckList is a list of delegates for the individual heuristic checks. ClearAllMailMarkers() does things like mark the mail as read, set the priority to normal, remove any flags, etc. headers is a Dictionary with the header names as the keys and lists of strings as the values.
private static void FilterInbox(object mailItem)
{
try
{
if (mailItem != null)
{
var mail = (Outlook.MailItem)mailItem;
var markers = SpamMarkersCount(mail, 3);
if (markers > 2)
{
PermanentlyDeleteEmail(mail);
}
else if (markers > 0)
{
ClearAllMailMarkers(mail);
mail.Move(_sequesteredFolder);
}
}
}
catch (Exception e)
{
MessageBox.Show("FilterSpam caught unexpected exception -- " + e);
}
}
private static int SpamMarkersCount(Outlook.MailItem mail, int threshold)
{
var spamMarkerCount = 0;
var headers = GetHeaderProperties(mail);
var emailAddressList = BuildAddressList(mail, headers);
var fullStringList = GetAllStrings(mail, headers);
foreach (var spamMarkerCheck in SpamMarkerCheckList)
{
if (spamMarkerCheck(mail, headers, emailAddressList, fullStringList))
{
spamMarkerCount++;
if (spamMarkerCount >= threshold)
{
return spamMarkerCount;
}
}
}
return spamMarkerCount;
}
The checks I am doing are:
Non-ASCII characters in the sender's name or address (e.g. hearts, shopping carts, etc.)
Indicators in the headers, like the presence of List-Unsubscribe or failed SPF, DKIM, or DMARC authentication
Email addresses that are badly formed or missing
If it was sent from a fake domain (via doing a DNS lookup)
The presence of the user's email alias in the subject or sender name ("delius1967 is a winner!")
If it was sent from a known blocked list of domains
If it contains specific phrases (e.g. "this is an advertisement")
I'd suggest checking the Windows event viewer for Outlook-specific records. Most probably your add-in fires an exception at runtime.
First and foremost, Microsoft Office applications can disable VSTO Add-ins that behave unexpectedly. If an application does not load your VSTO Add-in, the application might have hard disabled or soft disabled your VSTO Add-in.
Hard disabling can occur when a VSTO Add-in causes the application to close unexpectedly. It might also occur on your development computer if you stop the debugger while the Startup event handler in your VSTO Add-in is executing.
Soft disabling can occur when a VSTO Add-in produces an error that does not cause the application to unexpectedly close. For example, an application might soft disable a VSTO Add-in if it throws an unhandled exception while the Startup event handler is executing.
When you re-enable a soft-disabled VSTO Add-in, the application immediately attempts to load the VSTO Add-in. If the problem that initially caused the application to soft disable the VSTO Add-in has not been fixed, the application will soft disable the VSTO Add-in again. Read more about that in the How to: Re-enable a VSTO Add-in that has been disabled article.
Second, extending the add-in resiliency pillar of Outlook 2010, Outlook 2013 and later versions monitor add-in performance metrics such as add-in startup, shutdown, folder switch, item open, and invoke frequency. Outlook records the elapsed time in milliseconds for each performance monitoring metric.
For example, the startup metric measures the time required by each connected add-in during Outlook startup. Outlook then computes the median startup time over 5 successive iterations. If the median startup time exceeds 1000 milliseconds (1 second), then Outlook disables the add-in and displays a notification to the user that an add-in has been disabled. The user has the option of always enabling the add-in, in which case Outlook will not disable the add-in even if the add-in exceeds the 1000 millisecond performance threshold. Read more about that in the Performance criteria for keeping add-ins enabled section.
You may find the Outlook’s slow add-ins resiliency logic and how to always enable slow add-ins article helpful.
Finally, Outlook uses a single-threaded apartment model and may prevent any calls from secondary threads by throwing exceptions at runtime. You should use the OOM on the main thread only. If you need to do any processing on the background you may consider extracting the required plain data and passing it for processing. Extended MAPI allows running secondary threads also.
I found the proximate cause: garbage collection. After running in the debugger for quite a while, I noticed that the add-in stopped working immediately after a GC event; several more runs through show that this happens consistently.
The ultimate cause was in how I was associating the function with the folder:
private static Outlook.Account emailStore; // outside ThisAddIn_Startup
[...]
emailStore.DeliveryStore.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox).Items.ItemAdd += FilterInbox;
For reasons I do not fully understand, that causes a problem after GC, but this does not:
private static Outlook.Items emailItems; // outside ThisAddIn_Startup
[...]
emailItems = emailStore.DeliveryStore.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox).Items;
emailItems.ItemAdd += FilterInbox;
I get why having it as static is critical, but I don't understand why it makes a difference in the assignment. Anyone with a deeper understanding of C# objects who can explain, I would love to hear it.

EzPublish AcitivityTimeOut Setting

Good Day Guys,
I'm wondering if it's possible to set the ActivityTimeOut Setting for 30 days?
I actually tried putting it on 30 days... 2592000 secs = 30days..
however after several hours of inactivity EzPublish logout my account.
As per the eZ Publish documentation :
# Number of seconds before a session is considered inactive/logged out, 1 hour is standard
ActivityTimeout=3600
Looking at the kernel code, where this setting is used, it looks like that it does not have any effect on really disconnecting a user, it's just about considering a user as inactive (via the fetchLoggedInList function for instance) which is used in the Admin > Sessions section of the admin interface (if you're using sql stored session, which is not the default behavior in the last 4.x versions of eZ Publish).
Have you tried and checked these parameters ?
[Session]
# "Remember me" feature of the login.
# Number of seconds a session cookie will last,
# if an user wants to store current session to the cookie
# should click on "Remember me" checkbox on login page.
# Empty or 0 means this ability will be disabled and CookieTimeout will be used.
RememberMeTimeout=
# Number of seconds a session will last, 3 days is standard
SessionTimeout=259200
# Number of seconds a session cookie will last,
# 0 means until browser is closed
# Leaving the field empty means to use the default PHP settings (session.cookie_lifetime)
CookieTimeout=
As you can see, cookies are by default controller by your PHP server configuration, so you should have a look here too.

Get Mode in XMPP/Smack

My chat application has a procedure to set the presence/ mode status of the user i.e - Online, Offline, Invisible, Away etc. I am doing this using the following code :-
presence = new Presence(Presence.Type.available);
if (USER_STATE.equalsIgnoreCase("Online")) {
presence.setMode(Presence.Mode.available);
setUserPresence(0);
}else if (USER_STATE.equalsIgnoreCase("Invisible")) {
presence.setMode(Presence.Mode.xa);
setUserPresence(1);
} else if (USER_STATE.equalsIgnoreCase("Away")) {
presence.setMode(Presence.Mode.away);
setUserPresence(2);
} else if (USER_STATE.equalsIgnoreCase("Busy")) {
presence.setMode(Presence.Mode.dnd);
setUserPresence(3);
}
Here when I set the User Presence to Away or Invisible etc. and log out the user. Now when the user is logged in again I want to get the mode of the User that he had set earlier since his last logout. I am getting it as :-
System.out.println("Loggeddd innn");
// Set presence to online!
Presence userPresence = new Presence(Presence.Type.available);
userPresence.setStatus("Hello CCM!");
userPresence.setPriority(24);
userPresence.setMode(userPresence.getMode());
connection.sendPacket(userPresence);
Here I always get NULL in user.getMode() and also I always get Status as Available (shown in openfire portal)
Anybody please help ?
userPresence.setMode(userPresence.getMode()) seems like a no-op to me.
You should store the previous mode on the device itself (eg in SharedPreferences)

WMI and Win32_DeviceChangeEvent - Wrong event type returned?

I am trying to register to a "Device added/ Device removed" event using WMI. When I say device - I mean something in the lines of a Disk-On-Key or any other device that has files on it which I can access...
I am registering to the event, and the event is raised, but the EventType propery is different from the one I am expecting to see.
The documentation (MSDN) states : 1- config change, 2- Device added, 3-Device removed 4- Docking. For some reason I always get a value of 1.
Any ideas ?
Here's sample code :
public class WMIReceiveEvent
{
public WMIReceiveEvent()
{
try
{
WqlEventQuery query = new WqlEventQuery(
"SELECT * FROM Win32_DeviceChangeEvent");
ManagementEventWatcher watcher = new ManagementEventWatcher(query);
Console.WriteLine("Waiting for an event...");
watcher.EventArrived +=
new EventArrivedEventHandler(
HandleEvent);
// Start listening for events
watcher.Start();
// Do something while waiting for events
System.Threading.Thread.Sleep(10000);
// Stop listening for events
watcher.Stop();
return;
}
catch(ManagementException err)
{
MessageBox.Show("An error occurred while trying to receive an event: " + err.Message);
}
}
private void HandleEvent(object sender,
EventArrivedEventArgs e)
{
Console.WriteLine(e.NewEvent.GetPropertyValue["EventType"]);
}
public static void Main()
{
WMIReceiveEvent receiveEvent = new WMIReceiveEvent();
return;
}
}
Well, I couldn't find the code. Tried on my old RAC account, nothing. Nothing in my old backups. Go figure. But I tried to work out how I did it, and I think this is the correct sequence (I based a lot of it on this article):
Get all drive letters and cache
them.
Wait for the WM_DEVICECHANGE
message, and start a timer with a
timeout of 1 second (this is done to
avoid a lot of spurious
WM_DEVICECHANGE messages that start
as start as soon as you insert the
USB key/other device and only end
when the drive is "settled").
Compare the drive letters with the
old cache and detect the new ones.
Get device information for those.
I know there are other methods, but that proved to be the only one that would work consistently in different versions of windows, and we needed that as my client used the ActiveX control on a webpage that uploaded images from any kind of device you inserted (I think they produced some kind of printing kiosk).
Oh! Yup, I've been through that, but using the raw Windows API calls some time ago, while developing an ActiveX control that detected the insertion of any kind of media. I'll try to unearth the code from my backups and see if I can tell you how I solved it. I'll subscribe to the RSS just in case somebody gets there first.
Well,
u can try win32_logical disk class and bind it to the __Instancecreationevent.
You can easily get the required info
I tried this on my system and I eventually get the right code. It just takes a while. I get a dozen or so events, and one of them is the device connect code.