Porting an IE Extension to a WebAssembly - asp.net

I have developed an extension for Internet Explorer in C# using Visual Studio .Net 4.5.2 Framework which I would like to port to Chrome & Edge (Chromium). It is quite a sophisticated extension that comprises 6 bespoke C# libraries I have developed which in turn use a number of system libraries including Microsoft.mshtml & System.Windows.Forms. I am hoping that building out as a WebAssembly will prove a viable solution.
I tried porting to .Net 5.0 using Visual Studio 2019 with Windows.Wasm and also using Mono.Wasm but these have simply thrown up a succession of compatibility challenges.
Can anyone recommend alternative approaches I should look at. I am considering trying Blazor (although this appears to be more orientated towards server-side than client-side), Ooui.Wasm and Uno platform.
Regards,
Howard

Blazor has two different types of projects, one is Blazor Server App, which is obviously server side, and another one is Blazor WebAssembly App, which can be used to develop client side browser extension.
I too, has the intention to create browser extension using Blazor and so I created a package to help others achieve the same too. Feel free to checkout my repo on GitHub on how to do it.
This package includes the ability to interact with the WebExtensions API for cross browser compatibility. A browser APi polyfill developed by Mozilla is also loaded so that you can use WebExtensions API in Chrome too.
However in your scenario, with Blazor it is not possible to use WinForms so you will have to convert them to Razor components.

Related

Angular template NOT core

I'm looking for an Angular template for Visual Studio 2017 but I do NOT want to use the Core libraries as that requires me to rebuild all my re-usable libraries etc., and I will NEVER host my website on a non Microsoft platform (likely to put it into Azure only).
It would be nice if sign up / sign in is included.
I've tried to "convert" a core project to classic ASP .Net website with a "hack" mentioned on SO but encountered MANY issues
Any suggestions would be appreciated
Maybe you find a suitable template in the sidewaffle extension (http://sidewaffle.com/)

Is it possible to make desktop GUI application in .NET Core?

I have been developing Windows Forms programs for few years. I am now looking into .NET Core (including ASP.NET Core MVC). I am searching for the new GUI desktop technology. In Visual Studio 2015 update 3 I can't see any option to make a GUI app in .NET Core.
What am I missing?
You were not missing anything. Microsoft shipped no reasonable way to create GUI applications directly using .NET Core until .NET Core 3, though UWP (Universal Windows Platform) is partially built on top of .NET Core.
.NET Core 3.0 includes support for Windows Forms and WPF, though it is Windows-only.
.NET 6 will include .NET MAUI, which will support Windows and macOS desktop applications and mobile applications, with Linux desktop applications supported by the community (not MS). .NET 5 will include a preview version of .NET MAUI.
For third-party cross platform options, see other answers.
AvaloniaUI now has support for running on top of .NET Core on Windows, OS X, and Linux. XAML, bindings and control templates included.
E.g. to develop on macOS with Rider:
Follow instructions to install the Avalonia dotnet new templates
Open JetBrains Rider and from the Welcome screen,
Choose New Solution → (near the top of the Templates List) → More Templates → Button Install Template...* → browse to the directory where you cloned the templates at step 1.
Click the Reload Button
Behold! Avalonia Templates now appear in the New Solution Templates List!
Choose an Avalonia template
Build and run. See the GUI open before your eyes.
You could use Electron and wire it up with Edge.js resp. electron-edge. Edge.js allows Electron (Node.js) to call .NET DLL files and vice versa.
This way you can write the GUI with HTML, CSS and JavaScript and the backend with .NET Core. Electron itself is also cross platform and based on the Chromium browser.
It is now possible to use Qt, QtQuick, and QML with .NET Core, using Qml.Net.
It is highly performant (not "P/Invoke chatty"), fully featured and works across Linux, OS X, and Windows.
Check out my blog post to see how it compares to the other options out there currently.
PS: I'm the author.
For creating a console-based UI, you can use gui.cs. It is open-source (from Miguel de Icaza, creator of Xamarin), and runs on .NET Core on Windows, Linux, and macOS.
It has the following components:
Buttons
Labels
Text entry
Text view
Time editing field
Radio buttons
Checkboxes
Dialog boxes
Message boxes
Windows
Menus
ListViews
Frames
ProgressBars
Scroll views and Scrollbars
Hexadecimal viewer/editor (HexView)
Sample screenshot
One option would be using Electron with JavaScript, HTML, and CSS for UI and build a .NET Core console application that will self-host a web API for back-end logic. Electron will start the console application in the background that will expose a service on localhost:xxxx.
This way you can implement all back-end logic using .NET to be accessible through HTTP requests from JavaScript.
Take a look at this post, it explains how to build a cross-platform desktop application with Electron and .NET Core and check code on GitHub.
Yes, it is possible.
.NET Core doesn't have any components for native GUI application out of the box. However, there is a NuGet package for it that is called Electron.NET, as per Gregor Biswanger's answer.
Electron is a framework that allows you to build native GUI applications on top of Node.js. Electron.NET is a NuGet package that allows you to utilise Electron and Node.js from within your .NET Core code.
The good news is that you don't have to learn JavaScript, Electron or Node.js in order to be able to use the NuGet package. JS files do run inside your application, but they get automatically generated by the build process.
All you do is build a pretty standard ASP.NET Core MVC app. The only difference is that, instead of running in the browser, it runs as a native windowed app. Besides just a few lines of code specific to the Electron.NET package, you won't need to learn anything above ASP.NET Core MVC.
This page provides a tutorial on how to use it. It also contains some links to sample code repositories.
.NET Core 3 will have support for creating Windows desktop applications. I watched a demo of the technology yesterday during the .NET Conference.
This is the only blog post I could find, but it does illustrate the point: .NET Core 3 and Support for Windows Desktop Applications
I'm working on a project that might help: https://github.com/gkmo/CarloSharp
The following application is written in .NET with the UI in HTML, JavaScript, and CSS (Angular).
tl;dr - I'm not sure that it would be possible for the .NET Core developers to supply a cross-platform GUI framework.
I feel like expecting a cross-platform GUI framework to be bundled into the official tooling (especially an old version of the tooling - you mention that you're running Visual Studio 2015 update 3) for an early version of .NET Core is a little premature.
GUI frameworks are really quite heavy, and dependent on the hardware abstractions already present on the host machine. On Windows, there is generally a single window manager (WM) and desktop environment (DE) used by most users, but on the many different distributions of Linux which are supported, there are any number of possible WMs and DEs - granted most users will either be using X-Server or Wayland in combination with KDE, GNOME or Xfce. But no Linux installation ever is the same.
The fact that the open source community can't really settle on a "standard" setup for a VM and DE means that it would be pretty difficult for the .NET Core developers to create a GUI framework which would work across all platforms and combinations of DEs and WMs.
A lot of folks here have some great suggestions (from use ASP.NET Core to builds a Web application and use a browser to listing a bunch of cross-platform frameworks). If you take a look at some of the mentioned cross platform GUI frameworks listed, you'll see how heavy they are.
However, there is light at the end of the tunnel as Miguel de Icaza showed off Xamarin running naively on Linux and macOS at .NET Conf this year (2017, if you're reading this in the future), so it might be worth trying that when it's ready.
(But you'll need to upgrade from Visual Studio 2015 to Visual Studio 2017 to access the .NET Core 2.0 features.)
You could develop a web application with .NET Core and MVC and encapsulate it in a Windows universal JavaScript app: Progressive Web Apps on Windows
It is still a web application, but it's a very lightweight way to transform a web application into a desktop app without learning a new framework or/and redevelop the UI, and it works great.
The inconvenience is unlike Electron or ReactXP for example, the result is a universal Windows application and not a cross platform desktop application.
I have been searching for this for ages now and none of the solution above are to my satisfaction.
I ended up working with https://github.com/mellinoe/ImGui.NET for now.
I can confirm it works at least across macos and win10 and claims to be compatible with linux.
Leaving this here in case it can help someone.
It will be available using .NET 6:
https://devblogs.microsoft.com/dotnet/announcing-net-6-preview-1/
But you can already create WinForms applications using netcore 3.1 and net 5 (at least in Visual Studio 2019 16.8.4+).
For the special case of existing Windows Forms applications:
There is a way - though I don't know how well it works.
It goes like this:
Take the Windows Forms implementation from Mono.
Port it to .NET Core or NetStandard.
Recompile your Windows Forms applications against the new System.Windows.Forms.
Fix anything that may be broken by .NET Core.
Pray that mono implements the parts you need flawlessly.
(If it doesn't, you can always stop praying, and send the Mono project a pull request with your fix/patch/feature.)
Here's my CoreFX Windows Forms repository:
https://github.com/ststeiger/System.CoreFX.Forms
Yes, it is possible to develop cross-platform desktop (GUI) applications, for Windows, Linux and macOS, using Visual Studio Code, .NET Core, C#, GTK 3, gtksharp and Glade as the GUI designer.
Here is how.
Windows Forms (and its visual designer) have been available for .NET Core (as a preview) since Visual Studio 2019 16.6. It's quite good, although sometimes I need to open Visual Studio 2019 16.7 Preview to get around annoying bugs.
See this blog post: Windows Forms Designer for .NET Core Released
Also, Windows Forms is now open source: https://github.com/dotnet/winforms
If you are using .NET Core 3.0 and above, do the following steps and you are good to go: (I'm going to use .NET Core CLI, but you can use Visual Studio too):
md MyWinFormsApp optional step
cd MyWinFormsApp optional step
dotnet new sln -n MyWinFormsApp optional step, but it's a good idea
dotnet new winforms -n MyWinFormsApp I'm sorry, this is not optional
dotnet sln add MyWinFormsApp do this if you did step #3
Okay, you can stop reading my answer and start adding code to the MyWinFormsApp project. But if you want to work with Form Designer, keep reading.
Open up MyWinFormsApp.csproj file and change <TargetFramework>netcoreapp3.1<TargetFramework> to <TargetFrameworks>net472;netcoreapp3.1</TargetFrameworks> (if you are using netcoreapp3.0 don't worry. Change it to <TargetFrameworks>net472;netcoreapp3.0</TargetFrameworks>)
Then add the following ItemGroup
<ItemGroup Condition="'$(TargetFramework)' == 'net472'">
<Compile Update="Form1.cs">
<SubType>Form</SubType>
</Compile>
<Compile Update="Form1.Designer.cs">
<DependentUpon>Form1.cs</DependentUpon>
</Compile>
</ItemGroup>
After doing these steps, this is what you should end up with:
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFrameworks>net472;netcoreapp3.1</TargetFrameworks>
<UseWindowsForms>true</UseWindowsForms>
</PropertyGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net472'">
<Compile Update="Form1.cs">
<SubType>Form</SubType>
</Compile>
<Compile Update="Form1.Designer.cs">
<DependentUpon>Form1.cs</DependentUpon>
</Compile>
</ItemGroup>
</Project>
Open up file Program.cs and add the following preprocessor-if
#if NETCOREAPP3_1
Application.SetHighDpiMode(HighDpiMode.SystemAware);
#endif
Now you can open the MyWinFormsApp project using Visual Studio 2019 (I think you can use Visual Studio 2017 too, but I'm not sure) and double click on Form1.cs and you should see this:
Okay, open up Toolbox (Ctrl + W, X) and start adding controls to your application and make it pretty.
You can read more about designer at Windows Forms .NET Core Designer.

Can we compile an asp.net 5 application by .net native?

The role of .net native in .net ecosystem is confusing for me. I heard it is just for universal windows applications, but also heard that it is part of CoreFX. I think having the option to compile to .net native can have many advantages (including performance).
Is it possible to compile my asp.net application (specially asp.net 5) to .net native?
No, you cannot. Right now, .NET Native is not for ASP.NET. I believe it's only for Universal Windows Applications. That doesn't mean that one day it won't be available, but right now it's not planned.
See related GitHub issue where ASP.NET team confirms this.
Edit 11/27/2015
Since this was posted, Microsoft has made further announcements regarding .NET Native and .NET Core. I suggest you check out Scott Hanselman's part of the keynote from the Microsoft Connect 2015 event. At the 11:22 minute mark of this excerpt video Scott shows compiling an .NET app to native code and then running it. He says it's "future work" so it appears it's not quite ready yet (I believe one of the Q&A videos from the event explained that it's in one of the dev branches on GitHub, but I'm too lazy to rewatch all the videos for you at the moment). It was unclear if this is only working for console apps at the moment or if it will run ASP.NET.
As Thomas says in comments, this should be possible once LLILC is out. It targets .NET Core which is what ASP.NET 5 runs on. I am not sure if the resulting runtime can be called .NET Native per say but LLILC do has plans to natively compile IL (e.g. output by Roslyn) ahead-of-time.
Another option is ASP.NET running on CoreRT by using RyuJIT as AOT compiler. This looks closer to reality today than LLILC. Have seen some experiments in compiling ASP.NET project on CoreRT but nothing that actually works.
[.NET Native makes use of UTC compiler which compiles to run on some C++ runtime (MRT - either minimal runtime or managed runtime, cant remember, also known as Native runtime). Currently the .NET Native UWP apps are windows specific. Though .NET Native and UWP are advertised under .NET Core, this could be misleading as only in debug mode UWP targets CoreCLR, in release mode it targets native runtime which is Windows specific. LLILC/CoreRT should change that.]

Activating the in built web camera on a laptop in .NET

I want to activate the built-in web camera on a laptop for my application using .NET.
Is there any method that I can get this done in visual studio 2010?
The article here shows how you might do so using DirectShow and .NET
But ...
DirectShow on Windows Server 2008 (& R2) is fraught with problems so you might want to consider a different solution if this is the target OS
Touchless SDK (http://touchless.codeplex.com/releases/view/17986) contains a generic DLL for accessing webcams. Some of the cams, like the Toughbook, require accessing their own API. The Toughbook also has a downloadable SDK for their camera.
Are you talking about ASP.NET application? The answer is no unless you use some sort of activeX to be installed on the client browser.

can anyone define a stack for a ASP.NET Web forms application?

what is the stack for a asp.net Web forms application?and why?
example for ASP.NET MVC there is an example:
http://codeclimber.net.nz/archive/2009/10/15/my-asp.net-mvc-stack-and-why-i-chosen-it.aspx
thanks
To be perfectly honest, this depends a lot on the specific project you plan to build with WebForms. Since I'm newer to MVC, I do just about all of my .NET development with WebForms. So here's the "stack" (framework + tools + components) that I use when building an application:
Framework
Obviously, ASP.NET WebForms. I make sure to keep all of my different layers (presentation layer - aspx webform, business logic - aspx.vb/aspx.cs codebehind, data access layer - additional classes) separate while I'm building.
Tools
Visual Studio 2010 - I dare you to find a better tool for developing a .NET-based web application.
SQL Management Studio Express - Fantastic tool for managing your database setup
TortoiseSVN - Subversion tool that integrates directly into Windows' contextual file menus. It's great for quickly committing/reverting projects!
BugTracker.NET - Great bug tracking tool that integrates with TortoiseSVN.
Libraries
jQuery - I use this for everything
jQuery UI - Great for adding "squishy" user interface elements and building out more interactive web forms
Flexigrid - I use this for building datagrid elements on my sites. Since it's built with jQuery, it interfaces nicely and handles AJAX data loads remarkably well.
YUI - Another JavaScript library that's great for animations and transitions.
Testing
Visual Studio Debugger - fantastic for stepping through server-side code to make sure things are working
Firebug - Firefox extension - Absolutely essential for debugging client-side scripts and for identifying HTML/CSS errors
IETester - Useful for anyone supporting commercial clients (who might still be using IE6)
For deployment, I use a set of custom tools that create unique filenames for frequently changed files that will need to bypass a user's cache when they're changed - i.e. whenever a CSS or JS file is updated or I change an image, I'll append a unique string to the end of the filename so the browser re-fetches the file.
The stack we have where I work:
Visual Studio 2008 / SQL Server Management Studio Express 2005
Resharper - for helping with coding standards and practices
Subversion - for source control (Formerly had SourceSafe which I had used for years but Subversion is much much better IMO)
Cruise Control .Net - for continuous integration
nUnit/nAnt - for unit tests and automated builds
IIS 5.1 - The downside of still being on XP is that we have these old tools at times.
IIS Admin .Net 1.1 - For helping have multiple sites on one machine.
WatiN - for web-based tests when needed.
In terms of coding add-ons:
jQuery
Sitecore (This is our CMS and is huge in some ways)
Browsers, just to note the big ones here:
IE
Firefox
Chrome
Safari
Tools:
Dev environment -
Visual Studio 2010 Professional - quite an obvious choice given that the latest tool is a big improvement over 2008 edition, especially in terms of performance. There are a few quirks still (waiting for SP1!) but it is mostly a pleasant and productive experience.
SQL Management Studio Express - for DB management
Source control and Project Management - Team Foundation Server 2010 - really going all out with MS here, leveraging our Bizspark membership, TFS 2010 has cool new features including branching/merging, shelfing (vs checking in) and much better transactional integrity than VSS. Also the project management tools are pretty good - there are various templates you can choose depending on whether you want to go Agile, or traditional.
Mantis - for bug tracking, but we are phasing this out and trying to move to TFS. Figuring out how to migrate existing data though.
Libraries:
Asp.net Ajax - pretty cool for what we need, simple ajax effects are quite easy to achieve.
Testing:
MS Test - in built in Visual studio, much better than previous releases - Unit testing support is far better.
Debugging:
Visual Studio Debugger
IE Developer tools

Resources