Skip to main content
Legend
April 23, 2017
Question

FreSharp - Build Adobe Air Native Extensions using C#

  • April 23, 2017
  • 5 replies
  • 3468 views

While working on WebViewANE for Windows I wrapped FlashRuntimeExtensions in C++/CLI calls to allow me to more tightly integrate with C#.

I expanded this into a NuGet package to make writing ANEs in C# quicker.

Example - Convert a FREObject into a String, and String into FREObject

var inFre = argv[0];

try {

  var airString = new FreObjectSharp(inFre).GetAsString();

  Trace("String passed from AIR:" + airString);

}

catch (Exception e) {

  Trace(@"caught in C#: type: {0} message: {1}", e.GetType(), e.Message);

}

const string sharpString = "I am a string from C#";

return new FreObjectSharp(sharpString).Get();

Example - Call a method on an FREObject

var addition = person.CallMethod("add", new ArrayList

{

  new FreObjectSharp(100),

  new FreObjectSharp(33)

});

var sum = addition.GetAsInt();

Trace("result is: " + sum);

The source and example project is available on Github

https://github.com/tuarua/FreSharp

This topic has been closed for replies.

5 replies

el111Author
Legend
June 19, 2018

For anyone curious. Here is an example using FreSharp to hook into the new Windows ML feature.

It also shows how we can use UWP APIs in an ANE.

GitHub - tuarua/Windows-ML-ANE: This is a Windows AIR Native Extension to test Windows ML Preview.

fmontfort974
Participating Frequently
June 21, 2018

I definitly love your code and ideas on how to extend AIR with modern languages.

So many thanks.

SourceSkyBoxer
Known Participant
April 29, 2017

No It is not related to github tickets. It is finish. Only question about embedding dll into native extension dll. Than It doesn't need to required dlls - If who forgets to pack dlls into native installer. Thanks! Nice weekend!

SourceSkyBoxer
Known Participant
April 29, 2017

Thanks for explanation! I am trying FreSharpExampleANELib.dll in FreSharpExampleANE.dll via: AppDomain and ResolveEventHandler(myresolver); I already included FreSharpExampleANELib.dll from project and generates into standalone dll. Than Adobe Air crashed again. I know there separated dlls are easy. Example http://stackoverflow.com/questions/1978046/loading-interdependent-assemblies-from-c-cli Thanks I hope you try that. I already - How do I eventhandler from AppDomain from InitController() - Is it correct main function from initController()? I saw extern "C" {} If Initializer call "initController()" or starting main-function.

el111Author
Legend
April 29, 2017

Is this question still relevant?

I thought we resolved everything in the GitHub ticket?

SourceSkyBoxer
Known Participant
April 28, 2017

Thanks for answer - I have submitted issues to Github. I have tried because Adobe Air freeze if I use adl or generated native-installer. What is workaround for you? Is it correct for Adobe Air SDK 19.0? or last version? My details are Adobe Air SDK 24.0 and Net Frameworks 4.6.1. Show you my video! https://www.youtube.com/watch?v=dbyEAFxDzNE

el111Author
Legend
April 28, 2017

See my response on Github

SourceSkyBoxer
Known Participant
April 25, 2017

Nice idea! I am happy because I am working with C# and AS3. Yay! Hehe thanks for support! Please don't forget to release with Mono / Xamarin ( Mac, Android and iOS )! Because Adobe Air works same on Android, iOS and macOS. And for Linux? I think for packing into c drive image for wine under Ubuntu with Mono / Xamarin? I'm very happy because you have saved my life for CefSharp with Air App like nw.js and Electron. That is why it is great way with C#. PS: for Android, iOS and Mac need use CefMono ( Cef for unix-used library ) PS: How do I assign stage or nativewindow as owner from C#? Is it meaning for FreObjectSharp? Thanks for answer! Sorry for my bad English!

el111Author
Legend
April 25, 2017

You mention CefSharp. I built the Windows version of my WebViewANE using CefSharp. FreSharp grew out of that project.

Check it out in my github.

You will see here how I attached the Cef window to the AIR window.

WebViewANE/MainController.cs at master · tuarua/WebViewANE · GitHub

I am not familiar with Mono. It's important to note this will not allow you to create ANEs for iOS/OSX etc in C#.

It is Windows only.

For the iOS and OSX version of the WebViewANE I used Swift and the native WKWebview which is much lighter and quicker.

SourceSkyBoxer
Known Participant
April 26, 2017

Nice job! I have downloaded and tested. It works fine. But I have problem with packing to air-runtime :( Because It always show crazy like bug I already set up extendedDesktop than it cannot pack to air. Only running adl with webviewANE has not problem and it works fine. PS: Why do you use Swift / C++? You know. Xamarin released since whole support with Android, iOS and Mac. I'm not sure like you want merge dll in Mac with dylib / frameworks or You can try VS code and Net core ( dotnet with platforms ). Thanks for sharing. I will improve - If I have great ideas.... :)