Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error's trying to call C# .NET 5.0 "Self-Contained" "Single-File" DLL on Windows without any .NET Frameworks Installed #131

Closed
harlankoehn opened this issue Mar 17, 2022 · 2 comments

Comments

@harlankoehn
Copy link

harlankoehn commented Mar 17, 2022

We were hoping to distribute our Electron app along with our .NET DLL and without any requirements to install any .NET Frameworks. So far, I haven't been able to achieve this.

As a test, I've written a small desktop app that utilizes this exact same DLL file, published it, and ran it on a clean Win10 VM that doesn't have any .NET frameworks installed. It runs without any problems.

When I take the DLL, copy over the same supporting DLL files needed by the desktop app, and also include a [projectname].deps.json file, and then run the Electron app, I get this error message:

With: process.env.EDGE_USE_CORECLR = 1
Unhandled Exception Error: This is not a published, standalone application and we are unable to locate the .NET Core SDK. Please make sure that it is installed; see http://microsoft.com/net/core for more details. at process.func [as dlopen] (electron/js2c/asar_bundle.js:5:1846)

Without any process.env.EDGE_USE_CORECLR statement

We get this:
System.TypeLoadException: Could not load type 'System.Object' from assembly 'System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e' because the parent does not exist.

Or this:
System.IO.FileNotFoundException: Could not load file or assembly 'System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e' or one of its dependencies. The system cannot find the file specified.

Our DLL project file looks like this:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>net5.0-windows</TargetFramework>
    <PreserveCompilationContext>true</PreserveCompilationContext>
    <CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
	<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
	<PlatformTarget>AnyCPU</PlatformTarget>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="EdgeJs" Version="11.15.0" />
    <PackageReference Include="System.Runtime" Version="4.3.1" />
    <PackageReference Include="System.Runtime.InteropServices" Version="4.3.0" />
    <PackageReference Include="System.Threading.Tasks" Version="4.3.0" />
    <PackageReference Include="System.Threading.ThreadPool" Version="4.3.0" />
  </ItemGroup>

</Project>

I've attached a screenshot of our DLL publish settings. This just produces a NUPKG file that when expanded, doesn't include any of the supporting DLL's needed.

Just to reiterate, how can we call functions in a .NET 5.0 or 6.0 DLL without having to install any .NET framework on the target machine? Would we have better luck if we targeted .NET 4.6 or some older version of .NET Core? Is this a problem in Edge or a problem with .NET Core? Also, do we need to target "Any CPU", "Win-x86" or "Win-x64"? We currently only need our Electron app to work on Windows but we intend to support both 32bit and 64bit versions.

DLL_Publish_Settings

@tjcouch-sil
Copy link

tjcouch-sil commented Jan 26, 2023

Hello @harlankoehn and @agracio ! By any chance, did you find a solution to this issue? I am experiencing the same issue only after packaging. I am running electron-builder, and everything works in developer builds. I have the C# published project folder set in extraResources. I'm on .NET 6.0, but netcoreapp3.1 also does not seem to work. I have followed the standalone instructions in edge.js's readme regarding adding the PackageReferences and PropertyGroup item. I'm dotnet publishing with runtime win-x64 and self-contained. The environment variables are the following:

