Office.JS “This add-in is no longer available” error when creating a Word Document with context.application.createDocument() - ms-word

I'm developing an add-in for Microsoft Word 2016 using office js version 16.0.8626.1000. I use a web service to retrieve a document in base64 format and then I create a new Word instance with that.
The problem is that whenever I run the add-in from my server (not from visual studio debugger) it opens the document but the add-in frame displays an error
First Instance:
Second Instance:
This doesn't happen if I run the add-in from visual studio debugger, it opens the new instance without the frame.
This is my code
Office.initialize = function (reason) {
// Checks for the DOM to load using the jQuery ready function.
$(document).ready(function () {
$('#get').click(function () {
openWord();
});
});
}
This how I retrieve the document (without real url):
function openWord() {
getDocumentAsBase64(function (data) {
Word.run(function (context) {
var myNewDoc = context.application.createDocument(data);
context.load(myNewDoc);
return context.sync()
.then(function () {
myNewDoc.open();
context.sync();
})
.catch(function (myError) {
//otherwise we handle the exception here!
updateStatus(myError.message);
})
}).catch(function (myError) {
updateStatus(myError.message);
});
});
}
function getDocumentAsBase64(callback) {
$.ajax({
url: 'http://myurltomydocument.com/getFile',
data: "{}",
dataType: "json",
type: "POST",
contentType: "application/json; charset=utf-8",
success: function (response) {
callback(response.d);
},
error: function (response) {
updateStatus(response.d);
}
});
}
EDIT -- 8/12/2017
This is the manifest that I'm currently using if anyone wants to replicate the problem with Office 2016

I don't read Spanish, but the error mentions Visual Studio. I think Office is still trying to run a version that was sideloaded with Visual Studio and it's telling you that it can't do that. The problem might be the manifest. I notice that it still has the string ~remoteAppUrl in many places. When you are debugging with VS, this string is automatically replaced with the localhost URL, but you need to manually change all these to your web service's domain and sideload the new manifest when you are going to run it from the web service.
EDIT 12/11/17:
If that doesn't fix it, try clearing the Office cache. Details are at: Clear the Office cache
Edit 12/19/17:
Try this:
Go on File->Info->Check for Issues -> Inspect Document -> Inspect.
Then on Task Pane Add-ins click Remove All

Finally I found the solution to this problem.
First I downloaded Office 2016 Administrative Template Files.
When you run it, it will extract a bunch of files and folders.
Enter admx folder and copy the whole content to C:\Windows\PolicyDefinitions.
Do a gpupdate /force under CMD (or Powershell) as an administrator.
Run gpedit.msc and find the Administrative Template for Office 2016 then Updates (PC configuration >> Administrative Template >> Microsoft Office 2016 >> Updates >> Update Channel) and set the Update Channel to Montly Channel.
I'm on Version 1711 (compilation 8730.2127 click and run) and everything is working good now.
EDIT 9/1/2018:
The error started showing up again. The only thing I did was attaching the runtime logging to debug my add-in manifest. This is still unsolved.

Related

Getting an error while upgrading an MSI application

