Trying to convert windows exe for chrome extension to dot net core 2 - google-chrome-extension

I have heard that Dot net core only generates dll file and the only way to run them is using the command
dotnet myapp.dll
I have a chrome extension and i am trying to do some operations . For example, on chrome extension i enter two numbers and then click send button. this triggers the native messaging and a windows executable/dll is called which takes these 2 numbers as stdin and returns the sum as stdout which would be displayed on chrome extension .
Earlier it was an exe file which was working fine. Now i have migrated the code to dotnet core 2.0 . My unit tests work fine but the dll is unable to execute . i dont see any logs as well . my best guess is that the dll is not getting called at all. somehow i have no idea how to check if the app is getting called from chrome extension
{
"name": "myapp",
"description": "myapp",
"path": "C:\\Program Files (x86)\\myapp.dll",
"type": "stdio",
"allowed_origins": [
"chrome-extension://lpfjfcebobk**************/"
]
}
UPDATE -1
I was able to solve this by creating a bat file which in turn calls the dll file by the following command
dotnet my_app.dll
Also my bat file looks like this
#echo off
:: Copyright (c) 2013 The Chromium Authors. All rights reserved.
:: Use of this source code is governed by a BSD-style license that can be
:: found in the LICENSE file.
dotnet "my_app.dll" %*
and my app_manifest looks like this
{
"name": "myapp",
"description": "myapp",
"path": "C:\\Program Files (x86)\\myapp.bat",
"type": "stdio",
"allowed_origins": [
"chrome-extension://lpfjfcebobk**************/"
]
}

Related

Not able to debug Azure Functions in Visual Studio Code. Debugger stops

I am using http trigger Azure Function. When I am running my application (by pressing F5), after clicking http://localhost:7071/api/HttpTrigger1, I am getting response in browser but code doesn't stop at breakpoints.
After careful observation, I saw that debugger starts for 0.5 seconds and closes automatically.
I have posted the video here. At 5th second, we can see that debugger starts but closes instantly (Orange screen at 5th second).
There is a similar question on Stackoverflow, but that didn't solve my problem.
I have experienced the same, while debugging Azure Functions in VS Code on a Mac. I found this open issue on the Omnisharp GitHub about this issue:
https://github.com/OmniSharp/omnisharp-vscode/issues/4903
In the end, basilfx's workaround ended up helping me:
I was triggered by a log line about code signing in the logging above. I therefore tried the following:
Create self-signed code signing certificate: https://stackoverflow.com/a/58363510/1423623
Navigate to the debugger folder (in my case, ~/.vscode/extensions/ms-dotnettools.csharp-1.24.4-darwin-x64/.debugger/x86_64)
Run codesign --remove-signature vsdbg-ui && codesign --remove-signature vsdbg
Run codesign -s my-codesign-cert vsdbg-ui && codesign -s my-codesign-cert vsdbg
I can now attach to a running instance of ./vsdbg-ui --server --consoleLogging --engineLogging from VS Code that stops at breakpoints. It's a work-around, but it shows something is wrong with the code signing of vsdbg and/or vsdbg-ui.
2022-04-20: can confirm that this still works, using OmniSharp 1.24.4.
Prerequisites to run/debug the Azure Functions in Visual Studio Code:
Azure Tools Extension
Azure Functions Core Tools
Also, Ensure that the Storage Emulator installed on your system, even it is deprecated but still used for local environment debugging and testing purposes
Azurite Extension on VS Code Extensions Menu
local.settings.json
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
"FUNCTIONS_WORKER_RUNTIME": "dotnet"
}
}
.csproj file:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<AzureFunctionsVersion>v4</AzureFunctionsVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="4.0.1" />
</ItemGroup>
<ItemGroup>
<None Update="host.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="local.settings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToPublishDirectory>Never</CopyToPublishDirectory>
</None>
</ItemGroup>
</Project>
Debug Result:
Put a breakpoint at some code line inside the Run Method and Start debugging.
All the code files and debugging video is available in the GitHub Repository and debugging video, please compare each file to your code.
As specified in this VS Code Official Documentation, need to install the language runtime extension for debugging purposes like C# for .NET, Python, Java, JavaScript, PowerShell etc.
For example, for the above .NET Azure Functions Project I have installed this extension in VS Code:
Links to Install these extensions are given in prerequisites and in hyperlink wording formats.
References of VS Code debugging the Azure Functions:
Debugging Azure Functions Locally in VS Code
Microsoft Official Documentation of Azure Functions debugging in VS Code
I have a similar issue.
I have multiple python azure function repositories which i work on in vs-code.
If a file open in the editor has errors (lint errors, mypy errors, etc..)
Whenever i try to launch a debug session the function starts but eventually detach from the debug session.
After this log print:
INFO: Detaching console logging.
Then it won't stop at breakpoints and log debug logs.
Unfortunately I don't have a solution yet.
I do have a working workaround you can try:
Close any open file which has an error (you can close all the files), and launch the debug session (f5), I found this way it's working, stopping at breakpoints and not detaching the debugger.
If you (or anyone) find a working solution please share.
In my case, I'm running on a mac. and this answer worked:
https://github.com/OmniSharp/omnisharp-vscode/issues/4900
Basically I changed my launch.json from:
{
"version": "0.2.0",
"configurations": [
{
"name": "Attach to .NET Functions",
"type": "coreclr",
"request": "attach",
"processId": "${command:azureFunctions.pickProcess}"
}
]
}
to this:
{
"version": "0.2.0",
"configurations": [
{
"name": "Attach to .NET Functions",
"type": "coreclr",
"request": "attach",
"processId": "${command:azureFunctions.pickProcess}",
"targetArchitecture": "x86_64"
}
]
}

