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
Python から.net DLL を呼び出す
Search
tsuda.a
December 30, 2022
Programming
0
1.2k
Python から.net DLL を呼び出す
Python (Iron Python ではなく、普通のいわゆる cPython (ver3系)) で .net core の DLL を呼び出してみた例です。
tsuda.a
December 30, 2022
Tweet
Share
More Decks by tsuda.a
See All by tsuda.a
マジカルインクリメントと指数表記
tsudaahr
0
180
バックアップしていますか?
tsudaahr
0
110
RDB以前のファイル設計の話でもしようか(ぇ
tsudaahr
0
120
NPUわからん
tsudaahr
0
170
計算量オーダーの話
tsudaahr
1
390
クラウド初学者が抱える不安について
tsudaahr
0
260
キューとは何か
tsudaahr
0
220
等幅は死んだ(ぇ
tsudaahr
0
96
いくら眺めてもエラーの理由がわからないコードについて
tsudaahr
0
180
Other Decks in Programming
See All in Programming
個人軟體時代
ethanhuang13
0
330
Swift Updates - Learn Languages 2025
koher
2
510
基礎から学ぶ大画面対応(Learning Large-Screen Support from the Ground Up)
tomoya0x00
0
4.1k
速いWebフレームワークを作る
yusukebe
5
1.7k
Azure SRE Agentで運用は楽になるのか?
kkamegawa
0
2.5k
アセットのコンパイルについて
ojun9
0
130
AIでLINEスタンプを作ってみた
eycjur
1
230
デザイナーが Androidエンジニアに 挑戦してみた
874wokiite
0
550
Kiroで始めるAI-DLC
kaonash
2
630
もうちょっといいRubyプロファイラを作りたい (2025)
osyoyu
1
450
Laravel Boost 超入門
fire_arlo
3
220
print("Hello, World")
eddie
2
530
Featured
See All Featured
Intergalactic Javascript Robots from Outer Space
tanoku
272
27k
Build your cross-platform service in a week with App Engine
jlugia
231
18k
Building an army of robots
kneath
306
46k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
15
1.7k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
PRO
23
1.4k
The Illustrated Children's Guide to Kubernetes
chrisshort
48
50k
Why You Should Never Use an ORM
jnunemaker
PRO
59
9.5k
Embracing the Ebb and Flow
colly
87
4.8k
GraphQLとの向き合い方2022年版
quramy
49
14k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
31
2.2k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.5k
Keith and Marios Guide to Fast Websites
keithpitt
411
22k
Transcript
Python から .net DLL を 呼び出す すごい広島 .rb with Python[69]
オンライン LTDD 2022-12 #1 @tsuda_ahr
準備 pip install pythonnet ※ .net core のインストールは済んでいるものとします
Visual Studio で dll を作成 (.net core で作ります) namespace PythonTestNamespace
{ public class PythonTestClass { public int Add(int value1, int value2) { return value1 + value2; } } }
Python のコードを書く from pythonnet import load Load(“coreclr”) import clr clr.AddReference('PythonTest')
from PythonTestNamespace import PythonTestClass test = PythonTestClass() ver = test.Add(1, 2) print(ver) .net core の CLR を使用 (これを書かないと .net framework になる) DLL を Load Class を Import
同じフォルダに配置
実行
よって ライブラリロジックは C# で書いて、それを Python で操ることが可能!
そんなことをして何が楽しいのか?
Powershell (pwsh) からでも使えるよ!
C# DLL WindowsApp Python Powershell Excel VBA つまりいろんな環境から呼び出せる。 Winows Only
Winows or Linux or Mac
デメリット? • たぶん激烈に遅い(計測はしていません)
ご清聴ありがとうございました。