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.3k
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
220
バックアップしていますか?
tsudaahr
0
130
RDB以前のファイル設計の話でもしようか(ぇ
tsudaahr
0
140
NPUわからん
tsudaahr
0
190
計算量オーダーの話
tsudaahr
1
420
クラウド初学者が抱える不安について
tsudaahr
0
300
キューとは何か
tsudaahr
0
260
等幅は死んだ(ぇ
tsudaahr
0
110
いくら眺めてもエラーの理由がわからないコードについて
tsudaahr
0
200
Other Decks in Programming
See All in Programming
AIと一緒にレガシーに向き合ってみた
nyafunta9858
0
250
高速開発のためのコード整理術
sutetotanuki
1
400
CSC307 Lecture 03
javiergs
PRO
1
490
AIエージェントのキホンから学ぶ「エージェンティックコーディング」実践入門
masahiro_nishimi
5
470
CSC307 Lecture 02
javiergs
PRO
1
780
AIによる開発の民主化を支える コンテキスト管理のこれまでとこれから
mulyu
3
380
開発者から情シスまで - 多様なユーザー層に届けるAPI提供戦略 / Postman API Night Okinawa 2026 Winter
tasshi
0
200
AgentCoreとHuman in the Loop
har1101
5
240
責任感のあるCloudWatchアラームを設計しよう
akihisaikeda
3
180
izumin5210のプロポーザルのネタ探し #tskaigi_msup
izumin5210
1
130
16年目のピクシブ百科事典を支える最新の技術基盤 / The Modern Tech Stack Powering Pixiv Encyclopedia in its 16th Year
ahuglajbclajep
5
1k
フロントエンド開発の勘所 -複数事業を経験して見えた判断軸の違い-
heimusu
7
2.8k
Featured
See All Featured
The agentic SEO stack - context over prompts
schlessera
0
640
Typedesign – Prime Four
hannesfritz
42
2.9k
Reality Check: Gamification 10 Years Later
codingconduct
0
2k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
508
140k
Redefining SEO in the New Era of Traffic Generation
szymonslowik
1
220
sira's awesome portfolio website redesign presentation
elsirapls
0
150
The Power of CSS Pseudo Elements
geoffreycrofte
80
6.2k
Rebuilding a faster, lazier Slack
samanthasiow
85
9.4k
New Earth Scene 8
popppiees
1
1.5k
Marketing Yourself as an Engineer | Alaka | Gurzu
gurzu
0
130
Agile Leadership in an Agile Organization
kimpetersen
PRO
0
83
Building a A Zero-Code AI SEO Workflow
portentint
PRO
0
320
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
デメリット? • たぶん激烈に遅い(計測はしていません)
ご清聴ありがとうございました。