An assembly specified in the application dependencies manifest was not found

So I have a .NET Core 2.2 web application.
I added the EPPlus library to it and now, when it is released to Azure (App Service) it won't start and I get the error:
HTTP Error 502.5 - ANCM Out-Of-Process Startup Failure
I narrowed this down by running a console in Azure and the command: "dotnet my.project.dll" - and got the actual error:
An assembly specified in the application dependencies manifest
(my.project.deps.json) was not found:
package: 'Microsoft.Win32.SystemEvents', version: '4.5.0'
path: 'runtimes/win/lib/netcoreapp2.0/Microsoft.Win32.SystemEvents.dll'
The Microsoft.Win32.SystemEvents.dll is present in the main wwwroot folder the application is deployed to.
But the whole runtimes/win/libs/ folder I don't think exists at all.
The my.project.deps.json files has the section which looks like this:
"Microsoft.Win32.SystemEvents/4.5.0": {
"dependencies": {
"Microsoft.NETCore.Platforms": "2.2.0"
},
"runtime": {
"lib/netstandard2.0/Microsoft.Win32.SystemEvents.dll": {
"assemblyVersion": "4.0.0.0",
"fileVersion": "4.6.26515.6"
}
},
"runtimeTargets": {
"runtimes/win/lib/netcoreapp2.0/Microsoft.Win32.SystemEvents.dll": {
"rid": "win",
"assetType": "runtime",
"assemblyVersion": "4.0.0.0",
"fileVersion": "4.6.26515.6"
}
}
}
If I delete the whole "runtimeTargets" section, then the application works! (Well, I have to do the same for a few more dll's too: System.Drawing.Common and System.Security.Cryptography.Pkcs)
But the file gets regenerated fully whenever it is published and released - so it is not a viable solution.
I also don't know what that section of the file does. It might be important to leave it in. Though it all works so it can't be that vital...
It is built and published through TeamCity - I'm not an expert on the process but I think the command being run amounts to this:
dotnet publish my.proj.csproj --configuration RELEASE --no-restore --no-build
Other things tried: < PublishWithAspNetCoreTargetManifest>false< / PublishWithAspNetCoreTargetManifest>
had no effect
Anyone have any ideas?
As it turns out, it was my fault :(
Team City was created a NuGet package from the published output. But the /runtimes folder was not included in the package so was never released as part of the site.
I edited the nuspec file to include it /runtimes and all works OK.
I've had same issue. After the build I copied all files to the "production" directory by DOS command copy so then the files from "runtimes" subfolder were missing. Copying all files including all subdirectories (by using xcopy) fixed the issue.

Input functionality is not working with python in Vscode

Description:
I'm using Vscode Studio for python coding, I've installed every extension related to python and I wanna use Jupyter. I'm experiencing no problem with importing packages or running code but when I try to grab the input from the user it throws me an error stating 'StdinNotImplementedError: raw_input was called, but this frontend does not support input requests.' which I don't find using the console.
[Image Error]
https://i.stack.imgur.com/BDUC5.jpg
Error
StdinNotImplementedError Traceback (most recent call last)
in
9 while 1:
10 #ask for new item
---> 11 new_item=input("> ")
12 #add new items to our list
13 shopping_list.append(new_item)
~\AppData\Local\Programs\Python\Python37-32\lib\site-packages\ipykernel\kernelbase.py in raw_input(self, prompt)
846 if not self._allow_stdin:
847 raise StdinNotImplementedError(
--> 848 "raw_input was called, but this frontend does not support input requests."
849 )
850 return self._input_request(str(prompt),
StdinNotImplementedError: raw_input was called, but this frontend does not support input requests.
Steps Taken:
Use the raw_input function instead of input.
Install and uninstall python and jupyter extension.
Checked the version of jupyter notebook --version (5.7.4) and python -m ipykernel --version (7.2.0).
Restarted kernel but encounter the same error.
Observation:
The issue is not replicable when the code is executed with python integrated terminal
Please let me know if there is setting which I'm missing or is this a bug.
Ctrl + Shift + D
Environment -> Python
This creates launch.json file within a .vscode directory in the current directory
Paste the following json:
{
"version": "0.2.0",
"configurations": [
{
"name": "Python",
"type": "python",
"request": "launch",
"stopOnEntry": true,
"pythonPath": "${config.python.pythonPath}",
"program": "${file}",
"debugOptions": [
"WaitOnAbnormalExit",
"WaitOnNormalExit",
"RedirectOutput"
],
"console": "integratedTerminal"
}
]}
Save the file and open python script in the editor
Start without debugging

php-ews folders do not match php-ews code at all

Installed php-ews using composer:
{
"minimum-stability": "dev",
"prefer-stable": true,
"require":
{
"php-ews/php-ews": "dev-master"
}
}
The installation passed fine.
Made this simple request in my project code:
require_once 'composer/vendor/autoload.php';
use \php-ews\php-ews\src\Client;
$host = 'my.server.co.il';
$username = 'user#server.co.il';
$password = 'myPass';
$version = Client::VERSION_2010;
$client = new Client($host, $username, $password, $version);
But the PHP doesn't accept hyphens (-) in its use command path,
I got the error:
PHP Parse error: syntax error, unexpected '-', expecting ',' or ';' in /var/www/html
Then I noticed, the paths of the use phrases in all the code files of the php-ews project, do not match the project files that where installed using the composer at all. For example, in the create.php file there are use phrases:
use \jamesiarmes\PhpEws\Client;
use \jamesiarmes\PhpEws\Request\CreateItemType;
use \jamesiarmes\PhpEws\ArrayType\NonEmptyArrayOfAllItemsType;
use \jamesiarmes\PhpEws\ArrayType\NonEmptyArrayOfAttendeesType;
use \jamesiarmes\PhpEws\Enumeration\BodyTypeType;
use \jamesiarmes\PhpEws\Enumeration\CalendarItemCreateOrDeleteOperationType;
use \jamesiarmes\PhpEws\Enumeration\ResponseClassType;
use \jamesiarmes\PhpEws\Enumeration\RoutingType;
The above paths do not even exist in the project at all....
The project files and folders that the composer installed, they do not match the code use and require phrases inside of them.
Did I make the wrong installation?
is there other way to use the composer.json file so I can install the project right, without hyphens (php-ews) in the directories?
php-ews Version installed:
"packages": [{
"name": "jamesiarmes/php-ntlm",
"version": "1.0.0-beta.1",
"extra": {
"branch-alias": {
"dev-master": "1.0.x-dev"
}
}
}]
Linux Centos 7
PHP version: 5.4.16
Microsoft Exchange version: 2010
installation seems correct.
require != use
use is a namespace, this on is defined in the Client.php, which is autoloaded.
client.php line 6:
namespace jamesiarmes\PhpEws;

Execute URL/Path in external program in Haxe

It is possible to run URL or path with external program from Haxe?
Something like a Process.Start("C:\") in C# will be opened drive C in file windows explorer (or Process.Start("/home/user/Desktop") will open Caja with this path in Linux Mint), or somethink like a package "Open" in NodeJS (it will do the same).
Or I need to open some text file with text editor, what selected in system by default.
Or when I try to run URL, then must be opened default web-browser with this address.
I think I can do this little code:
public static function execUrl (url:String) : Void {
switch (Sys.systemName()) {
case "Linux", "BSD": Sys.command("xdg-open", [url]);
case "Mac": Sys.command("open", [url]);
case "Windows": Sys.command("start", [url]);
default:
}
}
in unix-like systems can be used program "xdg-open". it know how to run needed path/url, and in windows this can do program "start"

Resources