• Stars
    star
    103
  • Rank 322,527 (Top 7 %)
  • Language
    C#
  • License
    MIT License
  • Created about 4 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

ComWrappers required to run NativeAOT and WinForms

ComWrappers required to run NativeAOT and WinForms

This repository has ComWrappers implementation for WinForms. In additional to that, it allow use WinForms and NativeAOT and R2R with trimming together.

Getting started

Just add WinFormsComInterop to your project.

dotnet add package WinFormsComInterop

Then to your Program.cs add following line

ComWrappers.RegisterForMarshalling(WinFormsComInterop.WinFormsComWrappers.Instance);

And modify project file to enable NativeAOT

<PublishAot>true</PublishAot>
<_SuppressWinFormsTrimError>true</_SuppressWinFormsTrimError>

If you application will works with this ComWrappers implementation, then most likely it would work with NativeAOT.

If you are using WebView2 using Microsoft.Web.WebView2.Core package, then use

ComWrappers.RegisterForMarshalling(WinFormsComInterop.WebView2.WebView2ComWrapper.Instance);

Also

  1. Add <PackageReference Include="Microsoft.Web.WebView2" Version="1.0.1462.37" /> as depedency. This library would work only starting from this version of WebView2 package.
  2. Add RD.xml file from https://github.com/kant2002/RdXmlLibrary/blob/main/Microsoft.AspNetCore.Components.Web.rd.xml to project
  3. Add <RdXmlFile Include="Microsoft.AspNetCore.Components.Web.rd.xml" /> to project file
  4. Make sure that RootComponets are added to you app-specific rd.xml
<?xml version="1.0" encoding="utf-8" ?>
<Directives>
  <Application>
    <Assembly Name="YourAppAssembly" Dynamic="Required All">
      <Type Name="YourAppAssembly.YourRootComponent" Dynamic="Required All" />
    </Assembly>
  </Application>
</Directives>

Testing technology

Test that normal CoreCLR works

dotnet run --project samples\SampleWindowsForms\SampleWindowsForms.csproj
dotnet run --project experiments\WpfTestBed\WpfTestBed.csproj
dotnet run --project experiments\WinUITestBed\WinUITestBed\WinUITestBed.csproj
dotnet run --project experiments\WinUIUWP\WinUIUWP.csproj

NativeAOT

Test that NativeAOT works. Run commands in x64 developer tools.

WinForms

dotnet publish -r win-x64 samples\SampleWindowsForms\SampleWindowsForms.csproj
"samples\SampleWindowsForms\bin\x64\Debug\net6.0-windows\win-x64\publish\SampleWindowsForms.exe"

Below are experimental projects. They are need additional work.

WPF

dotnet publish -r win-x64 experiments\WpfTestBed\WpfTestBed.csproj -p:GenerateWPF=true

blocked by #30

WinUI

dotnet publish -r win10-x64 experiments\WinUITestBed\WinUITestBed\WinUITestBed.csproj

Classic UWP project

dotnet publish -r win-x64 experiments\WinUIUWP\WinUIUWP.csproj

does not working due to this error

experiments\WinUIUWP\WinUIUWP.csproj : error MSB4057: The target "Restore" does not exist in the project.

For brave souls

Mostly notes for me, but maybe somebody would like to hack.

Build (NativeAOT)[https://github.com/dotnet/runtimelab/tree/feature/NativeAOT].

Modify nuget.config

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <packageSources>
    <!--To inherit the global NuGet package sources remove the <clear/> line below -->
    <clear />
    <!--Locally built version of NativeAOT -->
    <add key="ILC" value="c:\runtimelab\artifacts\packages\Debug\Shipping\" />
    <!--To use daily builds of runtime -->
    <add key="dotnet6" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet6/nuget/v3/index.json" />
  </packageSources>
</configuration>

Restore packages to local folder to not pollute global Nuget cache. You will build NativAOT a lot.

dotnet restore -r win-x64 --packages packages

Then publish applications using regular workflow described above.

Additional reading

Design of future stubs in Runtime

More Repositories

1

FSharpPacker

Packs FSX files into executable
Nix
42
star
2

ncrawler

Web Crawler written in C#
C#
40
star
3

SourceGeneratorsKit

Utility library for faster writing source generators
C#
39
star
4

SqlMarshal

Generates data access using stored procedures
C#
36
star
5

RdXmlLibrary

Library of RD.xml files for NativeAOT
C#
29
star
6

Ghidra

As it is obvious from the name this is version of NSA Ghidra which actually could be built from sources
Java
24
star
7

steamhammer

This is repository to keep track of API changes in the SteamHammer BWAPI bot
C++
11
star
8

AspNetCore.Helpers

.NET Core port for the System.Web.Helpers
C#
9
star
9

NativeAOTDocker

C#
8
star
10

FStarMSBuildSdk

F* MSBuild SDK
F*
6
star
11

fstarsample

Sample how to perform export of F* to F# with Nuget
F*
6
star
12

NativeAOTImages

Example how to work with images in NativeAOT context
C#
5
star
13

msbuildtranslator

C#
5
star
14

storekeeper

AOT friendly dependency injection
C#
4
star
15

MstatAnalyser

Provides statistic information about NativeAOT filesize
C#
4
star
16

NativeAOTWasm

Sample for WASM and NativeAOT
HTML
4
star
17

scm2txt

Starcraft maps converter
C++
4
star
18

Dub

Application framework for speedier development of the SaaS application
C#
4
star
19

nativeaotwasi

WASI tests for NativeAOT-LLVM
C#
4
star
20

CoMallocNativeAot

C#
3
star
21

web-aot

Web application using NativeAOT
C#
3
star
22

cordova-plugin-navigation-menu

Provides platform specific menu for the Cordova
JavaScript
3
star
23

crowdin-cli

Node.js CLI tool for the CrowdIn
JavaScript
3
star
24

fsharp-kernel-ua

.NET Polyglot ядро для мови Ф#
F#
2
star
25

xdds

Performance test: XDDs per second
C#
2
star
26

cordova-plugin-screen-orientation

Plugin for Apache Cordova which allows to manipulate orientation of the devices's screen programmatically
Java
2
star
27

pascalabcsample

Hello world for PascalABC.Net
Pascal
2
star
28

sscait-tools

Analysis scripts for the SSCAIT
F#
2
star
29

numbers-db

Dataset of numbers in different languages in machine processable format
2
star
30

polymer-nuget

NuGet package for the Polymer project
PowerShell
1
star
31

NKalkan

Библиотека для работы с криптопровайдером АО "НУЦ" KalkanCrypt
C#
1
star
32

blazor-webidl-gen

Generator for Blazor Interop using WebIDL
C#
1
star
33

ExcelDataReaderCodePageIssue

Test repro for https://github.com/ExcelDataReader/ExcelDataReader/pull/344
C#
1
star
34

gulp-ts-swagger

Swagger generator for TypeScript
TypeScript
1
star
35

MvcDIMemoryLeak

Simple application which show how MS DI gives problem with MVC + OWIN
JavaScript
1
star
36

tdsharp-samples

Samples for TDSharp
C#
1
star
37

EngLang

Compiler for subset of English
C#
1
star
38

nativeaot-commandline

Adding support for command line arguments in custom .NET runtime
C#
1
star
39

JitDumpAnalyser

Analyzer application for CoreCLR JIT dumps
C#
1
star
40

cordova-plugin-imei

IMEI plugin for the Cordova
1
star
41

screeps-bot

Bot for the Screeps game (http://www.screeps.com/)
JavaScript
1
star
42

webidl-csharp

C# WebIDL parsing library
C#
1
star
43

SimpleIdentity

C#
1
star
44

fsharp-ua-notebook

.NET Polyglot ядро для мови Ф# у My Binder
Jupyter Notebook
1
star
45

FSharpKeywordTranslator

Helper application to translate keywords for F#
JavaScript
1
star
46

MSBuildScript-sample

Sample for MSBuild projects unrolled to C#
C#
1
star
47

RuckusSpotApi

The C# API for Ruckus SPoT
C#
1
star