Closed 3goats closed 3 months ago
This message is telling you that you're trying to load a 64-bit DLL in a 32-bit process or vice versa, you probably need to build edge.js from source and force it to the same arch as node-webkit
Hmm - yes I thought it might be something like this. Since node-webkit is 32bit only, I edited the edge.js file to this.
- edge = require('./native/' + process.platform + '/' + process.arch + '/' + determineVersion() + '/edge');
+ edge = require('./native/' + process.platform + '/' + 'ia32' + '/' + determineVersion() + '/edge');
This is what I got:
Uncaught Error: %1 is not a valid Win32 application.
C:\AppJs\data\node_modules\edge\lib\native\win32\ia32\0.10.0\edge.node
I then tried
- edge = require('./native/' + process.platform + '/' + process.arch + '/' + determineVersion() + '/edge');
+ edge = require('./native/' + process.platform + '/' + 'x64' + '/' + determineVersion() + '/edge');
and got this:
Uncaught Error: %1 is not a valid Win32 application.
C:\AppJs\data\node_modules\edge\lib\native\win32\x64\0.10.0\edge.node
Hm, perhaps one of the DLLs required by edge.js is the wrong arch (i.e. node-webkit -> edge.dll -> [SOMETHING 64-BIT])?
Hmm - Yeah I'm at a bit of loss as what to do next now - especially that it works OK outside of node-webkit!
@carlskii I would run Process Monitor and see what the last DLL to load is before things go pear-shaped
Yeah - I just tried that, but it doesn't really show anything since the DLL is not getting loaded.
Which version and architecture of node.exe are you using?
Also, could you give me the smallest possible self-contained repro code?
Here's the version information for node which is obviously included within the node-webkit runtime:
Node Version: v0.10.5
Platform: win32 Architecture: ia32
Here's a basic example of my code:
<!doctype html>
<html>
<script>
function myFunction1()
{
console.log('Node Version: ' + process.version);
console.log('Platform: ' + process.platform + ' Architecture: ' + process.arch);
var fs = require('fs');
console.log(fs.readdirSync('.'))
}
function myFunction2()
{
console.log('Node Version: ' + process.version);
console.log('Platform: ' + process.platform + ' Architecture: ' + process.arch);
var edge = require('edge')
var helloWorld = edge.func('async (input) => { return ".NET Welcomes " + input.ToString(); }');
helloWorld('JavaScript', function (error, result) {
if (error) throw error;
console.log(result);
});
}
</script>
<head>
<title>Hello World!</title>
</head>
<body>
<h1>Hello World!</h1>
<button onclick="myFunction1()">List Dir</button>
<button onclick="myFunction2()">Edge - Hello</button>
</body>
</html>
If you open this from the node-webkit runtime and open the developer/debug panel you can see whats happening.
I've been doing some more reading. I wonder if this is the problem:
"Native modules should be built by nw-gyp rather than node-gyp, which npm uses by default. For more information, see Build native modules with nw gyp"
Taken from the node-webkit docs.
https://github.com/rogerwang/node-webkit/wiki/How-to-use-3rd-party-node.js-modules-in-node-webkit
OK so I recompiled edge using nw-gyp and it seemed to work OK I then 'required' the new edge.node file and tested again.
This time I get this error which is what I was seeing in AppJS!!!
Uncaught TypeError: Object [object Object] has no method 'func'
Hmm..Going round in circles here a bit despite trying various things for most of the day!
Can you confirm what the dependencies are to compile edge from the source code?
I have the Windows 7 SDK installed and Visual Studio 12. If I run the buildall.bat file from the tools directory it seems to compile OK, with the exception of some dialogue boxes that popup saying:
"c:\edge-master\lib\native\win32\ia32\0.6.20\node.exe is not a valid Win32 application"
"c:\edge-master\lib\native\win32\ia32\0.8.22\node.exe is not a valid Win32 application"
"c:\edge-master\lib\native\win32\ia32\0.10.0\node.exe is not a valid Win32 application"
C:\edge-master\tools>buildall.bat
Building edge.node release for node.js x86 v0.6.20
Access is denied.
Error building edge.node release for node.js x86 v0.6.20
Building edge.node release for node.js x86 v0.8.22
Access is denied.
Error building edge.node release for node.js x86 v0.8.22
Building edge.node release for node.js x86 v0.10.0
Access is denied.
Error building edge.node release for node.js x86 v0.10.0
Building edge.node release for node.js x64 v0.6.20
gyp info it worked if it ends with ok
gyp info using node-gyp@0.9.6
gyp info using node@0.6.20 | win32 | x64
gyp info spawn python
gyp info spawn args [ 'C:\\Users\\Carl Bourne\\AppData\\Roaming\\npm\\node_modul
es\\node-gyp\\gyp\\gyp',
gyp info spawn args 'binding.gyp',
gyp info spawn args '-f',
gyp info spawn args 'msvs',
gyp info spawn args '-G',
gyp info spawn args 'msvs_version=2012',
gyp info spawn args '-I',
gyp info spawn args 'C:\\edge-master\\build\\config.gypi',
gyp info spawn args '-I',
gyp info spawn args 'C:\\Users\\Carl Bourne\\AppData\\Roaming\\npm\\node_modul
es\\node-gyp\\addon.gypi',
gyp info spawn args '-I',
gyp info spawn args 'C:\\Users\\Carl Bourne\\.node-gyp\\0.6.20\\common.gypi',
gyp info spawn args '-Dlibrary=shared_library',
gyp info spawn args '-Dvisibility=default',
gyp info spawn args '-Dnode_root_dir=C:\\Users\\Carl Bourne\\.node-gyp\\0.6.20
',
gyp info spawn args '-Dmodule_root_dir=C:\\edge-master',
gyp info spawn args '--depth=.',
gyp info spawn args '--generator-output',
gyp info spawn args 'C:\\edge-master\\build',
gyp info spawn args '-Goutput_dir=.' ]
Warning: while converting VCCLCompilerTool/BasicRuntimeChecks to MSBuild, index
value (-1) not in expected range [0, 4)
Warning: while converting VCCLCompilerTool/RuntimeLibrary to MSBuild, index valu
e (-1) not in expected range [0, 4)
Warning: while converting VCCLCompilerTool/RuntimeTypeInfo to MSBuild, expected
bool; got '-1'
Warning: while converting VCCLCompilerTool/RuntimeLibrary to MSBuild, index valu
e (-1) not in expected range [0, 4)
Warning: while converting VCCLCompilerTool/RuntimeTypeInfo to MSBuild, expected
bool; got '-1'
Warning: while converting VCCLCompilerTool/BasicRuntimeChecks to MSBuild, index
value (-1) not in expected range [0, 4)
Building the projects in this solution one at a time. To enable parallel build,
please add the "/m" switch.
gyp info spawn C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe
gyp info spawn args [ 'build/binding.sln',
gyp info spawn args '/clp:Verbosity=minimal',
gyp info spawn args '/nologo',
gyp info spawn args '/p:Configuration=Release;Platform=x64' ]
clrfuncreflectionwrap.cpp
edge.cpp
nodejsfunc.cpp
nodejsfuncinvokecontext.cpp
clrfunc.cpp
persistentdisposecontext.cpp
utils.cpp
clractioncontext.cpp
v8synchronizationcontext.cpp
clrfuncinvokecontext.cpp
Generating Code...
Creating library C:\edge-master\build\Release\edge.lib and object C:\edge-
master\build\Release\edge.exp
LINK : /LTCG specified but no code generation required; remove /LTCG from the
link command line to improve linker performance
edge.vcxproj -> C:\edge-master\build\Release\\edge.node
gyp info ok
C:\edge-master\tools\\..\lib\native\win32\x64\0.6.20
1 file(s) copied.
1 file(s) copied.
Success building edge.node release for node.js x64 v0.6.20
Building edge.node release for node.js x64 v0.8.22
gyp info it worked if it ends with ok
gyp info using node-gyp@0.9.6
gyp info using node@0.8.22 | win32 | x64
gyp info spawn python
gyp info spawn args [ 'C:\\Users\\Carl Bourne\\AppData\\Roaming\\npm\\node_modul
es\\node-gyp\\gyp\\gyp',
gyp info spawn args 'binding.gyp',
gyp info spawn args '-f',
gyp info spawn args 'msvs',
gyp info spawn args '-G',
gyp info spawn args 'msvs_version=2012',
gyp info spawn args '-I',
gyp info spawn args 'C:\\edge-master\\build\\config.gypi',
gyp info spawn args '-I',
gyp info spawn args 'C:\\Users\\Carl Bourne\\AppData\\Roaming\\npm\\node_modul
es\\node-gyp\\addon.gypi',
gyp info spawn args '-I',
gyp info spawn args 'C:\\Users\\Carl Bourne\\.node-gyp\\0.8.22\\common.gypi',
gyp info spawn args '-Dlibrary=shared_library',
gyp info spawn args '-Dvisibility=default',
gyp info spawn args '-Dnode_root_dir=C:\\Users\\Carl Bourne\\.node-gyp\\0.8.22
',
gyp info spawn args '-Dmodule_root_dir=C:\\edge-master',
gyp info spawn args '--depth=.',
gyp info spawn args '--generator-output',
gyp info spawn args 'C:\\edge-master\\build',
gyp info spawn args '-Goutput_dir=.' ]
Warning: while converting VCCLCompilerTool/BasicRuntimeChecks to MSBuild, index
value (-1) not in expected range [0, 4)
Warning: unrecognized setting VCCLCompilerTool/ImageHasSafeExceptionHandlers whi
le converting to MSBuild.
Warning: while converting VCCLCompilerTool/RuntimeLibrary to MSBuild, index valu
e (-1) not in expected range [0, 4)
Warning: while converting VCCLCompilerTool/RuntimeTypeInfo to MSBuild, expected
bool; got '-1'
Warning: unrecognized setting VCCLCompilerTool/ImageHasSafeExceptionHandlers whi
le converting to MSBuild.
Warning: while converting VCCLCompilerTool/RuntimeLibrary to MSBuild, index valu
e (-1) not in expected range [0, 4)
Warning: while converting VCCLCompilerTool/RuntimeTypeInfo to MSBuild, expected
bool; got '-1'
Warning: while converting VCCLCompilerTool/BasicRuntimeChecks to MSBuild, index
value (-1) not in expected range [0, 4)
gyp info spawn C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe
gyp info spawn args [ 'build/binding.sln',
gyp info spawn args '/clp:Verbosity=minimal',
gyp info spawn args '/nologo',
gyp info spawn args '/p:Configuration=Release;Platform=x64' ]
Building the projects in this solution one at a time. To enable parallel build,
please add the "/m" switch.
clrfuncreflectionwrap.cpp
edge.cpp
nodejsfunc.cpp
nodejsfuncinvokecontext.cpp
clrfunc.cpp
persistentdisposecontext.cpp
utils.cpp
clractioncontext.cpp
v8synchronizationcontext.cpp
clrfuncinvokecontext.cpp
Generating Code...
Creating library C:\edge-master\build\Release\edge.lib and object C:\edge-
master\build\Release\edge.exp
LINK : /LTCG specified but no code generation required; remove /LTCG from the
link command line to improve linker performance
edge.vcxproj -> C:\edge-master\build\Release\\edge.node
gyp info ok
C:\edge-master\tools\\..\lib\native\win32\x64\0.8.22
1 file(s) copied.
1 file(s) copied.
Success building edge.node release for node.js x64 v0.8.22
Building edge.node release for node.js x64 v0.10.0
gyp info it worked if it ends with ok
gyp info using node-gyp@0.9.6
gyp info using node@0.10.0 | win32 | x64
gyp info spawn python
gyp info spawn args [ 'C:\\Users\\Carl Bourne\\AppData\\Roaming\\npm\\node_modul
es\\node-gyp\\gyp\\gyp',
gyp info spawn args 'binding.gyp',
gyp info spawn args '-f',
gyp info spawn args 'msvs',
gyp info spawn args '-G',
gyp info spawn args 'msvs_version=2012',
gyp info spawn args '-I',
gyp info spawn args 'C:\\edge-master\\build\\config.gypi',
gyp info spawn args '-I',
gyp info spawn args 'C:\\Users\\Carl Bourne\\AppData\\Roaming\\npm\\node_modul
es\\node-gyp\\addon.gypi',
gyp info spawn args '-I',
gyp info spawn args 'C:\\Users\\Carl Bourne\\.node-gyp\\0.10.0\\common.gypi',
gyp info spawn args '-Dlibrary=shared_library',
gyp info spawn args '-Dvisibility=default',
gyp info spawn args '-Dnode_root_dir=C:\\Users\\Carl Bourne\\.node-gyp\\0.10.0
',
gyp info spawn args '-Dmodule_root_dir=C:\\edge-master',
gyp info spawn args '--depth=.',
gyp info spawn args '--generator-output',
gyp info spawn args 'C:\\edge-master\\build',
gyp info spawn args '-Goutput_dir=.' ]
Warning: while converting VCCLCompilerTool/BasicRuntimeChecks to MSBuild, index
value (-1) not in expected range [0, 4)
Warning: while converting VCCLCompilerTool/RuntimeLibrary to MSBuild, index valu
e (-1) not in expected range [0, 4)
Warning: while converting VCCLCompilerTool/RuntimeTypeInfo to MSBuild, expected
bool; got '-1'
Warning: while converting VCCLCompilerTool/RuntimeLibrary to MSBuild, index valu
e (-1) not in expected range [0, 4)
Warning: while converting VCCLCompilerTool/RuntimeTypeInfo to MSBuild, expected
bool; got '-1'
Warning: while converting VCCLCompilerTool/BasicRuntimeChecks to MSBuild, index
value (-1) not in expected range [0, 4)
gyp info spawn C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe
gyp info spawn args [ 'build/binding.sln',
gyp info spawn args '/clp:Verbosity=minimal',
gyp info spawn args '/nologo',
gyp info spawn args '/p:Configuration=Release;Platform=x64' ]
Building the projects in this solution one at a time. To enable parallel build,
please add the "/m" switch.
clrfuncreflectionwrap.cpp
edge.cpp
nodejsfunc.cpp
nodejsfuncinvokecontext.cpp
clrfunc.cpp
persistentdisposecontext.cpp
utils.cpp
clractioncontext.cpp
v8synchronizationcontext.cpp
clrfuncinvokecontext.cpp
Generating Code...
Creating library C:\edge-master\build\Release\edge.lib and object C:\edge-
master\build\Release\edge.exp
LINK : /LTCG specified but no code generation required; remove /LTCG from the
link command line to improve linker performance
edge.vcxproj -> C:\edge-master\build\Release\\edge.node
gyp info ok
C:\edge-master\tools\\..\lib\native\win32\x64\0.10.0
1 file(s) copied.
1 file(s) copied.
Success building edge.node release for node.js x64 v0.10.0
It is interesting the 32 bit versions of node.js downloaded from nodejs.org are considered invalid Win32 applications. Can you try manually running c:\edge-master\lib\native\win32\ia32\0.6.20\node.exe
from the same window you compiled from and see if that works at all?
Just tried it:
"c:\edge-master\lib\native\win32\ia32\0.6.20\node.exe is not a valid Win32 application"
Yes it thinks it's invalid!
Can you try downloading the official one from http://nodejs.org/dist/v0.6.20/node.exe and see if that works? If it does, something might have gone wrong with the download during build: wipe out all node.exe files under lib\native, then run buildall again.
OK - So I re-built a Windows 7 VM and installed all of the dependencies. The build now seems to work without errors.
I then recompiled using nw-gyp.
I still get the same error when the Module.load is called though :(
Uncaught Error: %1 is not a valid Win32 application.
C:\Users\Carl Bourne\node_modules\edge\lib\native\win32\ia32\0.10.0\edge.node
I think I've made some progress here :)
I reference the edge.node module that was compiled with nw-gyp as follows:
var edge = require('C:\\edge-master\\build\\Release\\edge.node');
I'm not getting the win32 application error any more and node-webkit seems to load the module OK.
However, I can't seem to access the func
within it.
Uncaught TypeError: Object [object Object] has no method 'func'
If I write the edge object to console out console.log(edge)
I can see:
Object {initializeClrFunc: function}
initializeClrFunc: function () { [native code] }
__proto__: Object
index.html:16
The func
function is actually defined in edge.js, a thin wrapper around the edge.node native module. Note that you can force edge to load the native module from a specific location by setting the EDGE_NATIVE
environment variable to the full path, e.g.:
set EDGE_NATIVE=C:\edge-master\build\Release\edge.node
Then in your code, load edge as you do normally:
var edge = require('edge');
Excellent this worked :)
Thanks very much for your help!
So does this actually work for you end to end? Can you call into C# code? I was hitting some issues down the road even with this change.
I only ran the sample you provided that listed the certificates in the users local certificate store. I haven't tried anything more than this yet. Is that what you mean by calling into C# code?
So based on your 203_x509store.js
example, this:
var edge = require('C:\\data\\node_modules\\edge');
console.log(edge)
var listCertificates = edge.func(function() {/*
#r "System.dll"
using System.Collections.Generic;
using System.Security.Cryptography.X509Certificates;
async (data) =>
{
var input = (IDictionary<string,object>)data;
X509Store store = new X509Store(
(string)input["storeName"],
(StoreLocation)Enum.Parse(typeof(StoreLocation), (string)input["storeLocation"]));
store.Open(OpenFlags.ReadOnly);
try
{
List<string> result = new List<string>();
foreach (X509Certificate2 certificate in store.Certificates)
{
result.Add(certificate.Subject);
}
return result;
}
finally
{
store.Close();
}
}
*/});
var result = listCertificates({ storeName: 'root', storeLocation: 'CurrentUser' }, true);
console.log(result);
returns this in node-webkit:
["CN=Microsoft Root Certificate Authority, DC=microsoft, DC=com", "CN=Thawte Timestamping CA, OU=Thawte Certification, O=Thawte, L=Durbanville, S=Western Cape, C=ZA", "CN=Microsoft Root Authority, OU=Microsoft Corporation, OU=Copyright (c) 1997 Microsoft Corp.", "CN=Microsoft Authenticode(tm) Root Authority, O=MSFT, C=US", "CN=cjndemo-CA, DC=cjndemo, DC=com", "OU=Copyright (c) 1997 Microsoft Corp., OU=Microsof…=Microsoft Corporation, O=Microsoft Trust Network", "OU="NO LIABILITY ACCEPTED, (c)97 VeriSign, Inc.", …ot, OU="VeriSign, Inc.", O=VeriSign Trust Network", "CN=UTN-USERFirst-Object, OU=http://www.usertrust.c…e USERTRUST Network, L=Salt Lake City, S=UT, C=US", "E=premium-server@thawte.com, CN=Thawte Premium Ser… Consulting cc, L=Cape Town, S=Western Cape, C=ZA", "CN=GeoTrust Global CA, O=GeoTrust Inc., C=US", "CN=SwissSign Gold CA - G2, O=SwissSign AG, C=CH", "CN=Baltimore CyberTrust Root, OU=CyberTrust, O=Baltimore, C=IE", "OU=Equifax Secure Certificate Authority, O=Equifax, C=US", "CN=GlobalSign Root CA, OU=Root CA, O=GlobalSign nv-sa, C=BE", "CN=Entrust.net Secure Server Certification Authori…corp. by ref. (limits liab.), O=Entrust.net, C=US", "OU=VeriSign Trust Network, OU="(c) 1998 VeriSign, …fication Authority - G2, O="VeriSign, Inc.", C=US", "CN=GTE CyberTrust Global Root, OU="GTE CyberTrust Solutions, Inc.", O=GTE Corporation, C=US", "CN=thawte Primary Root CA, OU="(c) 2006 thawte, In…ication Services Division, O="thawte, Inc.", C=US", "CN=Microsoft Root Certificate Authority 2011, O=Microsoft Corporation, L=Redmond, S=Washington, C=US", "OU=VeriSign Trust Network, OU="(c) 1998 VeriSign, …fication Authority - G2, O="VeriSign, Inc.", C=US", "OU=Class 3 Public Primary Certification Authority, O="VeriSign, Inc.", C=US", "E=info@valicert.com, CN=http://www.valicert.com/, …O="ValiCert, Inc.", L=ValiCert Validation Network", "E=premium-server@thawte.com, CN=Thawte Premium Ser… Consulting cc, L=Cape Town, S=Western Cape, C=ZA", "CN=Certum CA, O=Unizeto Sp. z o.o., C=PL", "CN=DigiCert High Assurance EV Root CA, OU=www.digicert.com, O=DigiCert Inc, C=US", "CN=Entrust.net Certification Authority (2048), OU=…048 incorp. by ref. (limits liab.), O=Entrust.net", "OU=Class 3 Public Primary Certification Authority, O="VeriSign, Inc.", C=US", "CN=VeriSign Class 3 Public Primary Certification A…=VeriSign Trust Network, O="VeriSign, Inc.", C=US", "CN=StartCom Certification Authority, OU=Secure Digital Certificate Signing, O=StartCom Ltd., C=IL", "CN=Microsoft Root Certificate Authority 2010, O=Microsoft Corporation, L=Redmond, S=Washington, C=US", "E=info@valicert.com, CN=http://www.valicert.com/, …O="ValiCert, Inc.", L=ValiCert Validation Network", "OU=Go Daddy Class 2 Certification Authority, O="The Go Daddy Group, Inc.", C=US", "CN=VeriSign Class 3 Public Primary Certification A…=VeriSign Trust Network, O="VeriSign, Inc.", C=US", "CN=UTN-USERFirst-Hardware, OU=http://www.usertrust…e USERTRUST Network, L=Salt Lake City, S=UT, C=US", "CN=AddTrust External CA Root, OU=AddTrust External TTP Network, O=AddTrust AB, C=SE"]
Tomasz,
Well, I've built a simple node-webkit demo app that contains nearly all of your examples and they all seem to work OK. In fact very well!
I'm curios as to what issues you encountered during your tests?
If you would like, I'm happy to upload the demo when I'm finished?
Hi @carlskii,
I am facing the exactly same problem in my node-webkit project. Just wondering would you mind share your rebuild edge with simple node-webkit demo app?
I cannot get Edge working in Node-Webkit 0.8.1. I've recompiled using nw-gyp but after simply requiring the module in my JS code it crashes NW. FYI, I've filed a bug report on the Node-Webkit page. Has anyone successfully got Edge to work on Node-Webkit 0.8.x?
My previous message no longer applies. I've successfully built Edge and have it working in Node-Webkit.
can you share your build for win32 ?
My build is not special and the only deviation from the normal process of building Edge is by using nw-gyp instead of node-gyp. You can grab my build of the module from the following Github repo. Additionally you can see how I built the module in the README. That module was built for Node-Webkit 0.8.4. I don't know if it'll work out of the box in newer versions of 0.8.x. I know it will not work on 0.9.x.
Hi,
This problem maybe related to #60. However, I'm getting slightly different results. This time I built a demo Node-Webkit app that uses edge as per the code below.
However, whenever I call it I get the following error:-
Obviously a bit different to the problem in #60 !
If I run the same code outside of node-webkit using nodejs it works OK -
This also works OK using Node-Webkit.
Any guidance would be appreciated!