IronPythonからC#のDLLを呼び出す ― 2015/05/09 08:00
トレンドは、C#からIronPythonを呼び出すと思いますが、都合により逆のパターンを考えています。
IronPythonで、C#で作ったDLLアセンブリモジュールの単体テストを行う
http://d.hatena.ne.jp/Wacky/20070325/1174810604
.NET Frameworkを使うための準備
http://www.ops.dti.ne.jp/ironpython.beginner/PrepareNetFramework.html
How to load a C# dll in python?
http://stackoverflow.com/questions/2077870/how-to-load-a-c-sharp-dll-in-python
How to use a C# dll in IronPython
http://stackoverflow.com/questions/1200182/how-to-use-a-c-sharp-dll-in-ironpython
IronPython: clr.AddReference(MSDN)
http://blogs.msdn.com/b/haibo_luo/archive/2007/09/25/5130072.aspx
IronPython(MSDN)
https://msdn.microsoft.com/en-us/magazine/cc300810.aspx
Scripting .NET Applications with IronPython(CodeProject)
http://www.codeproject.com/Articles/602112/Scripting-NET-Applications-with-IronPython
ここまで来ると、PowerShellからIronPythonを呼び出したくなりますね。
IronPython and Microsoft's PowerShell
http://www.pythondiary.com/blog/Jun.26,2012/ironpython-and-microsofts-powershell.html
結局、以下のコードで呼び出しが可能なようです。
import clr
import sys
sys.path.append( r"d:\test" ) ← C#で作成したDLL(publicなクラスにする必要があることに注意)へのパス
clr.AddReference( "test.dll" )
from 名前空間 import クラス名
instance = クラス名
instance.Function()
後はお好きに。
コメントをどうぞ
※メールアドレスとURLの入力は必須ではありません。 入力されたメールアドレスは記事に反映されず、ブログの管理者のみが参照できます。
※なお、送られたコメントはブログの管理者が確認するまで公開されません。
※投稿には管理者が設定した質問に答える必要があります。