TS2339: Property 'application' does not exist on type 'RequestContext' MS word addin - ms-word

This is driving me mad - i am developing what i thought was a simple addin for MS word using React and office JS.
I am loading https://appsforoffice.microsoft.com/lib/beta/hosted/office.js in my app, I have a working manifest and can sideload the app which renders as expected, until i try to create my word interactivity. I have fallen on the first hurdle, i need my addin to get a docx document, and then load - which should be possible using createDocument(base64) then load.
my problem is that:
Word.run(async context => {
var MyDoc = context.application.createDocument(getMyDocument());
context.load(MyDoc);
})
.catch(function (error) {
console.log('Error: ' + JSON.stringify(error));
if (error instanceof OfficeExtension.Error) {
console.log('Debug info: ' + JSON.stringify(error.debugInfo));
}
});
fails to compile with the error TS2339: Property 'application' does not exist on type 'RequestContext'.
however I can refer to context.document which will compile and add in paragraphs of text. I do not know where im going wrong at all.
Office version is Mac 2016 16.2 (181125) so should easily accept Word 1.3 API which has the functionality.
Googling has given no meaningful results which suggests its something i have missed rather than a common mistake.
Any help would be greatly appreciated.

I have finally resolved this issue, it is down to the react library #types/office-js being out of date. The add-in was created using yeoman generator, and the #types/office-js had a version of 0.051^. I changed the package in packages.json and ran npm install to update to the latest (0.0170 at time of writing), which includes the contexts to work with the later versions of the word API, including createDocument and this worked.

Related

TYPO3 throws Error after Updating to 11.5.16 and PHP 8.1 (get_class_methods(): Argument #1

After Updating from TYPO3 9.5.x LTS and PHP 7.4 to TYPO3 11.5.16 and PHP 8.1 I am getting this error:
get_class_methods(): Argument #1 ($object_or_class) must be an object or a valid class name, string given
I know it's about my Extension (when I disable it the Error disappears), but the further debug Information I are not helping me:
in /html/typo3/typo3_src-11.5.16/typo3/sysext/extbase/Classes/Mvc/ExtbaseRequestParameters.php line 302
// todo: this is nonsense! We can detect a non existing method in
// todo: \TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin, if necessary.
// todo: At this point, we want to have a getter for a fixed value.
$actionMethodName = $this->controllerActionName . 'Action';
$classMethods = get_class_methods($controllerObjectName);
if (is_array($classMethods)) {
foreach ($classMethods as $existingMethodName) {
if (strtolower($existingMethodName) === strtolower($actionMethodName)) {
$this->controllerActionName = substr($existingMethodName, 0, -6);
I couldn't find anything searching github, stackoverflow or the web. Anyone else had the same problem or knows where this could come from?
Right after this Post, it came to my Mind to change the PHP Version back to 7.4. With PHP 7.4 I've got a different Error Message ("Class does not exist. Reflection failed.") which leads me to:
https://forge.typo3.org/issues/91239
I made the Mistake to Register Plugin With VendorName. Just in case anyone else does it the same way, I've written this answer and would like to keep this Post.

Error handling in extensions to visual studio code

Can someone point me to best practices for error handling in a Visual Studio Code extension?
I'm writing an extension in TypeScript that contributes a debugger. I want to log unexpected behavior, sometimes as information to the user explaining that something didn't go right, sometimes to create a trail for debugging, but certainly not to fail silently. Using console.log or console.error shows up in the debug output when I am debugging the extension, but I can't find it when the extension is installed. Do I have to open an output channel specifically for my extension and write everything there? Should I be throwing up showInformationMessage and showErrorMessage windows? Should I just be throwing exceptions and hope that code will do the right thing?
In my extension I use two ways for feedback. One is an output channel for errors produced by an external process that I'm using for the work.
Create the channel in your activation method:
outputChannel = window.createOutputChannel("ANTLR4 Errors");
and push output to it whenever you have something:
} catch (reason) {
outputChannel.appendLine("Cannot parse sentence generation config file:");
outputChannel.appendLine((reason as SyntaxError).message);
outputChannel.show(true);
return;
}
The other one is what you already considered:
if (workspace.getConfiguration("antlr4.generation").mode === "none") {
void window.showErrorMessage("Interpreter data generation is disabled in the preferences (see " +
"'antlr4.generation'). Set this at least to 'internal' to enable debugging.");
return null;
}
which is for messages I create in the extension and that users need to see and take seriously.

Using the Plantronics SDK with a Delphi application

and thank you in advance for any advice / insight / assistance that can be provided.
The Background:
We have a soft phone application that is written in Delphi (XE3) for Windows. The ability to answer an incoming call by activating the answer button an a Plantronics Wireless Headset was recently requested. The MSI files were downloaded and executed, and the Plantronics SDK was converted / altered into a Delphi Library File.
I then started to follow the "First Steps" section of the Plantronics Website. I knew that the "First Steps" code would have to be tweaked to fit the Delphi system.
The Problem:
In adjusting the code to work within Delphi, a few translation problems were encountered and resolved. One such error is proving to be stubborn - When an instance of one specific class is created, the error "Class not registered" is thrown.
"First Steps" code for reference -
// Connect to the Plantronics COM API:
myAppName = "SDK .NET COM sample";
sessionManager = new COMSessionManager();
sessionManager.Register(myAppName, out session);
// Hook to SessionManager events:
sessionManagerEvents = sessionManager as ICOMSessionManagerEvents_Event;
if (sessionManagerEvents != null)
{
sessionManagerEvents.onCallStateChanged += SessionManagerEvents_onCallStateChanged;
sessionManagerEvents.onDeviceStateChanged += SessionManagerEvents_onDeviceStateChanged;
}
Delphi Code:
//Connect to the Plantronics COM API:
plugin_name: "Plugin Name";
the_session: CoCOMSession.Create;
session_manager = new COMSessionManager.Create;
session_manager.Register(plugin_name, the_session);
//Hook to Session Manager Events
state_device_event_args := CoCOMStateDeviceEventArgs.Create;
call_event_args := CoCOMCallEventArgs.Create;
The final line of Delphi Code is the issue. The other three "Create" calls go off without a hitch. The line "call_event_args := CoCOMCallEventArgs.Create;" throws the error "Class not registered", even through it is declared and implemented in the library file along with the other three.
Excerpts from the library file:
Class Declarations:
IID_ICOMStateDeviceEventArgs: TGUID = '{91542BEE-4931-4620-9E96-23AE4001E93F}';
CLASS_COMStateDeviceEventArgs: TGUID = '{335D08FD-8BB5-4EF5-964B-E8A8C010530F}';
IID_ICOMCallEventArgs: TGUID = '{0280956C-C644-4CD8-B124-C8A99E5D505E}';
CLASS_COMCallEventArgs: TGUID = '{705129C3-2265-4F10-9768-0FF8A20234C0}';
Class creation functions:
//Works
class function CoCOMStateDeviceEventArgs.Create: ICOMStateDeviceEventArgs;
begin
Result := CreateComObject(CLASS_COMStateDeviceEventArgs) as ICOMStateDeviceEventArgs;
end;
// Doesn't Work
class function CoCOMCallEventArgs.Create: ICOMCallEventArgs;
begin
Result := CreateComObject(CLASS_COMCallEventArgs) as ICOMCallEventArgs;
end;
Every tutorial / forum answer about resolving the "Class Not Registered" error that I have found has not resolved the issue.
Does anyone have any advice or insight as to what I have been doing wrong?
Thank you.
The issue has been (potentially) resolved by the following -
I had mistakenly thought from the tutorial / first steps section that a "COMCallEventArgs" object needed to be created before it could be used.
Upon further review, the COMCallEventArgs object gets created when necessary at a later point.
More testing needs to be done, but I believe this issue is resolved.

Where are the docs on how to add symbol support for a language to Visual Studio Code?

I would like to add symbol support for PowerShell to VS Code but I'm not finding any docs on the code.visualstudio.com/docs site.
Also, is it possible to do this for a language like PowerShell that, for the moment, will only work on Windows? Is there a way to light up symbol support on Windows only?
BTW I've added a bunch of PowerShell snippets that I'm in the process of trying to get integrated into VS Code. Any help on how to get these snippets into the product would be appreciated as well? I did submit an issue on the snippets, suggesting that the team put these into VS Code.
There is currently no documentation for the plugin API. It's too early for this as the API is still changing with every minor release. The VSCode team is focused on providing a stable plugin API. There will be a documentation about it when it's done.
Nevertheless it is already possible to add a new language plugin or extending an exisiting one. Take a look on this short description on how to add declaration support for a new language: Create Custom Language in Visual Studio Code
You could add symbol support in a similar way. What you need is something like an abstract syntax tree builder for powershell scripts and an application or a javascript module that is able to process a JSON request in order to provide the correct symbols. An example request for outline support is this:
{
"seq":442,
"type":"request",
"command":"navbar",
"arguments":
{
"file":"c:/Users/C/Documents/projects/MyProject/MyFile.xxx"
}
}
A response could look like that:
{
"seq":442,
"type":"response",
"command":"navbar",
"request_seq":442,
"success":true,
"body":[
{
"text":"TObjA",
"kind":"class",
"kindModifiers":"",
"spans":[
{
"start":{
"line":10,
"offset":3
},
"end":{
"line":16,
"offset":4
}
}
],
"childItems":[
]
},
{
"text":"DoSomething",
"kind":"method",
"kindModifiers":"",
"spans":[
{
"start":{
"line":20,
"offset":1
},
"end":{
"line":27,
"offset":4
}
}
],
"childItems":[
]
},
]
}
I'm not sure what do you mean with "symbol support". Is it something like "jump to symbol inside the current file" using CTRL+Shift+O? Then you are looking for outlineSupport.
Is it something like "find a symbol in any file" using CTRL+P, #? Then you are looking for navigateTypesSupport.
Copy the needed .js file from the vs.langauage.csharp.o folder to the vs.langauage.powershell folder and register the support in powershellMain.js as it is done in omnisharpMain.js.
If you want to register the new support only on Windows then you can do it like this:
var isWin = /^win/.test(process.platform);
if(isWin)
monaco.Modes.NavigateTypesSupport.register('powershell', new navigateTypesSupport_1.default(ModelService, server));
I hope this helps for the moment. Don't forget to save your changed plugins in a different folder. VSCode often deletes changes in the plugin folders on update.

Zend_validate isValid() get stuck fatalError Maximum execution time of 30 seconds exceeded in /library/Zend/Validate/Hostname.php on line 608

Iam suffering from Zend_validate ,when ever I write a form and try to add validators , the only thing that works for me if I submit the form with no values , it will show error msg , but if I submit good values it will stuck for sometime and then give fatal error msg saying Maximum execution time 30 seconds is exceeded in /Applications/MAMP/htdocs/MyApplicationFolderName/library/Zend/Validate/Hostname.php on line 608
Please help my controller action code is
public function createAction()
{
// action body
$roleService=new User_Service_RoleService($this->em);
$userForm=new User_Form_UserForm($roleService->listAllRoleNames());
$userForm->startForm();
$userForm->setAction('create');
$userForm->setMethod('post');
if($this->getRequest()->isPost() )
{
if($userForm->isValid($this->getRequest()->getPost()))
{
$this->userAccountService->createUser($this->getRequest()->getParams());
$this->_forward('confirm');
}
}
$this->view->form=$userForm;
}
and my form class code is
class User_Form_UserForm extends Zend_Form {
//put your code here
private $roles;
public function __construct($options = null) {
parent::__construct($options);
$this->roles=$options;
}
public function startForm()
{
$idForm=new Zend_Form_Element_Hidden('id');
$this->addElement($idForm);
///////////
$userEmailForm=new Zend_Form_Element_Text('email');
$userEmailForm->setRequired(TRUE);
$userEmailForm->setLabel('Email');
$emailValidator=new Zend_Validate_EmailAddress();
// $emailValidator->setOptions(array('domain' => FALSE));
$userEmailForm->addValidator($emailValidator,false);
$userEmailForm->setAttrib('size', 25);
$userEmailForm->setFilters(array(new Zend_Filter_StringToLower(),
new Zend_Filter_StringTrim())
);
$this->addElement($userEmailForm);
}
}
This is small part of my form its so simple but not working Iam using MAMP PHP 5.3.5 because of Doctrine2 and name spaces
Please any help will be really appreciated .
Note I also tried other validators like string length and the same error showed.
"I actually just found the answer to this one:
The version of PHP 5.3 that ships with MAMP has a bug in
iconv_strlen() that causes a "do { ... } while (false);" loop in the
validator to run infinitely. I just switched my PHP version to 5.2, as
it's closer to production anyway, and it works. If you need the 5.3,
though, you will have to upgrade your PHP installation in MAMP. I
haven't tried it, but the following link was highly recommended:
http://www.davidgolding.net/cakephp/upgrading-php-in-mamp.html
Hope that all helps."
Source: http://forum.mamp.info/viewtopic.php?f=2&t=12189
I worked out the problem by not using mamp , and start using Zendserver CE free Edition http://www.zend.com/en/products/server-ce/downloads
, and by going through the steps described on this link http://www.witheringtree.com/2011/07/installing-zend-server-ce-on-os-x-a-guide-for-the-terminal-timid/
I could edit my root document for zend server to USERS/sites/
I run Zendframework validation and it worked nicely , I like mamp but I develope on Zend and zend use iconv_strlen() ,
the other way to solve this issue is by installing PHP but I found that not an easy solution , or you can use macports and I didnot want to go that way, since Iam using zendframework I needed something related to it so I used zendServer which is so far the cleanest solution .