Our project structure is like,
native.dll
:- This contains pure native code written in c\c++.
This native.dll exposes some functions using *def file.
Wrapper Library(wrapper.dll compiled with .Net framework v4.0)
:-
In order to use functionality of native.dll
, a Wrapper lib(wrapper.dll)
is written in C++\CLI
using :clr\oldsyntax
. This wrapper has all
code of Interoperability
and Marshalling
.
Application(Console App v4.0)
directly uses wrapper.dll
to use functionality provided
by native.dll
.
Now this project needs to run in .Net Core. This means we will have an
.Net Core application
that will reference wrapper.dll
that in turn will refer
native.dll
.
I know this will not directly work. But the issue is whether .Net Core(CoreCLR) supports C++\CLI (clr\oldsyntax) runtime environment ?
If no, what can be the possible solutions to this application work ?
NET Core 3.1 and Visual Studio 2019, C++/CLI projects can target . NET Core. This support makes it possible to port Windows desktop applications with C++/CLI interop layers to .
The . NET command-line interface (CLI) is a cross-platform toolchain for developing, building, running, and publishing . NET applications.
A platform-independent development system from Microsoft that enables programs written in different programming languages to run on different types of hardware. CLI is part of Microsoft's . NET platform and is expected to become an ECMA standard.
C++/CLI is not deprecated. The Visual C++ team invested in C++/CLI Intellisense in Visual Studio 2012; a feature that was cut from Visual Studio 2010.
whether .Net Core(CoreCLR) supports C++\CLI (clr\oldsyntax) runtime environment ?
As far as I know there is no plan to support C++/CLI with .NET Core.
If no, what can be the possible solutions to this application work ?
You can (should) provide a C API. Mono e. g. supports P/Invoke and .NET Core also supports P/Invoke (see also this Stack overflow question and this DllMap related ticket).
Update (2022-09-02): This answer is from 2016. See the other answers (e.g., this) for what is possible with recent .Net Core versions.
Officially announced eventually... (next wish... support linux @ .Net 5 ^^)
https://devblogs.microsoft.com/cppblog/the-future-of-cpp-cli-and-dotnet-core-3/
C++/CLI will have full IDE support for targeting .NET Core 3.1 and higher. This support will include projects, IntelliSense, and mixed-mode debugging (IJW) on Windows. We don’t currently have plans for C++/CLI for targeting macOS or Linux. Additionally, compiling with “/clr:pure” and “/clr:safe” won’t be supported for .NET Core.
The first public previews for C++/CLI are right around the corner. Visual Studio 2019 16.4 Preview 1 includes an updated compiler with “/clr:netcore”
Updat: From replied of origin url: "We are still working on the IDE and MSBuild integration, so I can’t share a sample project quite yet. Once it’s available, likely with 16.4 Preview 2 or 3"
(16.4 Preview1 cannot create C++/CLI with .NetCore project.)
191015 16.4 Preview2 Released. I'v tried asp.net core 3.1 with c++/CLI dll, it works. (need set plateform to x64 both asp.net core and c++/CLI dll)
.net Core team will only commit (now?) to supporting C++/CLI for Windows only.
The intention was to deliver it for .net Core 3.0. While I haven't found explicit mention of it yet in the release notes, C++/CLI support was a prerequisite for delivering WPF (windows-only), which is now supported in .net Core 3.0.
Support mixed-mode assemblies on Windows - #18013
This issue (#18013) will track progress toward supporting loading and running mixed-mode assemblies on CoreCLR. The main goal is to provide support for WPF and other existing C++/CLI code on .NET Core. Some of the work will be dependent on updates to the MSVC compiler.
The github issue (#659) mentioned above by @Tomas-Kubes, Will CoreCLR support C++/CLI crossplat? - #659, is about cross-platform C++/CLI.
BTW, I am getting compiler warnings on "clr\oldsyntax" with VS2017/.net-4.7. So this compiler flag is already deprecated.
UPDATE: This isn't coming till .Net Core 3.1
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With