EDGE_USE_CORECLR: 1
EDGE_APP_ROOT: C:\Users\tj_co\source\repos\paranext-core\release\build\win-unpacked\resources\c-sharp\bin\Release\net6.0\publish\win-x64 (Correct, and the C# published project is at this location)
EDGE_BOOTSTRAP_DIR: C:\Users\tj_co\source\repos\paranext-core\release\build\win-unpacked\resources\app.asar\node_modules\electron-edge-js\lib\bootstrap\obj\Release\netcoreapp1.1 (without setting this, it is undefined in production. So I set it, but it doesn't seem to do anything)

And I receive the following error no matter what I do in playing with various publishing or packaging settings:

Error invoking remote method 'electronAPI.edge.invoke': System.TypeLoadException: Could not load type 'System.Object' from assembly 'System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e' because the parent does not exist.

Following is a printout of the files in the EDGE_APP_ROOT folder (the C# project I'm using is EdgeLibrary.csproj):

EDGE_APP_ROOT file list
Directory: C:\Users\tj_co\source\repos\paranext-core\release\build\win-unpacked\resources\c-sharp\bin\Release\net6.
    0\publish\win-x64


Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
d-----         1/26/2023     14:17                cs
d-----         1/26/2023     14:17                de
d-----         1/26/2023     14:17                es
d-----         1/26/2023     14:17                fr
d-----         1/26/2023     14:17                it
d-----         1/26/2023     14:17                ja
d-----         1/26/2023     14:17                ko
d-----         1/26/2023     14:17                pl
d-----         1/26/2023     14:17                pt-BR
d-----         1/26/2023     14:17                refs
d-----         1/26/2023     14:17                ru
d-----         1/26/2023     14:17                tr
d-----         1/26/2023     14:17                zh-Hans
d-----         1/26/2023     14:17                zh-Hant
-a----         9/11/2021     15:05          20944 api-ms-win-core-console-l1-1-0.dll
-a----         9/11/2021     15:05          20960 api-ms-win-core-console-l1-2-0.dll
-a----         9/11/2021     15:05          20952 api-ms-win-core-datetime-l1-1-0.dll
-a----         9/11/2021     15:05          20944 api-ms-win-core-debug-l1-1-0.dll
-a----         9/11/2021     15:05          20944 api-ms-win-core-errorhandling-l1-1-0.dll
-a----         9/11/2021     15:05          20944 api-ms-win-core-fibers-l1-1-0.dll
-a----         9/11/2021     15:05          25048 api-ms-win-core-file-l1-1-0.dll
-a----         9/11/2021     15:05          20960 api-ms-win-core-file-l1-2-0.dll
-a----         9/11/2021     15:05          20960 api-ms-win-core-file-l2-1-0.dll
-a----         9/11/2021     15:05          20944 api-ms-win-core-handle-l1-1-0.dll
-a----         9/11/2021     15:05          20960 api-ms-win-core-heap-l1-1-0.dll
-a----         9/11/2021     15:05          20944 api-ms-win-core-interlocked-l1-1-0.dll
-a----         9/11/2021     15:05          20944 api-ms-win-core-libraryloader-l1-1-0.dll
-a----         9/11/2021     15:05          20960 api-ms-win-core-localization-l1-2-0.dll
-a----         9/11/2021     15:05          20944 api-ms-win-core-memory-l1-1-0.dll
-a----         9/11/2021     15:05          20960 api-ms-win-core-namedpipe-l1-1-0.dll
-a----         9/11/2021     15:05          20944 api-ms-win-core-processenvironment-l1-1-0.dll
-a----         9/11/2021     15:05          20944 api-ms-win-core-processthreads-l1-1-0.dll
-a----         9/11/2021     15:05          20944 api-ms-win-core-processthreads-l1-1-1.dll
-a----         9/11/2021     15:05          20944 api-ms-win-core-profile-l1-1-0.dll
-a----         9/11/2021     15:05          20960 api-ms-win-core-rtlsupport-l1-1-0.dll
-a----         9/11/2021     15:05          20960 api-ms-win-core-string-l1-1-0.dll
-a----         9/11/2021     15:05          20944 api-ms-win-core-synch-l1-1-0.dll
-a----         9/11/2021     15:05          20944 api-ms-win-core-synch-l1-2-0.dll
-a----         9/11/2021     15:05          20944 api-ms-win-core-sysinfo-l1-1-0.dll
-a----         9/11/2021     15:05          20944 api-ms-win-core-timezone-l1-1-0.dll
-a----         9/11/2021     15:05          20944 api-ms-win-core-util-l1-1-0.dll
-a----         9/11/2021     15:05          20944 api-ms-win-crt-conio-l1-1-0.dll
-a----         9/11/2021     15:05          25056 api-ms-win-crt-convert-l1-1-0.dll
-a----         9/11/2021     15:05          20944 api-ms-win-crt-environment-l1-1-0.dll
-a----         9/11/2021     15:05          20944 api-ms-win-crt-filesystem-l1-1-0.dll
-a----         9/11/2021     15:05          20944 api-ms-win-crt-heap-l1-1-0.dll
-a----         9/11/2021     15:05          20944 api-ms-win-crt-locale-l1-1-0.dll
-a----         9/11/2021     15:05          29144 api-ms-win-crt-math-l1-1-0.dll
-a----         9/11/2021     15:05          29136 api-ms-win-crt-multibyte-l1-1-0.dll
-a----         9/11/2021     15:05          74192 api-ms-win-crt-private-l1-1-0.dll
-a----         9/11/2021     15:05          20944 api-ms-win-crt-process-l1-1-0.dll
-a----         9/11/2021     15:05          25040 api-ms-win-crt-runtime-l1-1-0.dll
-a----         9/11/2021     15:05          25040 api-ms-win-crt-stdio-l1-1-0.dll
-a----         9/11/2021     15:05          25040 api-ms-win-crt-string-l1-1-0.dll
-a----         9/11/2021     15:05          20944 api-ms-win-crt-time-l1-1-0.dll
-a----         9/11/2021     15:05          20944 api-ms-win-crt-utility-l1-1-0.dll
-a----         12/6/2022     13:37         152576 apphost.exe
-a----        11/30/2022     15:30         304808 clretwrc.dll
-a----        11/30/2022     15:24        1436328 clrjit.dll
-a----         12/6/2022     13:38         190976 comhost.dll
-a----        11/30/2022     15:32        5125800 coreclr.dll
-a----         12/6/2022     13:33           2552 coreclr_delegates.h
-a----        11/30/2022     15:29          57584 createdump.exe
-a----        11/30/2022     15:30         140456 dbgshim.dll
-a----         12/6/2022     13:37         184968 dotnet.exe
-a----         1/26/2023     14:02          99840 EdgeJs.dll
-a----         1/24/2023     09:45          17460 EdgeJs.pdb
-a----         1/26/2023     14:12         167712 EdgeLibrary.deps.json
-a----         1/26/2023     14:02          19456 EdgeLibrary.dll
-a----         12/6/2022     13:37         184968 EdgeLibrary.exe
-a----         1/26/2023     14:01          12352 EdgeLibrary.pdb
-a----         12/6/2022     13:36         382080 hostfxr.dll
-a----         12/6/2022     13:33          11978 hostfxr.h
-a----         12/6/2022     13:37         391816 hostpolicy.dll
-a----         1/26/2023     14:01         851456 Humanizer.dll
-a----         12/6/2022     13:38         154752 ijwhost.dll
-a----         12/6/2022     13:38           1716 ijwhost.lib
-a----         12/6/2022     13:36       24437726 libhostfxr.lib
-a----         12/6/2022     13:37        2145966 libnethost.lib
-a----        10/22/2021     18:47          16000 Microsoft.Bcl.AsyncInterfaces.dll
-a----         1/26/2023     14:01       17760256 Microsoft.CodeAnalysis.CSharp.dll
-a----         1/26/2023     14:01        2442752 Microsoft.CodeAnalysis.CSharp.Workspaces.dll
-a----         1/26/2023     14:01        7549440 Microsoft.CodeAnalysis.dll
-a----         1/26/2023     14:02       14079488 Microsoft.CodeAnalysis.VisualBasic.dll
-a----         1/26/2023     14:02        2288640 Microsoft.CodeAnalysis.VisualBasic.Workspaces.dll
-a----         1/26/2023     14:02        9745920 Microsoft.CodeAnalysis.Workspaces.dll
-a----        11/30/2022     16:14        1042560 Microsoft.CSharp.dll
-a----        12/16/2020     17:57        1813896 Microsoft.DiaSymReader.Native.amd64.dll
-a----         1/26/2023     14:02          25088 Microsoft.DotNet.InternalAbstractions.dll
-a----         1/26/2023     14:02         159232 Microsoft.Extensions.DependencyModel.dll
-a----        11/30/2022     16:15        1245352 Microsoft.VisualBasic.Core.dll
-a----        11/30/2022     15:39          18064 Microsoft.VisualBasic.dll
-a----        11/30/2022     16:15          26280 Microsoft.Win32.Primitives.dll
-a----        11/30/2022     16:15          87680 Microsoft.Win32.Registry.dll
-a----        11/30/2022     15:38        1321872 mscordaccore.dll
-a----        11/30/2022     15:38        1321872 mscordaccore_amd64_amd64_6.0.1322.58009.dll
-a----        11/30/2022     15:38        1268616 mscordbi.dll
-a----        11/30/2022     15:39          58496 mscorlib.dll
-a----        11/30/2022     15:30         147072 mscorrc.dll
-a----        11/30/2022     15:39         499584 msquic.dll
-a----         12/6/2022     13:37         144000 nethost.dll
-a----         12/6/2022     13:33           2942 nethost.h
-a----         12/6/2022     13:37           1742 nethost.lib
-a----        11/30/2022     15:39         101520 netstandard.dll
-a----         1/26/2023     14:02        1879552 Newtonsoft.Json.dll
-a----         12/6/2022     13:35        9465856 singlefilehost.exe
-a----        11/30/2022     15:39          15488 System.AppContext.dll
-a----        11/30/2022     15:39          15488 System.Buffers.dll
-a----        11/30/2022     16:15         246952 System.Collections.Concurrent.dll
-a----        11/30/2022     16:15         264832 System.Collections.dll
-a----        11/30/2022     16:15         666240 System.Collections.Immutable.dll
-a----        11/30/2022     16:15         100992 System.Collections.NonGeneric.dll
-a----        11/30/2022     16:15          95400 System.Collections.Specialized.dll
-a----        11/30/2022     16:15         187048 System.ComponentModel.Annotations.dll
-a----        11/30/2022     15:39          17576 System.ComponentModel.DataAnnotations.dll
-a----        11/30/2022     16:15          18600 System.ComponentModel.dll
-a----        11/30/2022     16:15          38528 System.ComponentModel.EventBasedAsync.dll
-a----        11/30/2022     16:15          75392 System.ComponentModel.Primitives.dll
-a----        11/30/2022     16:15         744616 System.ComponentModel.TypeConverter.dll
-a----         1/26/2023     14:02          13824 System.Composition.AttributedModel.dll
-a----         1/26/2023     14:02         104960 System.Composition.Convention.dll
-a----         1/26/2023     14:02         105984 System.Composition.Hosting.dll
-a----         1/26/2023     14:02          30720 System.Composition.Runtime.dll
-a----         1/26/2023     14:02         122880 System.Composition.TypedParts.dll
-a----        11/30/2022     15:39          19592 System.Configuration.dll
-a----        11/30/2022     16:15         156840 System.Console.dll
-a----        11/30/2022     15:39          24200 System.Core.dll
-a----        11/30/2022     16:15        2983552 System.Data.Common.dll
-a----        11/30/2022     15:39          16008 System.Data.DataSetExtensions.dll
-a----        11/30/2022     15:39          25728 System.Data.dll
-a----        11/30/2022     15:39          16000 System.Diagnostics.Contracts.dll
-a----        11/30/2022     15:39          16000 System.Diagnostics.Debug.dll
-a----        11/30/2022     16:15         380584 System.Diagnostics.DiagnosticSource.dll
-a----        11/30/2022     16:15          35456 System.Diagnostics.FileVersionInfo.dll
-a----        11/30/2022     16:16         290432 System.Diagnostics.Process.dll
-a----        11/30/2022     16:16          36480 System.Diagnostics.StackTrace.dll
-a----        11/30/2022     16:16          60544 System.Diagnostics.TextWriterTraceListener.dll
-a----        11/30/2022     15:39          16000 System.Diagnostics.Tools.dll
-a----        11/30/2022     16:16         133248 System.Diagnostics.TraceSource.dll
-a----        11/30/2022     15:39          16512 System.Diagnostics.Tracing.dll
-a----        11/30/2022     15:39          50816 System.dll
-a----        11/30/2022     15:39          21136 System.Drawing.dll
-a----        11/30/2022     16:16         130176 System.Drawing.Primitives.dll
-a----        11/30/2022     15:39          16528 System.Dynamic.Runtime.dll
-a----        11/30/2022     16:16         197248 System.Formats.Asn1.dll
-a----        11/30/2022     15:39          16000 System.Globalization.Calendars.dll
-a----        11/30/2022     15:39          16000 System.Globalization.dll
-a----        11/30/2022     15:39          15504 System.Globalization.Extensions.dll
-a----        11/30/2022     16:16          72832 System.IO.Compression.Brotli.dll
-a----        11/30/2022     16:16         266880 System.IO.Compression.dll
-a----        11/30/2022     15:39          16008 System.IO.Compression.FileSystem.dll
-a----        11/30/2022     15:39         822912 System.IO.Compression.Native.dll
-a----        11/30/2022     16:16          39552 System.IO.Compression.ZipFile.dll
-a----        11/30/2022     15:39          16016 System.IO.dll
-a----        11/30/2022     16:16          93824 System.IO.FileSystem.AccessControl.dll
-a----        11/30/2022     15:39          24200 System.IO.FileSystem.dll
-a----        11/30/2022     16:16          42624 System.IO.FileSystem.DriveInfo.dll
-a----        11/30/2022     15:39          15496 System.IO.FileSystem.Primitives.dll
-a----        11/30/2022     16:16          72320 System.IO.FileSystem.Watcher.dll
-a----        11/30/2022     16:16          83584 System.IO.IsolatedStorage.dll
-a----        11/30/2022     16:16          69248 System.IO.MemoryMappedFiles.dll
-a----         1/26/2023     14:02         179712 System.IO.Pipelines.dll
-a----        11/30/2022     15:39          16528 System.IO.Pipes.AccessControl.dll
-a----        11/30/2022     16:16         136320 System.IO.Pipes.dll
-a----        11/30/2022     15:39          15488 System.IO.UnmanagedMemoryStream.dll
-a----        11/30/2022     16:16         538240 System.Linq.dll
-a----        11/30/2022     16:16        3857024 System.Linq.Expressions.dll
-a----        11/30/2022     16:16         849024 System.Linq.Parallel.dll
-a----        11/30/2022     16:17         228480 System.Linq.Queryable.dll
-a----        11/30/2022     16:17         173696 System.Memory.dll
-a----        11/30/2022     15:39          18064 System.Net.dll
-a----        11/30/2022     16:17        1803392 System.Net.Http.dll
-a----        11/30/2022     16:17          82048 System.Net.Http.Json.dll
-a----        11/30/2022     16:17         639104 System.Net.HttpListener.dll
-a----        11/30/2022     16:17         551552 System.Net.Mail.dll
-a----        11/30/2022     16:17         100992 System.Net.NameResolution.dll
-a----        11/30/2022     16:17         150656 System.Net.NetworkInformation.dll
-a----        11/30/2022     16:17          78976 System.Net.Ping.dll
-a----        11/30/2022     16:17         214144 System.Net.Primitives.dll
-a----        11/30/2022     16:17         291968 System.Net.Quic.dll
-a----        11/30/2022     16:17         348800 System.Net.Requests.dll
-a----        11/30/2022     16:17         682112 System.Net.Security.dll
-a----        11/30/2022     16:17          36992 System.Net.ServicePoint.dll
-a----        11/30/2022     16:17         506496 System.Net.Sockets.dll
-a----        11/30/2022     16:17         166528 System.Net.WebClient.dll
-a----        11/30/2022     16:17          60544 System.Net.WebHeaderCollection.dll
-a----        11/30/2022     16:18          31872 System.Net.WebProxy.dll
-a----        11/30/2022     16:18          75904 System.Net.WebSockets.Client.dll
-a----        11/30/2022     16:18         181888 System.Net.WebSockets.dll
-a----        11/30/2022     15:39          16016 System.Numerics.dll
-a----        11/30/2022     15:39          16000 System.Numerics.Vectors.dll
-a----        11/30/2022     16:18          91264 System.ObjectModel.dll
-a----        11/30/2022     15:36       10630272 System.Private.CoreLib.dll
-a----        11/30/2022     16:18        2076288 System.Private.DataContractSerialization.dll
-a----        11/30/2022     16:18         252544 System.Private.Uri.dll
-a----        11/30/2022     16:18        8505472 System.Private.Xml.dll
-a----        11/30/2022     16:18         405120 System.Private.Xml.Linq.dll
-a----        11/30/2022     16:18          66176 System.Reflection.DispatchProxy.dll
-a----        11/30/2022     15:39          16512 System.Reflection.dll
-a----        11/30/2022     15:39          16000 System.Reflection.Emit.dll
-a----        11/30/2022     15:39          16000 System.Reflection.Emit.ILGeneration.dll
-a----        11/30/2022     15:39          16000 System.Reflection.Emit.Lightweight.dll
-a----        11/30/2022     15:39          15496 System.Reflection.Extensions.dll
-a----        11/30/2022     16:18        1130624 System.Reflection.Metadata.dll
-a----        11/30/2022     15:39          16000 System.Reflection.Primitives.dll
-a----        11/30/2022     16:18          33408 System.Reflection.TypeExtensions.dll
-a----        11/30/2022     15:39          15504 System.Resources.Reader.dll
-a----        11/30/2022     15:39          16000 System.Resources.ResourceManager.dll
-a----        11/30/2022     16:18          45184 System.Resources.Writer.dll
-a----        11/30/2022     16:18          22656 System.Runtime.CompilerServices.Unsafe.dll
-a----        11/30/2022     16:18          20096 System.Runtime.CompilerServices.VisualC.dll
-a----        11/30/2022     15:39          42624 System.Runtime.dll
-a----        11/30/2022     15:39          18048 System.Runtime.Extensions.dll
-a----        11/30/2022     15:39          15504 System.Runtime.Handles.dll
-a----        11/30/2022     16:18          51840 System.Runtime.InteropServices.dll
-a----        11/30/2022     16:18          31872 System.Runtime.InteropServices.RuntimeInformation.dll
-a----        11/30/2022     15:39          16512 System.Runtime.Intrinsics.dll
-a----        11/30/2022     15:39          16000 System.Runtime.Loader.dll
-a----        11/30/2022     16:18         221824 System.Runtime.Numerics.dll
-a----        11/30/2022     15:39          17552 System.Runtime.Serialization.dll
-a----        11/30/2022     16:19         322176 System.Runtime.Serialization.Formatters.dll
-a----        11/30/2022     15:39          16016 System.Runtime.Serialization.Json.dll
-a----        11/30/2022     16:19          28800 System.Runtime.Serialization.Primitives.dll
-a----        11/30/2022     15:39          16528 System.Runtime.Serialization.Xml.dll
-a----        11/30/2022     16:19         215168 System.Security.AccessControl.dll
-a----        11/30/2022     16:19          94336 System.Security.Claims.dll
-a----        11/30/2022     16:19         804992 System.Security.Cryptography.Algorithms.dll
-a----        11/30/2022     16:19         485504 System.Security.Cryptography.Cng.dll
-a----        11/30/2022     16:19         189568 System.Security.Cryptography.Csp.dll
-a----        11/30/2022     16:19          93824 System.Security.Cryptography.Encoding.dll
-a----        11/30/2022     16:19          31872 System.Security.Cryptography.OpenSsl.dll
-a----        11/30/2022     16:19         134784 System.Security.Cryptography.Primitives.dll
-a----        11/30/2022     16:19         486528 System.Security.Cryptography.X509Certificates.dll
-a----        11/30/2022     15:39          18568 System.Security.dll
-a----        11/30/2022     15:39          15488 System.Security.Principal.dll
-a----        11/30/2022     16:19         151680 System.Security.Principal.Windows.dll
-a----        11/30/2022     15:39          15496 System.Security.SecureString.dll
-a----        11/30/2022     15:39          17576 System.ServiceModel.Web.dll
-a----        11/30/2022     15:39          16528 System.ServiceProcess.dll
-a----        11/30/2022     16:19         871040 System.Text.Encoding.CodePages.dll
-a----        11/30/2022     15:39          16000 System.Text.Encoding.dll
-a----        11/30/2022     15:39          16000 System.Text.Encoding.Extensions.dll
-a----         1/26/2023     13:56         117248 System.Text.Encodings.Web.dll
-a----         1/26/2023     13:56        1470464 System.Text.Json.dll
-a----        11/30/2022     16:19         530048 System.Text.RegularExpressions.dll
-a----        11/30/2022     16:19         125056 System.Threading.Channels.dll
-a----        11/30/2022     16:19          80000 System.Threading.dll
-a----        11/30/2022     15:39          16000 System.Threading.Overlapped.dll
-a----        11/30/2022     16:20         505472 System.Threading.Tasks.Dataflow.dll
-a----        11/30/2022     15:39          17024 System.Threading.Tasks.dll
-a----        11/30/2022     15:39          16000 System.Threading.Tasks.Extensions.dll
-a----        11/30/2022     16:20         138880 System.Threading.Tasks.Parallel.dll
-a----        11/30/2022     15:39          16000 System.Threading.Thread.dll
-a----        11/30/2022     15:39          16000 System.Threading.ThreadPool.dll
-a----        11/30/2022     15:39          15488 System.Threading.Timer.dll
-a----        11/30/2022     15:39          17032 System.Transactions.dll
-a----        11/30/2022     16:20         351360 System.Transactions.Local.dll
-a----        11/30/2022     15:39          15504 System.ValueTuple.dll
-a----        11/30/2022     15:39          16016 System.Web.dll
-a----        11/30/2022     16:20          52864 System.Web.HttpUtility.dll
-a----        11/30/2022     15:39          16520 System.Windows.dll
-a----        11/30/2022     15:39          24704 System.Xml.dll
-a----        11/30/2022     15:39          16528 System.Xml.Linq.dll
-a----        11/30/2022     15:39          22160 System.Xml.ReaderWriter.dll
-a----        11/30/2022     15:39          16528 System.Xml.Serialization.dll
-a----        11/30/2022     15:39          16008 System.Xml.XDocument.dll
-a----        11/30/2022     15:39          16008 System.Xml.XmlDocument.dll
-a----        11/30/2022     15:39          18088 System.Xml.XmlSerializer.dll
-a----        11/30/2022     15:39          16016 System.Xml.XPath.dll
-a----        11/30/2022     16:20          18048 System.Xml.XPath.XDocument.dll
-a----         9/11/2021     15:05        1122768 ucrtbase.dll
-a----        11/30/2022     15:39          17064 WindowsBase.dll

And following is a printout of the files in the EDGE_APP_ROOT/refs folder:

EDGE_APP_ROOT/refs file list
Directory: C:\Users\tj_co\source\repos\paranext-core\release\build\win-unpacked\resources\c-sharp\bin\Release\net6.
    0\publish\win-x64\refs


Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
-a----         12/2/2022     19:15          19072 Microsoft.CSharp.dll
-a----         12/2/2022     19:15          60032 Microsoft.VisualBasic.Core.dll
-a----         12/2/2022     19:05          18064 Microsoft.VisualBasic.dll
-a----         12/2/2022     19:14          17064 Microsoft.Win32.Primitives.dll
-a----         12/2/2022     19:15          22184 Microsoft.Win32.Registry.dll
-a----         12/2/2022     19:16          56488 mscorlib.dll
-a----         12/2/2022     19:08         101520 netstandard.dll
-a----         12/2/2022     19:15          15528 System.AppContext.dll
-a----         12/2/2022     19:15          15528 System.Buffers.dll
-a----         12/2/2022     19:15          27816 System.Collections.Concurrent.dll
-a----         12/2/2022     19:14          46208 System.Collections.dll
-a----         12/2/2022     19:14          66728 System.Collections.Immutable.dll
-a----         12/2/2022     19:15          24232 System.Collections.NonGeneric.dll
-a----         12/2/2022     19:15          26792 System.Collections.Specialized.dll
-a----         12/2/2022     19:15          30888 System.ComponentModel.Annotations.dll
-a----         12/2/2022     19:56          17576 System.ComponentModel.DataAnnotations.dll
-a----         12/2/2022     19:15          17064 System.ComponentModel.dll
-a----         12/2/2022     19:14          20136 System.ComponentModel.EventBasedAsync.dll
-a----         12/2/2022     19:14          26792 System.ComponentModel.Primitives.dll
-a----         12/2/2022     19:15         102568 System.ComponentModel.TypeConverter.dll
-a----         12/2/2022     19:04          19592 System.Configuration.dll
-a----         12/2/2022     19:14          26792 System.Console.dll
-a----         12/2/2022     19:04          24200 System.Core.dll
-a----         12/2/2022     19:15         152232 System.Data.Common.dll
-a----         12/2/2022     19:15          16000 System.Data.DataSetExtensions.dll
-a----         12/2/2022     19:15          24232 System.Data.dll
-a----         12/2/2022     19:15          20608 System.Diagnostics.Contracts.dll
-a----         12/2/2022     19:15          16040 System.Diagnostics.Debug.dll
-a----         12/2/2022     19:15          35968 System.Diagnostics.DiagnosticSource.dll
-a----         12/2/2022     19:15          18088 System.Diagnostics.FileVersionInfo.dll
-a----         12/2/2022     19:15          31912 System.Diagnostics.Process.dll
-a----         12/2/2022     19:14          23720 System.Diagnostics.StackTrace.dll
-a----         12/2/2022     19:15          18600 System.Diagnostics.TextWriterTraceListener.dll
-a----         12/2/2022     19:15          15528 System.Diagnostics.Tools.dll
-a----         12/2/2022     19:16          27816 System.Diagnostics.TraceSource.dll
-a----         12/2/2022     19:15          28328 System.Diagnostics.Tracing.dll
-a----         12/2/2022     19:15          50344 System.dll
-a----         12/2/2022     19:04          21136 System.Drawing.dll
-a----         12/2/2022     19:14          36520 System.Drawing.Primitives.dll
-a----         12/2/2022     19:15          16552 System.Dynamic.Runtime.dll
-a----         12/2/2022     19:15          26792 System.Formats.Asn1.dll
-a----         12/2/2022     19:15          16000 System.Globalization.Calendars.dll
-a----         12/2/2022     19:15          16040 System.Globalization.dll
-a----         12/2/2022     19:15          16000 System.Globalization.Extensions.dll
-a----         12/2/2022     19:15          19112 System.IO.Compression.Brotli.dll
-a----         12/2/2022     19:15          21632 System.IO.Compression.dll
-a----         12/2/2022     19:04          16008 System.IO.Compression.FileSystem.dll
-a----         12/2/2022     19:15          17536 System.IO.Compression.ZipFile.dll
-a----         12/2/2022     19:15          16040 System.IO.dll
-a----         12/2/2022     19:15          21632 System.IO.FileSystem.AccessControl.dll
-a----         12/2/2022     19:14          16040 System.IO.FileSystem.dll
-a----         12/2/2022     19:15          18088 System.IO.FileSystem.DriveInfo.dll
-a----         12/2/2022     19:14          16000 System.IO.FileSystem.Primitives.dll
-a----         12/2/2022     19:16          21632 System.IO.FileSystem.Watcher.dll
-a----         12/2/2022     19:15          23208 System.IO.IsolatedStorage.dll
-a----         12/2/2022     19:15          19624 System.IO.MemoryMappedFiles.dll
-a----         12/2/2022     19:15          19624 System.IO.Pipes.AccessControl.dll
-a----         12/2/2022     19:15          22144 System.IO.Pipes.dll
-a----         12/2/2022     19:15          15488 System.IO.UnmanagedMemoryStream.dll
-a----         12/2/2022     19:15          32384 System.Linq.dll
-a----         12/2/2022     19:15          63616 System.Linq.Expressions.dll
-a----         12/2/2022     19:15          32424 System.Linq.Parallel.dll
-a----         12/2/2022     19:15          30848 System.Linq.Queryable.dll
-a----         12/2/2022     19:15          45736 System.Memory.dll
-a----         12/2/2022     19:05          18064 System.Net.dll
-a----         12/2/2022     19:15          57984 System.Net.Http.dll
-a----         12/2/2022     19:15          20648 System.Net.Http.Json.dll
-a----         12/2/2022     19:15          25768 System.Net.HttpListener.dll
-a----         12/2/2022     19:15          31400 System.Net.Mail.dll
-a----         12/2/2022     19:15          18560 System.Net.NameResolution.dll
-a----         12/2/2022     19:15          33920 System.Net.NetworkInformation.dll
-a----         12/2/2022     19:16          20608 System.Net.Ping.dll
-a----         12/2/2022     19:15          33408 System.Net.Primitives.dll
-a----         12/2/2022     19:15          38056 System.Net.Requests.dll
-a----         12/2/2022     19:15          49320 System.Net.Security.dll
-a----         12/2/2022     19:15          20648 System.Net.ServicePoint.dll
-a----         12/2/2022     19:15          46720 System.Net.Sockets.dll
-a----         12/2/2022     19:15          28840 System.Net.WebClient.dll
-a----         12/2/2022     19:15          20096 System.Net.WebHeaderCollection.dll
-a----         12/2/2022     19:15          18600 System.Net.WebProxy.dll
-a----         12/2/2022     19:15          19584 System.Net.WebSockets.Client.dll
-a----         12/2/2022     19:15          23208 System.Net.WebSockets.dll
-a----         12/2/2022     19:05          16016 System.Numerics.dll
-a----         12/2/2022     19:15          35968 System.Numerics.Vectors.dll
-a----         12/2/2022     19:15          30336 System.ObjectModel.dll
-a----         12/2/2022     19:15          16512 System.Reflection.DispatchProxy.dll
-a----         12/2/2022     19:15          16552 System.Reflection.dll
-a----         12/2/2022     19:15          39552 System.Reflection.Emit.dll
-a----         12/2/2022     19:15          21672 System.Reflection.Emit.ILGeneration.dll
-a----         12/2/2022     19:15          20096 System.Reflection.Emit.Lightweight.dll
-a----         12/2/2022     19:15          15488 System.Reflection.Extensions.dll
-a----         12/2/2022     19:15         120456 System.Reflection.Metadata.dll
-a----         12/2/2022     19:16          22696 System.Reflection.Primitives.dll
-a----         12/2/2022     19:17          20648 System.Reflection.TypeExtensions.dll
-a----         12/2/2022     19:15          15496 System.Resources.Reader.dll
-a----         12/2/2022     19:16          16040 System.Resources.ResourceManager.dll
-a----         12/2/2022     19:16          17040 System.Resources.Writer.dll
-a----         12/2/2022     19:16          19600 System.Runtime.CompilerServices.Unsafe.dll
-a----         12/2/2022     19:16          18056 System.Runtime.CompilerServices.VisualC.dll
-a----         12/2/2022     19:15         476296 System.Runtime.dll
-a----         12/2/2022     19:16          18088 System.Runtime.Extensions.dll
-a----         12/2/2022     19:16          16040 System.Runtime.Handles.dll
-a----         12/2/2022     19:16          68744 System.Runtime.InteropServices.dll
-a----         12/2/2022     19:15          17576 System.Runtime.InteropServices.RuntimeInformation.dll
-a----         12/2/2022     19:15         168616 System.Runtime.Intrinsics.dll
-a----         12/2/2022     19:16          20112 System.Runtime.Loader.dll
-a----         12/2/2022     19:16          24200 System.Runtime.Numerics.dll
-a----         12/2/2022     19:04          17552 System.Runtime.Serialization.dll
-a----         12/2/2022     19:16          24200 System.Runtime.Serialization.Formatters.dll
-a----         12/2/2022     19:15          21136 System.Runtime.Serialization.Json.dll
-a----         12/2/2022     19:16          20112 System.Runtime.Serialization.Primitives.dll
-a----         12/2/2022     19:16          36496 System.Runtime.Serialization.Xml.dll
-a----         12/2/2022     19:17          38056 System.Security.AccessControl.dll
-a----         12/2/2022     19:16          32936 System.Security.Claims.dll
-a----         12/2/2022     19:15          48808 System.Security.Cryptography.Algorithms.dll
-a----         12/2/2022     19:16          30376 System.Security.Cryptography.Cng.dll
-a----         12/2/2022     19:16          27784 System.Security.Cryptography.Csp.dll
-a----         12/2/2022     19:16          21648 System.Security.Cryptography.Encoding.dll
-a----         12/2/2022     19:16          20104 System.Security.Cryptography.OpenSsl.dll
-a----         12/2/2022     19:15          28816 System.Security.Cryptography.Primitives.dll
-a----         12/2/2022     19:16          41608 System.Security.Cryptography.X509Certificates.dll
-a----         12/2/2022     19:04          18568 System.Security.dll
-a----         12/2/2022     19:16          15496 System.Security.Principal.dll
-a----         12/2/2022     19:16          27792 System.Security.Principal.Windows.dll
-a----         12/2/2022     19:16          16040 System.Security.SecureString.dll
-a----         12/2/2022     19:56          17576 System.ServiceModel.Web.dll
-a----         12/2/2022     19:05          16528 System.ServiceProcess.dll
-a----         12/2/2022     19:16          16552 System.Text.Encoding.CodePages.dll
-a----         12/2/2022     19:16          16552 System.Text.Encoding.dll
-a----         12/2/2022     19:16          21648 System.Text.Encoding.Extensions.dll
-a----         12/2/2022     19:15          27304 System.Text.Encodings.Web.dll
-a----         12/2/2022     19:15          61608 System.Text.Json.dll
-a----         12/2/2022     19:16          33424 System.Text.RegularExpressions.dll
-a----         12/2/2022     19:15          19624 System.Threading.Channels.dll
-a----         12/2/2022     19:15          32392 System.Threading.dll
-a----         12/2/2022     19:16          19592 System.Threading.Overlapped.dll
-a----         12/2/2022     19:16          32904 System.Threading.Tasks.Dataflow.dll
-a----         12/2/2022     19:16          17040 System.Threading.Tasks.dll
-a----         12/2/2022     19:15          16040 System.Threading.Tasks.Extensions.dll
-a----         12/2/2022     19:16          20648 System.Threading.Tasks.Parallel.dll
-a----         12/2/2022     19:16          23720 System.Threading.Thread.dll
-a----         12/2/2022     19:16          19112 System.Threading.ThreadPool.dll
-a----         12/2/2022     19:16          15496 System.Threading.Timer.dll
-a----         12/2/2022     19:04          17032 System.Transactions.dll
-a----         12/2/2022     19:15          25768 System.Transactions.Local.dll
-a----         12/2/2022     19:15          16040 System.ValueTuple.dll
-a----         12/2/2022     19:05          16016 System.Web.dll
-a----         12/2/2022     19:15          18048 System.Web.HttpUtility.dll
-a----         12/2/2022     19:04          16520 System.Windows.dll
-a----         12/2/2022     19:15          24208 System.Xml.dll
-a----         12/2/2022     19:05          16528 System.Xml.Linq.dll
-a----         12/2/2022     19:16         115856 System.Xml.ReaderWriter.dll
-a----         12/2/2022     19:04          16528 System.Xml.Serialization.dll
-a----         12/2/2022     19:16          34984 System.Xml.XDocument.dll
-a----         12/2/2022     19:16          16016 System.Xml.XmlDocument.dll
-a----         12/2/2022     19:16          51344 System.Xml.XmlSerializer.dll
-a----         12/2/2022     19:16          17552 System.Xml.XPath.dll
-a----         12/2/2022     19:16          17576 System.Xml.XPath.XDocument.dll
-a----         12/2/2022     19:56          17064 WindowsBase.dll

Here is my repo on the current commit: https://github.com/paranext/paranext-core/tree/d1a6a02d48602283ff7b4b542c505f9503593ec7

Thank you very much for the help! Please let me know if you have any ideas.

EDIT: I printed the stack trace of the edge code where it was throwing this "parent does not exist" stuff (note that 'electronAPI.edge.invoke' is the ipc channel for edge stuff as I have change to using a preload and nodeIntegration off. As such, the edge code is running in main.ts):

Error invoking remote method 'electronAPI.edge.invoke': Error: System.TypeLoadException: Could not load type 'System.Object' from assembly 'System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e' because the parent does not exist.

Stack Trace:
   at System.Reflection.RuntimeAssembly.GetType(RuntimeAssembly assembly, String name, Boolean throwOnError, Boolean ignoreCase, ObjectHandleOnStack type)
   at System.Reflection.RuntimeAssembly.GetType(String name, Boolean throwOnError, Boolean ignoreCase)
   at ClrFuncReflectionWrap.Create(Assembly assembly, String typeName, String methodName)
   at ClrFunc.Initialize(FunctionCallbackInfo<v8::Value>* info).

This exception is thrown during edge.func as I have here (in my main.ts file):

edge.func({
      assemblyFile: baseDll,
      typeName: `${ns}.${className}`,
      methodName: method,
    })

I have tried importing edge with require as in the quickstart and with import('electron-edge-js') as a dynamic import (with edge.func waiting until the dynamic import is finished. I have tried setting the .csproj dependencies to the same as in the quickstart.

Because the standalone instructions in edge.js's readme say to use netcoreapp2.1, I have also tried that. Strangely, I get a slightly different exception as follows:

Error invoking remote method 'electronAPI.edge.invoke': Error: System.BadImageFormatException: Could not load file or assembly 'System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e' or one of its dependencies. An attempt was made to load a program with an incorrect format.

Stack Trace:
   at System.Reflection.RuntimeAssembly.GetType(RuntimeAssembly assembly, String name, Boolean throwOnError, Boolean ignoreCase, ObjectHandleOnStack type)
   at System.Reflection.RuntimeAssembly.GetType(String name, Boolean throwOnError, Boolean ignoreCase)
   at ClrFuncReflectionWrap.Create(Assembly assembly, String typeName, String methodName)
   at ClrFunc.Initialize(FunctionCallbackInfo<v8::Value>* info).

I also ran the production build while logging some kind of dll interaction using a tool called Fusion++, and that indicated an error with edge_nativeclr:

Fusion++ edge_nativeclr error full log
*** Assembly Binder Log Entry  (1/26/2023 @ 12:16:16) ***

The operation failed.
Bind result: hr = 0x80070002. The system cannot find the file specified.

Assembly manager loaded from:  C:\Windows\Microsoft.NET\Framework64\v4.0.30319\clr.dll
Running under executable  C:\Users\tj_co\source\repos\paranext-core\release\build\win-unpacked\ParanextCore.exe
--- A detailed error log follows. 

=== Pre-bind state information ===
LOG: DisplayName = edge_nativeclr, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
 (Fully-specified)
LOG: Appbase = file:///C:/Users/tj_co/source/repos/paranext-core/release/build/win-unpacked/
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = ParanextCore.exe
Calling assembly : (Unknown).
===
LOG: This bind starts in default load context.
LOG: Download of application configuration file was attempted from file:///C:/Users/tj_co/source/repos/paranext-core/release/build/win-unpacked/ParanextCore.exe.config.
LOG: Configuration file C:\Users\tj_co\source\repos\paranext-core\release\build\win-unpacked\ParanextCore.exe.config does not exist.
LOG: No application configuration file found.
LOG: Using host configuration file: 
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Attempting download of new URL file:///C:/Users/tj_co/source/repos/paranext-core/release/build/win-unpacked/edge_nativeclr.DLL.
LOG: Attempting download of new URL file:///C:/Users/tj_co/source/repos/paranext-core/release/build/win-unpacked/edge_nativeclr/edge_nativeclr.DLL.
LOG: Attempting download of new URL file:///C:/Users/tj_co/source/repos/paranext-core/release/build/win-unpacked/edge_nativeclr.EXE.
LOG: Attempting download of new URL file:///C:/Users/tj_co/source/repos/paranext-core/release/build/win-unpacked/edge_nativeclr/edge_nativeclr.EXE.
LOG: All probing URLs attempted and failed.



*** Assembly Binder Log Entry  (1/26/2023 @ 12:16:16) ***

The operation failed.
Bind result: hr = 0x80070002. The system cannot find the file specified.

Assembly manager loaded from:  C:\Windows\Microsoft.NET\Framework64\v4.0.30319\clr.dll
Running under executable  C:\Users\tj_co\source\repos\paranext-core\release\build\win-unpacked\ParanextCore.exe
--- A detailed error log follows. 

=== Pre-bind state information ===
LOG: DisplayName = edge_nativeclr, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
 (Fully-specified)
LOG: Appbase = file:///C:/Users/tj_co/source/repos/paranext-core/release/build/win-unpacked/
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = ParanextCore.exe
Calling assembly : (Unknown).
===
LOG: This bind starts in default load context.
LOG: Download of application configuration file was attempted from file:///C:/Users/tj_co/source/repos/paranext-core/release/build/win-unpacked/ParanextCore.exe.config.
LOG: Configuration file C:\Users\tj_co\source\repos\paranext-core\release\build\win-unpacked\ParanextCore.exe.config does not exist.
LOG: No application configuration file found.
LOG: Using host configuration file: 
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Attempting download of new URL file:///C:/Users/tj_co/source/repos/paranext-core/release/build/win-unpacked/edge_nativeclr.DLL.
LOG: Attempting download of new URL file:///C:/Users/tj_co/source/repos/paranext-core/release/build/win-unpacked/edge_nativeclr/edge_nativeclr.DLL.
LOG: Attempting download of new URL file:///C:/Users/tj_co/source/repos/paranext-core/release/build/win-unpacked/edge_nativeclr.EXE.
LOG: Attempting download of new URL file:///C:/Users/tj_co/source/repos/paranext-core/release/build/win-unpacked/edge_nativeclr/edge_nativeclr.EXE.
LOG: All probing URLs attempted and failed.

Reproduced from the error log is the following critical piece:

LOG: Attempting download of new URL file:///C:/Users/tj_co/source/repos/paranext-core/release/build/win-unpacked/edge_nativeclr.DLL.
LOG: Attempting download of new URL file:///C:/Users/tj_co/source/repos/paranext-core/release/build/win-unpacked/edge_nativeclr/edge_nativeclr.DLL.
LOG: Attempting download of new URL file:///C:/Users/tj_co/source/repos/paranext-core/release/build/win-unpacked/edge_nativeclr.EXE.
LOG: Attempting download of new URL file:///C:/Users/tj_co/source/repos/paranext-core/release/build/win-unpacked/edge_nativeclr/edge_nativeclr.EXE.
LOG: All probing URLs attempted and failed.

I suppose edge_nativeclr.DLL and edge_nativeclr.EXE are some kind of intermediate files because I cannot find them anywhere. I don't know if this is helpful information, but I figured I would include it in case it means something to you. :)

@harlankoehn
Copy link
Author

In my case we resorted to building a console app which references our DLL. Then we have to call that console application with some parameters from within Electron. We were able to package the console application as a stand alone executable but we had to use the Publish feature in Visual Studio to get it to bundle correctly into one file. Nothing ideal about what we resorted to but it does work.

@agracio agracio closed this as completed Mar 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants