-
Hi! As usual I mapped all functions that i need from dll as edge.function as below: My code: import edge from 'electron-edge-js';
import path from 'path';
declare const __static: string;
const dllA6 = path.join(process.env.NODE_ENV === 'production' ? __dirname : __static, '../src/dll/CuDoubleSidedScannerAPIWrap.dll');
export class ScannerA6 {
Init = () => edge.func<string, string[]>(`
#r "${dllA6}"
using Custom.CuDoubleSidedScannerAPIWrap;
using Custom.CuDoubleSidedScannerAPIWrap.ScannerEvent;
async (input) => {
CuDoubleSidedScannerAPI cScannerLibrary = new CuDoubleSidedScannerAPI();
return cScannerLibrary.EnumScanner();
}
`);
Status = () => edge.func<string, object>(`
#r "${dllA6}"
using Custom.CuDoubleSidedScannerAPIWrap;
using Custom.CuDoubleSidedScannerAPIWrap.ScannerEvent;
async (input) => {
CuDoubleSidedScannerAPI cScannerLibrary = new CuDoubleSidedScannerAPI();
CuScanner scanner = cScannerLibrary.ConnectScanner(input.ToString());
return scanner.GetStatus();
}
`);
} The first time that i run the application i can call Init but when i try to call Status or Init again the c# code throws the following exception: From scanner docs
I tried to decompile it but the code it looks like obfuscated and i cannot know the real reason. Is there a way to reset completely the edge env or a similar thing in order to avoid that exception and every call is like the first? Thanks! PS: thanks @agracio because i already use your project for a similar integration it works very well! |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 7 replies
-
@agracio maybe using |
Beta Was this translation helpful? Give feedback.
-
This looks like an error coming from your application and not from Edge.js, have you tried using this code in c# console app to see if it works in this way? |
Beta Was this translation helpful? Give feedback.
-
The best advise I can give you is to clone https://github.com/agracio/edge-js-quick-start and then add your code as C# methods rather than inline. This should either resolve your problem or point you to the right place in C# code where the error occurs. Inline code does not offer much insight into what is happening in C#. |
Beta Was this translation helpful? Give feedback.
In pure C# class you can create
new CuDoubleSidedScannerAPI()
once and then use it in all of your methods, so as I said clone https://github.com/agracio/edge-js-quick-start and create a proper C# class where you instantiateCuDoubleSidedScannerAPI
once and all the methods use that instance. Quick start provides great example on how to use compiled C# dlls rather than inline C#.Something like this