Namespace ElectronNET could not be found #238

Closed
opened 2026-01-29 16:34:31 +00:00 by claunia · 3 comments
Owner

Originally created by @TheBrambleShark on GitHub (Dec 9, 2018).

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

Originally created by @TheBrambleShark on GitHub (Dec 9, 2018). 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](https://user-images.githubusercontent.com/7003081/49693840-85256080-fb43-11e8-97c4-b84fda29fb80.png)
Author
Owner

@robertmuehsig commented on GitHub (Jan 1, 2019):

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

Hope this helps!

@robertmuehsig commented on GitHub (Jan 1, 2019): We updated the readme - don't use "dotnet electronize" instead use just "electronize". Hope this helps!
Author
Owner

@MiffOttah commented on GitHub (Jul 3, 2019):

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.

@MiffOttah commented on GitHub (Jul 3, 2019): 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.
Author
Owner

@Succubussix commented on GitHub (Sep 23, 2022):

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.

this still exist until this days. xD this should be in the readme xD It took a lot of try cant figure it out why is it uninstall itself xD

@Succubussix commented on GitHub (Sep 23, 2022): > 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. this still exist until this days. xD this should be in the readme xD It took a lot of try cant figure it out why is it uninstall itself xD
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/Electron.NET#238