chikuchikugonzalezの雑記帳

趣味とか日記とかメモとか(∩゚д゚)

IronRubyとIronPythonでのアセンブリの読み込み方法

メモしておかないと忘れそう。特にIronPythonのほう。

IronRubyでの読み込み方

普通にrequireで出来る。

#!ir

require 'System.Windows.Forms'
require 'System.Drawing'

class TestForm < System::Windows::Forms::Form
end

if __FILE__ == $0
  System::Windows::Forms::Application.Run(TestForm.new)
end
IronPythonでの読み込み方

いきなりimportが出来なくて、clrモジュールでアセンブリを登録してからimportする必要がある。

#!ipy

import clr

clr.AddReferenceByPartialName("System.Windows.Forms")
clr.AddReferenceByPartialName("System.Drawing")

from System.Drawing import *
from System.Windows.Forms import *

class TestForm(Form):
    def __init__(self):
        self.Text = "Test"

if __name__ == '__main__':
    Application.Run(TestForm())