- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我做的例子可以查到here .所以我尝试在 C# 脚本中运行 IronPython:
python :
def hello(name):
print "Hello " + name + "! Welcome to IronPython!"
return
def add(x, y):
print "%i + %i = %i" % (x, y, (x + y))
return
def multiply(x, y):
print "%i * %i = %i" % (x, y, (x * y))
return
C#:
using IronPython.Hosting;
using IronPython.Runtime;
using Microsoft.Scripting.Hosting;
using System;
namespace IntroIronPython
{
class IronPythonMain
{
static void Main(string[] args)
{
// Create a new ScriptRuntime for IronPython
Console.WriteLine("Loading IronPython Runtime...");
ScriptRuntime python = Python.CreateRuntime();
try
{
// Attempt to load the python file
Console.WriteLine("Loading Python File...");
// Create a Dynamic Type for our Python File
dynamic pyfile = python.UseFile("PythonFunctions.py");
Console.WriteLine("Python File Loaded!");
Console.WriteLine("Running Python Commands...\n");
// Call the hello(name) function
pyfile.hello("Urda");
…
从这里我有这个错误:“没有“Microsoft.CSharp.dll”程序集引用,无法编译动态操作。”我真的不明白那是什么,我忘了添加什么?
在我的引用资料中,我有:
感谢您的帮助。
Ps: 我在 MonoDevelop 上。
最佳答案
这对我有帮助。我正在使用 Xamarian Studio v5.8.1 (build 8) 编写 C# 程序。我只需右键单击“引用”->“编辑引用”->开始在搜索栏中输入“Microsoft”->选中“Microsoft.CSharp”旁边的框->然后单击“确定”。
之后我刚刚保存并运行了程序 - 一切都按预期进行!
关于C#动态编译和 "Microsoft.CSharp.dll"错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11417047/
我希望将我们代码中某些基于反射的部分替换为使用动态运行时编译性能更好的部分。环顾四周,我看到 Mono 和 Microsoft 都有单独的编译器即服务解决方案:Mono.CSharp 和 Micros
在 Open with .cs 的菜单文件有 Csharp editor和 Csharp editor with encoding .我打开了一个解决方案,并没有看到任何区别。 它们之间有什么区别?
关闭。此题需要details or clarity 。目前不接受答案。 想要改进这个问题吗?通过 editing this post 添加详细信息并澄清问题. 已关闭 7 年前。 Improve th
一段代码抵千字... public enum enTest { a, b, c } public void PrintEnum() { foreach (var E in Enum.GetVa
我不熟悉 visual studio/c# 中的单元测试和异步操作。感谢对此的任何帮助。 我的主类 class Foo { public async Task GetWebAsync()
我搜索了一上午,似乎找不到这个问题的答案。 我有一组线程,每个线程都在工作,然后我将遍历 id 连接每个线程,然后启动新线程。检测线程何时完成以便我可以在不等待每个线程完成的情况下启动新线程的最佳方法
我有方法,它有参数“word”返回 Word 第一个字母和字符串的最后一个字母。第一个和最后一个字母之间有三点。例如,当您编写“stackoverflow”时,它会像“s...w”那样返回它 我有这个
这是我目前正在尝试的: var value = Datepicker1.Value; List data = new List(); string connetionString; MySqlConn
A a = new A(); 012E2FB8 mov ecx,58812BCh 012E2FBD调用011C30F4 012E2FC2 mov dword ptr [ebp-44h],eax 012
我有这样的 file.txt:编辑:我没有写,但我猜这很重要 - 在 file.txt 中可以有其他行! folder=c:\user;c:\test;c:\something; 我需要添加一个路径,
我从 OdcDataReader 获取一个值,该值显示为 Single 类型。我不想在代码中使用单个,所以我想将它转换成小数。但是,似乎每当我尝试将其转换为小数(或任何与此相关的东西)时,它都会丢失几
你能在最顶层的窗口上启动一个进程吗? (csharp wpf) 我有以下内容,但在此之前的当前窗口(使用具有 topmost=true 的窗口类的 wpf 窗口)在进程启动时仍位于进程的顶部。 if
我正在尝试在可移植类库中使用 .NET 4 的动态类型,但我在获取所有必需的引用时遇到了问题。我可以很好地引用 System.Core,但是 Microsoft.CSharp 给我带来了一些麻烦。似乎
我相信我发现了一个错误,该错误涉及如何将准备好的语句缓存在 Cassandra csharp 驱动程序(版本 2.7.3)的 StatementFactory 中。这是用例。 Guid key = G
大家好,我只想将 textbox.text 与数据库进行比较。这是我的代码: string str = string.Format("select Firstname,Lastname,Middlen
是否有一个简单的 csharp (cshtml) 解决方案来检测浏览器是否为 Chrome,然后不加载一段 html 代码。另外,我知道我可能只使用 javascript,但使用 C# html 组合
我有一个 Minecraft 客户端启动器,但它无法启动 Minecraft。我尝试了 TeamExtreme 中的参数,但失败了。 [原文为匈牙利,现翻译] 启动器代码: priva
是否可以在我的 CSharp 项目文件中包含代码来检查 ConfuserEx 是否正确执行,如果没有正确执行则终止编译过程?也许使用反射来检查类名是否仍然存在(即没有被混淆)? 更新:这是 .cspr
我有一堆实现接口(interface)的数据类,我们称它为ISpendable。根据在运行时处理哪个 ISpendable 类, Controller 类需要设置不同的事件监听器。 例子: publi
我已阅读构建说明 protobuf-csharp-port在Linux/Unix 系统下使用Mono。我仍然无法让它工作,最终我会打开一个线程来询问为什么,但这不是这篇文章的问题。 我正在使用 Win
我是一名优秀的程序员,十分优秀!