I'm getting below error while upgrading one software on my Windows 2003 server.
"Error 1260 : Windows cannot open this program because it has been prevented by a software restriction policy. For more information, open event viewer."
I searched lot on internet and one thing I got to know that, this error occurs because of one Windows's security update, KB2918614. I uninstalled that update & tried upgrade of my product, it worked fine for me.
But my question is, without uninstalling that update how I can make my upgrade of software successful ?
Here are some logs that I'm getting while failure :
MSI (s) (E4:24) [10:39:07:097]: SECREPAIR: Hash Database: C:\WINDOWS\Installer\SourceHash{97353D18-281D-42B5-8855-21E08089EFB8}
MSI (s) (E4:24) [10:39:07:128]: SECREPAIR: CryptAcquireContext succeeded
MSI (s) (E4:24) [10:39:07:878]: SECREPAIR: filename: **********.msi Stored Hash Value:+VE6k8PVr******************RjSWBjatbw= Current Hash:jhsyK1CivGh*************V2MlyUZsICUx83w=
MSI (s) (E4:24) [10:39:07:878]: SECREPAIR: UAC not supported and could not take approval from user
MSI (s) (E4:24) [10:39:07:878]: SECUREREPAIR: SecureRepair Failed. Error code: 4ec4E6A3388
Finally I got the answer !!
There is one more update Microsoft provided to get rid from current security update KB2918614. Here is the Microsoft article
In this article they have mentioned some registry changes. After doing those change my issue got resolved. Here are those registry changes :
Locate and then click the following subkey in the registry:
HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\Installer
On the Edit menu, point to New, and then click DWORD Value.
Type SecureRepairPolicy for the name of the DWORD, and then press Enter.
Right-click SecureRepairPolicy, and then click Modify.
In the Value data box, type 2, and then click OK.
Locate and then click the following subkey in the registry:
HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\Installer
On the Edit menu, point to New, and then click Key.
Type SecureRepairWhitelist for the name of the key, and then press Enter.
Double-click the SecureRepairWhitelist key to open it.
On the Edit menu, point to New, and then click String Value. Create String Values that contain the product codes (including braces {}) of the products that have to be added to the Safe Recipients list.

Is there any good grunt ftp plugin?

I've tried grunt-ftpush and grunt-ftp-deploy but both doesn't work properly. I experience annoyning bugs with them. FTP task seems very important and it's weird that I can't google working one.
UPDATED
Here is settings for grunt-ftp
ftp: {
options: {
host: 'myhostname',
user: 'myusername',
pass: 'mypassword'
},
upload: {
files: {
'codebase/myprojectfolder': 'build/*'
}
}
}
I expect that my local folder build will be copied to the server but I got an error
Fatal error: Unable to read "build/scripts" file (Error code: EISDIR).
Documentation is very poor, so I have no idea how to upload folders which has folders in it.
I tried many FTP plugins and, to my mind, only ftp_push was good enough for me. All other plugins lie on minimap which seemed buggy (when selecting which files to upload or not). Moreover, the idea to use a separate file to handle auth keys has no viable using : if we want to store FTP data in an external JSON file and put it inside our Gruntfile.js, it is not possible at all... The developer should choose by himself what to do with authentification and not rely on an external auth system.
Anyway, the project is alive and Robert-W has fix many issues really quickly : it's a major advantage too when we're developing. Projects that are quite dead are really painful.
https://github.com/Robert-W/grunt-ftp-push
I have been looking for a actual working way to pushing single files for quite a while, but I come down to using a shell script that makes the ftp call and run the script with grunt-exec (npm link). This seemed way simpler than getting any of the ftp plugins to work. This would work for any *nix system.
script.sh
ftp -niv ftp.host.com << EOF
user foo_user password
cd /path/to/destination
put thefilepush.txt
EOF
Gruntfile.js
exec: {
ftpupload: {
command: './script.sh'
}
}
Yes grunt-ftp and grunt-sftp-deploy worked well for me.
Try grunt-ftp
grunt.initConfig({
ftp: { // Task
options: { // Options
host: 'website.com',
user: 'johndoe',
pass: '1234'
},
upload: { // Target
files: { // Dictionary of files
'public_html': 'src/*' // remote destination : source
}
}
}
});
grunt.loadNpmTasks('grunt-ftp');
grunt.registerTask('default', ['ftp']);
After following old or misinformation I was finally to get grunt-ftps-deploy to work for uploading individual files to a remote server inside a docker. Here is the grunt task:
ftps_deploy: {
deploy: {
options: {
auth:{
host:'xx.xx.xx.xx',
authKey: 'key1',
port: 22,
secure: true
},
silent:false
//progress: true
},
files: [{
expand: true,
cwd: './',
src: ['./js/clubServices.js', './js/controllers.js', './css/services.css'],
dest: '/data/media/com_memberservices/',
}]
}
}
Initially I just received no files transferred response. The key to getting it working was specifying the "src" files correctly in an array. None of the information I found specifically addressed this issue. Hope this helps someone else. See update below
yoda57

