我正在试用.fsx脚本中的预编译正则表达式。但我不知道如何为生成的程序集指定.dll文件位置。我已经尝试在Regex.CompileToAssembly
使用的AssemblyName
实例上设置CodeBase
等属性,但无济于事。下面是我有:Regex.CompileToAssembly如何设置.dll文件位置
open System.Text.RegularExpressions
let rcis = [|
new RegexCompilationInfo(
@"^NumericLiteral([QRZING])$",
RegexOptions.None,
"NumericLiteral",
"Swensen.Unquote.Regex",
true
);
|]
let an = new System.Reflection.AssemblyName("Unquote.Regex");
an.CodeBase <- __SOURCE_DIRECTORY__ + "\\" + "Unquote.Regex.dll"
Regex.CompileToAssembly(rcis, an)
我在FSI执行此,当我评价an
我看到:
> an;;
val it : System.Reflection.AssemblyName =
Unquote.Regex
{CodeBase = "C:\Users\Stephen\Documents\Visual Studio 2010\Projects\Unquote\code\Unquote\Unquote.Regex.dll";
CultureInfo = null;
EscapedCodeBase = "C:%5CUsers%5CStephen%5CDocuments%5CVisual%20Studio%202010%5CProjects%5CUnquote%5Ccode%5CUnquote%5CUnquote.Regex.dll";
Flags = None;
FullName = "Unquote.Regex";
HashAlgorithm = None;
KeyPair = null;
Name = "Unquote.Regex";
ProcessorArchitecture = None;
Version = null;
VersionCompatibility = SameMachine;}
但同样,我没有看到C:\用户\斯蒂芬\ Documents \ Visual Studio 2010 \ Projects \ Unquote \ code \ Unquote \ Unquote.Regex.dll就像我想要的。如果我搜索我的C驱动器Unquote.Regex.dll,我确实在某个临时AppData文件夹中找到了它。
那么,如何正确指定由Regex.CompileToAssembly
生成的程序集的.dll文件位置?
非常好 - 谢谢! – 2012-04-15 18:26:24