基本上对应翻译一下就可以了吧?Imports System.Runtime.InteropServices Imports System.Textusing System.Runtime.InteropServices; using System.Text;---------------------Private Declare Function GetCORSystemDirectory Lib "mscoree.dll" (<MarshalAs(UnmanagedType.LPWStr)> ByVal Buffer As System.Text.StringBuilder, ByVal BufferLength As Integer, ByRef Length As Integer) As Integer[DllImport("mscoree.dll")] int GetCORSystemDirectory([MarsalAs(...)] System.Text.StringBuilder Buffer, ...);----------------------Public Overrides Sub Install(ByVal savedState As System.Collections.IDictionary) MyBase.Install(savedState) Dim Args As String = Me.Context.Parameters.Item("Args") If Args = "" Then Throw New InstallException("No arguments specified") End If ' Gets the path to the Framework directory. Dim Path As New System.Text.StringBuilder(1024) Dim Size As Integer GetCORSystemDirectory(Path, Path.Capacity, Size) Dim P As Process ' Quotes the arguments, in case they have a space in them. Dim Si As New ProcessStartInfo(Path.ToString() & "ngen.exe", Chr(34) & Args & Chr(34)) Si.WindowStyle = ProcessWindowStyle.Hidden Try P = Process.Start(Si) P.WaitForExit() Catch e As Exception Throw New InstallException(e.Message) End Try End Sub public virtual void Install(...) { base.Install(...); string Args = Me.Context.... if(...) { throw new .... } System.Text.StringBuilder Path = new System.Text.StringBuilder(1024); int Size; GetCORSystemDirectory(...) Process P; ProcessStartInfo Si = new ProcessStartInfo(... + "ngen.exe", "\"" + Args + "\""); try { P = Process.Start(Si); ... } catch(Exception e) { throw... } }
Imports System.Textusing System.Runtime.InteropServices;
using System.Text;---------------------Private Declare Function GetCORSystemDirectory Lib "mscoree.dll" (<MarshalAs(UnmanagedType.LPWStr)> ByVal Buffer As System.Text.StringBuilder, ByVal BufferLength As Integer, ByRef Length As Integer) As Integer[DllImport("mscoree.dll")]
int GetCORSystemDirectory([MarsalAs(...)] System.Text.StringBuilder Buffer, ...);----------------------Public Overrides Sub Install(ByVal savedState As System.Collections.IDictionary)
MyBase.Install(savedState)
Dim Args As String = Me.Context.Parameters.Item("Args") If Args = "" Then
Throw New InstallException("No arguments specified")
End If ' Gets the path to the Framework directory.
Dim Path As New System.Text.StringBuilder(1024)
Dim Size As Integer
GetCORSystemDirectory(Path, Path.Capacity, Size) Dim P As Process
' Quotes the arguments, in case they have a space in them.
Dim Si As New ProcessStartInfo(Path.ToString() & "ngen.exe", Chr(34) & Args & Chr(34))
Si.WindowStyle = ProcessWindowStyle.Hidden
Try
P = Process.Start(Si)
P.WaitForExit()
Catch e As Exception
Throw New InstallException(e.Message)
End Try
End Sub
public virtual void Install(...)
{
base.Install(...);
string Args = Me.Context.... if(...)
{
throw new ....
} System.Text.StringBuilder Path = new System.Text.StringBuilder(1024);
int Size; GetCORSystemDirectory(...) Process P;
ProcessStartInfo Si = new ProcessStartInfo(... + "ngen.exe", "\"" + Args + "\""); try
{
P = Process.Start(Si);
...
}
catch(Exception e)
{
throw...
}
}
生成的Release版程序是在c:\1\bin\Release\1.exe
那么我怎样用ngen.exe把它搞成本地代码.给一条完整命令给我就OK了.
谢谢 sumtec
/show 显示已经安装到缓冲里面的程序集列表
/delete 从缓冲当中删除指定的程序集
/showversion 显示用来产生程序集的本地代码的编译器(框架)版本号开发者参数:
... 这个你似乎用不着杂项参数:
/? 不用解释吧?
/nologo 不显示logo
/silent 安静模式