console.log browser in android emulator

How to see console.log messages of a website using android emulator?
From Rich Chetwynd's short article "Javascript debugging on Android browser".
You can log javascript errors and console messages from your Android device or emulator. To do this you first need to install the Android SDK and USB drivers and enable USB debugging on the actual device.
To check if the device is connected correctly you can run the following cmd from your Android SDK tools directory and you should see a device in the list
c:\android sdk..\platform-tools\adb devices
You can then use the Android Debug Bridge to filter debug messages so that you only see browser related messages by running the following cmd.
c:\android sdk..\platform-tools\adb logcat browser:V *:S
By default the log is written to stdout so you will see any Javascript errors or console.log messages etc written to the cmd window.
Further details: Logcat CLI tool docs.
If you have started the emulator from Eclipse with the ADT plugin, you will see all JavaScript console logs directly under the LogCat view :
Window -> Show View -> Android -> LogCat
If you are using Android Studio; you can open your Logcat (Alt+6) and filter for: :CONSOLE
Filtering for only :CONSOLE (rather than INFO:CONSOLE) will display all types of console messages (including ERROR, WARN, etc).
You could add some JavaScript temporarily like...
var console = {
log: function(msg) { alert(msg); }
};
Ugly as hell, but it works.
I hijacked the console.log using this code:
function logManager() {
var self = this;
self.init = function () {
console.log('logmanager initialized');
var old = console.log;
self.logger = document.getElementById('log');
console.log = function (message, options) {
if (typeof message == 'object') {
self.logger.innerHTML = (JSON && JSON.stringify ? JSON.stringify(message) : message) + '<br />' + self.logger.innerHTML;
} else {
self.logger.innerHTML = message + '<br />' + self.logger.innerHTML;
}
}
}
self.toggleLogVisibility = function () {
return $(self.logger).toggle();
};
}
And consume it like so in your html with your own styling (absolute top right is what I used)
<div id="log" class="log">
Application loaded...
</div>
And in your jscript (run this on page loaded as the log element has to exist)
document.lmgr = new logManager();
document.lmgr.init();
Open this url on your chrome
chrome://inspect
Command - get log from the emulator
adb -e logcat
adb.exe can be found at $your_installation_path$\android sdk\platform-tools
more detailed
https://learn.microsoft.com/ru-ru/xamarin/android/deploy-test/debugging/android-debug-log?tabs=windows
If you cannot run adb logcat browser:V *:S because of zsh, you need to run noglob adb logcat browser:V *:S. Rationale: https://github.com/ohmyzsh/ohmyzsh/issues/2901

Why did SQL Server Management Studio 2008 command-line switches stop working?

