Using mono assemblies from the .NET CoreCLR - linux

I need to consume a library that doesn't yet have CoreCLR support (RabbitMQ.Client, to be specific). Is it possible to utilize a mono-based port of that library on a Linux system from inside a CoreCLR executable? If so, how is that achieved?

It is impossible at binary level (unless using a proper PCL profile). .NET Core has a different approach to arrange classes in assemblies, so some assemblies on desktop .NET Framework are broken into smaller assemblies, and types are moved. A desktop targeting assembly (from .NET or Mono) won't work on .NET Core due to such changes.
But it is obviously possible at source code level, as there was an attempt to port Mono's WinForms to .NET Core,
http://forums.dotnetfoundation.org/t/anyone-porting-winforms-mono-to-net-core/898/4
Once a new .NET Core library project is created, the source files should be able to be carried over (with some modification or even none).
However, .NET Core has been evolving too fast, and that attempt might be now out of date. Anyone would like to explore in this area can follow that example and try once again. Good luck.

Related

Why does the Windows SDK now include strmbase.lib?

Windows SDK 7.1 was the last version that included the baseclasses direct show sample. But later Windows SDK have strmbase.lib with the compiled library. What use is the library without the headers?
It might be included without good reason waiting for its cleanup time, or there is unobvious reason such as reference to this static library when linking other legacy libraries.
Either way you are correct in the part that DirectShow bases classes are no longer in Windows SDK. Those interested in DirectShow development would typically get DirectShow BaseClasses and samples from Windows-classic-samples/Win7Samples and build the code including strmbase.lib themselves.

What is the importance of CoreCLR, PCL and WinRT in Azure-Storage-Net change log

I was inspecting the change log of Windows Azure Storage nuget from here. I do not get the usage of CoreCLR, PCL and WinRT.
For instance
Changes in 7.2.0 :
All (CoreCLR): NetStandard target framework changed to netstandard1.3
All (PCL): Removed support for PCL in favor of NetStandard GA release
...
Changes in 7.1.2 :
...
All (WinRT): Fixed a bug where HttpClient default timeout caused unhandled TaskCancellation exceptions.
...
A simple search on google tells that CoreCLR is a .NET execution engine and WinRT stands for Windows Runtime. I do not know what PCL is.
So what is the importance of these in change log in simple terms?
Those represent versions of the package capable of running on different versions of .Net:
WinRT is used in Windows Store apps, it uses a trimmed version of .Net
PCL is short for Portable Class Library, the old approach of targeting multiple versions of .Net from a single library
NetStandard is a new approach of targeting multiple versions of .Net, that came along with .Net Core, the new modular cross-platform version of .Net
CoreCLR is the runtime used by .Net Core, though marking changes to NetStandard version of the library as "CoreCLR" is confusing

Can I use Visual Studio to develop Mono applications?

I have developed a .NET 4.5 application using WinForms. I want my application to run not only on Windows, but also on Linux, so I decided to port it to Mono.
However, I can't find any information on how to use Visual Studio for Mono. I don't want to switch to MonoDevelop, since VS provides much of the functionality I want and I am already familiar with it.
There apparently used to be something called Mono Tools for Visual Studio, which David Lively insists works on current VS editions, but I don't want to run an extension that was deprecated 3 years ago. I don't even know where to download the extension - it redirects to Xamarin, and Xamarin seems like not what I want because while it mentions VS integration, it forces me to install a bunch of Android and Java SDKs (why?).
As far as I can see, .NET and Mono code looks fairly similar, and there are 3 main concerns:
Making VS use the Mono compiler instead of the C# compiler, so I can tell if non-Windows users can compile my source, and also get notified about missing libraries
Making IntelliSense suggest only Mono-supported things
Making the "Run" command run the application using Mono, not .NET, so I can test it correctly
Is there really no easy way of accomplishing these?
Note: I want to develop Windows and Linux desktop apps, with a WinForms GUI or equivalent only. I am not interested in mobile.
In general, you can just target .NET 4.5 and compile with Visual Studio and the resulting assembly works as-is on Mono (assuming you don't use platform-specific stuff via p/invoke, etc).
Mono's WinForms support isn't perfect though (and nobody actively works on it), so you still need to test by running the app directly on Mono. Missing APIs aren't usually the problem, it's more that the Mono implementation has different behavior/bugs.
Another alternative to WinForms might be Xwt.

MEF support on Xamarin.iOS

I am wanting to port a C# Mobile App for Windows 8 tablets using Xamarin. One of the issues we foresee is the use of MEF. Does Xamarin.iOS support MEF?
It depends on what you mean by MEF support. Using MEF assemblies is possible using Xamarin.iOS. What's not possible (iOS restriction) is dynamically loading code in your application (e.g. plugins).
You might be able to use MEF while ensuring there's not dynamic code being loaded, i.e. that everything is statically referenced and built inside a single binary executable (e.g. by ensuring every plugin is built-in).
Depending on your application that could prove useful (no, or less, need to modify your existing application) or not (if your app can't load/be built with all plugins). In the later case your problem is with iOS itself (not Xamarin).

How to run C# 4.0 app on Linux OS using mono?

I want to run my c# application with OS Linux using Mono. I am new to this cross platform migration? Please tell the procedure for doing that?
Thanks & Regards.
It very much depends on what type of application it is. For a console or WinForms app, it may be simple. Mono doesn't support WPF.
Well, the first think you'll need to do is install Mono of course. Then you probably want to run MoMA to determine your application's compatibility. There's a whole separate page about porting WinForms apps.
If all is well, you should just be able to run your application using:
mono MyApplication.exe
after copying the binaries over.
If your application is actually a web service or web application, you'll want to think about the various hosting options.
I suspect you'll want to read a lot of the pages on the Mono Start Page.
Check if your application is 100% compatible with Mono Framework using MoMA.
Remove or replace those unimplemented parts with Mono's implementation or third party libraries that works with Mono. Or if you think it should work fine, just execute it with Mono Framework 2.8 or higher. Better go with 2.10 which is default's profile is on 4.0.
There is an IDE, MonoDevelop that supports Web and Desktop applications. Open the project files (monodevelop supports visual studio project files) from monodevelop, compile and run.
you can browse mono website here, where you can find which features are supported and which are not supported and why.

Resources