首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在StringTemplate中运行cs脚本(c#脚本)?

如何在StringTemplate中运行cs脚本(c#脚本)?
EN

Stack Overflow用户
提问于 2011-01-10 04:42:57
回答 1查看 1K关注 0票数 0

我将Antlr3.StringTemplate.dll和Antlr3.Runtime.dll从http://www.stringtemplate.org/复制到cs-script/lib目录( http://www.csscript.net/ ),并执行以下代码,但它显示找不到Antlr的程序集,为什么?下面是我的程序

代码语言:javascript
复制
//css_reference Antlr3.Runtime.dll;
//css_reference Antlr3.StringTemplate.dll;

using System;
using Antlr.StringTemplate;
using Antlr.StringTemplate.Language;
using System.Windows.Forms;

class Script
{
    static public void Main(string[] args)
    {


StringTemplateGroup group =  new StringTemplateGroup("myGroup", @"C:\Tutorials\stringtemplate", typeof(DefaultTemplateLexer));
StringTemplate helloAgain = group.GetInstanceOf("homepage");

helloAgain.SetAttribute("title", "Welcome To StringTemplate");
helloAgain.SetAttribute("name", "World");
helloAgain.SetAttribute("friends", "Terence");
helloAgain.SetAttribute("friends", "Kunle");
helloAgain.SetAttribute("friends", "Micheal");
helloAgain.SetAttribute("friends", "Marq");

Console.Out.WriteLine(helloAgain.ToString());
    }
}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2011-01-10 07:04:18

该错误表示CS-Script无法解析Antlr3.*.dll程序集。

您需要指示脚本引擎这些程序集可能位于的位置,如果您不这样做,CS-Script将只在GAC、您的本地目录(脚本所在的目录)和cs- script \Lib中查找。

你有几个选项来解决这个问题:

  • 您可以使用绝对路径
  • 指定程序集,并将探测目录添加到CS-Script全局设置或直接添加到脚本中。在GAC中注册

看一看AddingSearchDirs和www.csscript.net/help/Using_.NET_assemblies.html,,这将帮助你开始。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/4641649

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档