An open API service indexing awesome lists of open source software.

https://github.com/skivhisink/marshalingclrsamples

Guide for Using C++ or C code in C#
https://github.com/skivhisink/marshalingclrsamples

clr cpp csharp dll library marshaling

Last synced: about 2 months ago
JSON representation

Guide for Using C++ or C code in C#

Awesome Lists containing this project

README

          

# MarshalingCLRSamples

This repository contains examples of using С++ code in С#.
The following two common approaches are typically employed:
* [**Marshaling**](https://github.com/SkivHisink/MarshalingCLRSamples/blob/main/README.md#marshaling)
* [**CLR**](https://github.com/SkivHisink/MarshalingCLRSamples/blob/main/README.md#clr)

## Marshaling
### About
Marshaling is the process of converting data between different memory representations to enable communication between components with different data formats, such as managed and unmanaged code in software applications. It allows seamless data exchange by translating data structures, data types, and memory layouts to ensure compatibility and consistency during interoperation. Marshaling is commonly used in environments like .NET to facilitate communication between managed and unmanaged code and to handle data transfers across boundaries like processes or networks.
### How to
1. Create Project with **DLL** Configuration type.
![image](https://github.com/SkivHisink/MarshalingCLRSamples/blob/main/Picture/marshalingcpp1.png)
2. TODO
### Code samples
## CLR
### About
C++ to C# communication via CLR (Common Language Runtime) can be achieved by creating a managed C++ wrapper that exposes C++ functions to the .NET environment. The managed C++ wrapper serves as an intermediary, allowing C# code to call C++ functions seamlessly. This integration enables interoperability between C++ and C# codebases, leveraging the strengths of both languages in a single application.
### How to
It will be written later.
### Code samples
TODO