Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
C# and C++ Interoperability - cho-dotnetnew
Search
Akiko Kawai
May 29, 2026
Programming
520
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
C# and C++ Interoperability - cho-dotnetnew
2026/5/29 超dotnetnew
「C++とC#の相互運用」遥佐保
Akiko Kawai
May 29, 2026
More Decks by Akiko Kawai
See All by Akiko Kawai
Unity Scripting Backend - C++breaktime 2026 Summer
harukasao
0
61
How to call c# from c++ - meetup app osaka@10
harukasao
0
45
VCpp Link and Library - C++ breaktime 2025 Summer
harukasao
0
320
Coding Experience Cpp vs Csharp - meetup app osaka@9
harukasao
0
1.3k
Selected MAUI Blazor - meetup app osaka@8
harukasao
0
170
Try C++ module! - meetup app osaka@5
harukasao
0
510
シミュレーター制作の感想/ Tried developing Simulator at .NET Lab 201910
harukasao
0
120
NimTorchの紹介 / Introduce NimTorch meetup app osaka @3
harukasao
0
910
std::optionalの使い方 / how to use optional nakamecpp_13
harukasao
0
2.7k
Other Decks in Programming
See All in Programming
Creating Composable Callables in Contemporary C++
rollbear
0
180
1B+ /day規模のログを管理する技術
broadleaf
0
120
ローカルLLMでどこまでコードが書けるか -縮小版 / How much code can be written on a local LLM Shortened
kishida
2
150
AIで効率化できた業務・日常
ochtum
0
160
Go1.27で導入されるジェネリクスメソッドでできること
mackee
0
210
Agentic UI
manfredsteyer
PRO
0
210
Lessons from Spec-Driven Development
simas
PRO
0
230
メソッドのジェネリクスでGoの夢は広がるか? / Kyoto.go #65
utgwkk
3
1k
AI がコードを書く時代における新卒エンジニアの仕事風景 (2026) / New Graduate Engineers in the Era of AI Coding (2026)
sushichan044
0
110
任せる範囲はこう広がった / How the Scope of AI Delegation Has Expanded
nrslib
1
220
Performance Engineering for Everyone
elenatanasoiu
0
250
ローカルLLMを使ってB2Bサービスを作っていての学び
yaotti
0
220
Featured
See All Featured
Large-scale JavaScript Application Architecture
addyosmani
515
110k
A brief & incomplete history of UX Design for the World Wide Web: 1989–2019
jct
2
410
Faster Mobile Websites
deanohume
310
32k
Between Models and Reality
mayunak
4
360
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
47
8.2k
Mind Mapping
helmedeiros
PRO
1
270
Building a A Zero-Code AI SEO Workflow
portentint
PRO
0
610
Git: the NoSQL Database
bkeepers
PRO
432
67k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
32
3.6k
First, design no harm
axbom
PRO
2
1.2k
Navigating the moral maze — ethical principles for Al-driven product design
skipperchong
2
400
YesSQL, Process and Tooling at Scale
rocio
174
15k
Transcript
None
None
None
None
Type C# → C++(序章) COM系 COM Interop(RCW) CLI系 C++/CLIラッパー Export系
P/Invoke (DLLImport,LibraryImport) https://learn.microsoft.com/ja-jp/dotnet/standard/native-interop/runtime-callable-wrapper RCW C# Client COM Object C++/CLI 自作Wrapper (/clr) C# Client Native Class/DLL C# Client Marshal (auto- generated) Native DLL CLRに組み込まれている DllImport 実行時 LibraryImportビルド時
None
え?なんで? さっきの逆でしょ? C#のメモリ先に飛ん でけばいいやん?
None
Type C++ → C# COM系 COM Interop(CCW) Windows only 超Legacy
マーシャリング コスト大 CLI系 /clr 化 つまり /clr option Windows only Legacy C++/CLIブリッジDLL CCW C# Object COM Client Native Class/DLLのCLR化 (/clr) IJW(It Just Works) Thunk using VTableFixup C++/CLI 自作ブリッジ DLL C# Object Native Class/DLL C# Object
Type C++ → C# Export 系 DllExport (~.NET Framework) Windows
only 超Legacy NativeAOT (.NET 7+) +[UnmanagedCallersOnly] ホットリロード未対応, ランタイムは固定, 手動でC ABIを解決, ライブラリ抱き込み Cross- platform Build後にToolでC# DLLのILを書き換え パッチDLL(純粋なIL) C# Object using VTableFixup Native Class/DLL AOTコンパイラが C#コードをNativeDLLへ Native Class/DLL C# Native
Type C++ → C# Hosting 系 CLR Hosting APIはCOM Interface,
CCWなし Windows only Hostfxr (.NET Core 3.0+) +[UnmanagedCallersOnly] (.NET 5+) 直接C API使う Cross-platform C++ Process CLR Runtime C# Managed Heap Native Class/DLL C++ Process Core CLR Runtime C# Managed Heap Native Class/DLL
まとめ
Type C# → C++ C++ → C# COM系 COM Interop(RCW)
COM Interop(CCW) CLI系 C++/CLIラッパー /clr, C++/CLIブリッジDLL Export系 P/Invoke (DLLImport,LibraryImport) DllExport, NativeAOT+[UnmanagedCallersOnly] Hosting系 なし (C++は既にNativeなので Runtime不要) CLR Hosting, hostfxr+[UnmanagedCallersOnly]