.net 如何在boo中加载程序集

.net 如何在boo中加载程序集,.net,import,.net-assembly,boo,.net,Import,.net Assembly,Boo,我正试图在我的boo代码中使用.NET程序集Microsoft.VisualBasic,它 看起来像这样: import System import Regex from System.Text.RegularExpressions import Interaction from Microsoft.VisualBasic import Microsoft.VisualBasic ## import Reflection.Assembly ## path="""C:\Windows

我正试图在我的boo代码中使用
.NET
程序集
Microsoft.VisualBasic
,它

看起来像这样:

import System

import Regex from System.Text.RegularExpressions

import Interaction from Microsoft.VisualBasic

import Microsoft.VisualBasic

## import Reflection.Assembly



## path="""C:\Windows\winsxs\msil_microsoft.visualbasic_b03f5f7f11d50a3a_6.1.7100.0_none_29f6b89369881fe4\Microsoft.VisualBasic.dll"""

## f=Reflection.Assembly.Load(Reflection.Assembly.LoadFile(path).ToString())

## Interaction.Beep()

for i in Regex.Matches("def jam(this)","\\w+"):

    print i

arr=array(range(10))

print List(arr)

Array.Reverse(arr)

print List(arr)
当使用导入Microsoft.VisualBasic时,我得到一个错误:

test.boo(9,1): BCE0005: Unknown identifier: 'Interaction'.
使用
从Microsoft导入交互时。VisualBasic

test.boo(4,8): BCE0167: Namespace 'Interaction' not found in assembly 'Microsoft.VisualBasic'
当我尝试以这种方式加载dll时,它仍然不起作用:

Reflection.Assembly.Load(Reflection.Assembly.LoadFile(path))
问题是上述方法在Powershell中有效:

PS C:\mine> [reflection.assembly]::loadfile("C:\Windows\winsxs\msil_microsoft.visualbasic_b03f5f7f11d50a3a_6.1.7100.0_none_29f6b89369881fe4\Microsoft.VisualBasic.dll")

GAC    Version        Location

---    -------        --------

True   v2.0.50727     C:\Windows\assembly\GAC_MSIL\Microsoft.VisualBasic\8.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualBasic.dll

PS C:\mine> [microsoft.visualbasic.interaction]::beep()
我也可以使用
LoadWithPartialName
[Reflection.Assembly]::LoadWithPartialName('Microsoft.VisualBasic')
,但它已被弃用。


我该怎么做?

我终于找到了解决方案。原来问题是我编译它的方式。我使用的是
booc.exe test.boo
,而不是添加对
Microsoft.VisualBasic
的引用。您甚至不需要使用
Reflection.Assembly
加载它,只需导入它,使用它并使用
booc.exe test.boo-r:Microsoft.VisualBasic.dll
进行编译。为
dll
提供完整路径也可以。我猜
Powershell
boo
有不同的方式访问
.NET
程序集