Electron.net: Namespace ElectronNET could not be found

Created on 9 Dec 2018  路  2Comments  路  Source: ElectronNET/Electron.NET

Hello,

I was looking at trying Electron.NET for the purposes of building an x-plat app in a language (C#) that I'm familiar with.

I followed the guide in the readme - Installed the global tooling, created a new MVC app, installed the ElectronNET.API nuget package, made the appropriate changes to Program.cs and Startup.cs, and ran electronize init.

Here's output from electronize init:

PM> electronize init
Adding our config file to your project...
Search your .csproj to add the needed electron.manifest.json...
Found your .csproj: C:\Users\Foxtrek_64\Documents\Projects\LuzFaltex\Launcher.FotC\Launcher.FotC.csproj - check for existing config or update it.
electron.manifest.json will be added to csproj.
electron.manifest.json added in csproj!
Search your .launchSettings to add our electron debug profile...
Debug profile added!
Everything done - happy electronizing!

After this, I was ready to start. Since this is just to see it run, I thought I'd use the built-in web page that tells you all about IIS. So to start, I ran electronize start. Here's the output from that:

PM> electronize start
Start Electron Desktop Application...
Microsoft Windows [Version 10.0.17134.376]
(c) 2018 Microsoft Corporation. All rights reserved.
C:\Users\Foxtrek_64\Documents\Projects\LuzFaltex\Launcher.FotC>dotnet publish -r win-x64 --output "C:\Users\Foxtrek_64\Documents\Projects\LuzFaltex\Launcher.FotC\obj\Host\bin"
Microsoft (R) Build Engine version 15.9.20+g88f5fadfbe for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.
  Restoring packages for C:\Users\Foxtrek_64\Documents\Projects\LuzFaltex\Launcher.FotC\Launcher.FotC.csproj...
  Generating MSBuild file C:\Users\Foxtrek_64\Documents\Projects\LuzFaltex\Launcher.FotC\obj\Launcher.FotC.csproj.nuget.g.props.
  Generating MSBuild file C:\Users\Foxtrek_64\Documents\Projects\LuzFaltex\Launcher.FotC\obj\Launcher.FotC.csproj.nuget.g.targets.
  Restore completed in 2.09 sec for C:\Users\Foxtrek_64\Documents\Projects\LuzFaltex\Launcher.FotC\Launcher.FotC.csproj.
Program.cs(6,7): error CS0246: The type or namespace name 'ElectronNET' could not be found (are you missing a using directive or an assembly reference?) [C:\Users\Foxtrek_64\Documents\Projects\LuzFaltex\Launcher.FotC\Launcher.FotC.csproj]
Startup.cs(5,7): error CS0246: The type or namespace name 'ElectronNET' could not be found (are you missing a using directive or an assembly reference?) [C:\Users\Foxtrek_64\Documents\Projects\LuzFaltex\Launcher.FotC\Launcher.FotC.csproj]
C:\Users\Foxtrek_64\Documents\Projects\LuzFaltex\Launcher.FotC>
Error occurred during dotnet publish: 1

After a bit of investigation, I found that the dotnet publish command runs a dotnet restore, which removes the ElectronNET.API nuget package. In other words, the build process removes the API and then complains that it couldn't find it.

I've asked around in a C# group that I'm in but we were unable to diagnose this behavior. We did break down a few of the steps and we found that running dotnet restore did indeed remove the package, though its output doesn't represent that:

PM> dotnet restore
  Restoring packages for C:\Users\Foxtrek_64\Documents\Projects\LuzFaltex\Launcher.FotC\Launcher.FotC.csproj...
  Generating MSBuild file C:\Users\Foxtrek_64\Documents\Projects\LuzFaltex\Launcher.FotC\obj\Launcher.FotC.csproj.nuget.g.props.
  Generating MSBuild file C:\Users\Foxtrek_64\Documents\Projects\LuzFaltex\Launcher.FotC\obj\Launcher.FotC.csproj.nuget.g.targets.
  Restore completed in 1.95 sec for C:\Users\Foxtrek_64\Documents\Projects\LuzFaltex\Launcher.FotC\Launcher.FotC.csproj.

Any assistance on this issue would be appreciated. I would rather like to see this work.


Edit: I seem to have made a very strange discovery. Running electronize start from PowerShell makes it past the restore successfully. After installing Node.js (doh!), I was able to get the app to start successfully.

So, I pose this question to you: why did this task fail when running under the Package Manager Console but when running under PowerShell it worked just fine?

Also, as an interesting note, despite the documentation saying dotnet electronize ..., attempting to run that results in an error stating No executable found matching command "dotnet-electronize". When I installed electronize, it told me to use it as just electronize, so that's what I've been doing. Is this a result of outdated documentation?

Here's a screenshot of the working app:
image

Most helpful comment

I had this same problem with the build process removing the Electronize.API package. The solution I found was that electronize didn't like the way Visual Studio installed it. To fix this, I just installed it from the terminal.

dotnet add package ElectronNET.API

And it worked like a charm.

All 2 comments

We updated the readme - don't use "dotnet electronize" instead use just "electronize".

Hope this helps!

I had this same problem with the build process removing the Electronize.API package. The solution I found was that electronize didn't like the way Visual Studio installed it. To fix this, I just installed it from the terminal.

dotnet add package ElectronNET.API

And it worked like a charm.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

AykutToprak picture AykutToprak  路  4Comments

GregorBiswanger picture GregorBiswanger  路  4Comments

Marcelh1983 picture Marcelh1983  路  5Comments

ernestotw85 picture ernestotw85  路  3Comments

iqmeta picture iqmeta  路  3Comments