I've always relied heavily on Windows shortcuts to SSMS that include command-line switches allowing me to quickly open up a specific database on a specific server. For example
Ssms.exe -S 123.123.123.123 -U sa -P goodpassword -d DbName
or
Ssms.exe -S . -E -d DbName
These suddenly stopped working. I get this error from SSMS:
Failed to create new SQL Server script.
Object reference not set to an instance of an object. (AppIDPackage)
Program Location: at Microsoft.SqlServer.Management.UI.VSIntegration.
AppIDPackage.AppIDPackage.OpenConnectionDialogWithGlobalConnectionInfo()
I can still launch SSMS without the command-line switches, and then manually establish the connections. Some command-line switches still work, for example
ssms.exe -nosplash
works fine.
I get the same error with any combination of the -S, -E, and -d command-line switches. It doesn't matter if I'm pointing to a valid server or database or not, or if my login credentials are good or not. I can point to the older version of SSMS and it works fine, but not the 2008 version.
This post on MSDN's forums is all I've found online, but MS hasn't been very helpful on this thread.
Any ideas how I might start to fix this? I work with a lot of different databases on different servers, and I really rely on these shortcuts.
I've thrown the DLL in question at reflector and it's given me back the code at the bottom of this post, sadly there's nothing immediately obvious in the code that makes it easy to work out why it's stopped working for you (wouldn't it be nice if Microsoft shipped debug symbols with anything they produce that's written against the CLR?).
There are a couple of places where the code makes me wonder if you might have a corrupted "recently used servers" list or something similar, perhaps you could try following the steps listed in this question to clear them out and see if that helps.
private void OpenConnectionDialogWithGlobalConnectionInfo()
{
if ((ServiceCache.GlobalConnectionInfo != null) && (ServiceCache.GlobalConnectionInfo.Count != 0))
{
try
{
using (ConnectionDialog dialog = new ShellConnectionDialog())
{
IDbConnection connection;
dialog.ImportRegisteredServersOnFirstLaunch = true;
dialog.AddServer(new SqlServerType());
UIConnectionInfo connectInfo = ServiceCache.GlobalConnectionInfo[0].Copy();
if (dialog.TryToConnect(this.PopupOwner, ref connectInfo, out connection) == DialogResult.OK)
{
this.ScriptFactory.CreateNewBlankScript(ScriptType.Sql, connectInfo, connection);
}
}
}
catch (Exception exception)
{
ExceptionMessageBox box = new ExceptionMessageBox(new ApplicationException(SRError.FailedToCreateNewSqlScript, exception));
box.Caption = SRError.MessageBoxCaption;
box.Show(this.PopupOwner);
}
}
ServiceCache.GlobalConnectionInfo = null;
}
The ObjectExplorer window must be open. Don't hide.
I solved my problem this way :)
Works fine like this:
sqlwb.exe -S . -E -d dbName
I'm using SSMS2008 against a SQL2005 database, and the ssms command line works fine here.
This is the version info produced by the SSMS About dialog:
Microsoft SQL Server Management Studio 10.0.1600.22 ((SQL_PreRelease).080709-1414 )
Microsoft Data Access Components (MDAC) 6.0.6001.18000 (longhorn_rtm.080118-1840)
Microsoft MSXML 2.6 3.0 5.0 6.0
Microsoft Internet Explorer 8.0.6001.18813
Microsoft .NET Framework 2.0.50727.3074
Operating System 6.0.6001
There are several sources (MSSqlTips, and here) that state the command line arguments are available on sqlwb.exe. Yet the Books Online page for ssms states that the options are available on ssms.

Firebird custom installation

I want to deploy a firebird installation, and thus will launch it from my installer using command-line parameters. I read Inno Setup's documentation but still can't get it to work.
I just want to install a "Super server" with no documentation or whatsoever.
Here's what I have so far
Firebird-2.1.2.18118_0_Win32.exe /sp- /silent /SUPPRESSMSGBOXES /nocancel /noicons /components="Super Server binary"
But it won't install the server. If I remove the /components it does install the server but install other developer stuff, which customers don't need.
read installation_scripted.txt in C:\Program Files\Firebird\Firebird_2_1\doc
/COMPONENTS="comma separated list of
component names"
Choose from -
ServerComponent\SuperServerComponent,
ServerComponent\ClassicServerComponent,
ServerComponent,
DevAdminComponent and
ClientComponent
Overrides the default components
settings. Using this command line
parameter causes Setup to
automatically select a custom type. A
full install requires combining
components. For example:
/COMPONENTS="ServerComponent\SuperServerComponent,ServerComponent,DevAdminComponent,ClientComponent"
would be required for a full
install.
I use the following and it works fine, however I need to install to a custom directory and also change the server option
string installerFilePath = #"C:\BennaOlivier\Randoms\Delter\Firebird\FirebirdMainInstaller\MainInstaller\MainInstaller\Firebird X64\FirebirdInstallX64\Firebird-2.5x64.exe";
Process installerProcess = new Process();
installerProcess = Process.Start(installerFilePath, Arguments);
while (installerProcess.HasExited == false)
{
//indicate progress to user
Application.DoEvents();
System.Threading.Thread.Sleep(250);
}
}
catch (Exception FBX64)
{
MessageBox.Show(FBX64.Message);
throw;
}public const string comps = #"ServerComponent\ClassicServerComponent,ServerComponent,ClientComponent";
public const string Arguments = "/VERYSILENT /SUPPRESSMSGBOXES";