问题描述
我正在尝试在Power Shell 2.0中执行C#代码。
我的问题是代码开头的引用:
Hi , I'm trying to execute C# code in Power Shell 2.0 .
My problem is for the references at the beginning of the code:
$referencingassemblies = (
"C:\Windows\Microsoft.NET\Framework\v4.0.30319\System.XML.dll",
"C:\Windows\Microsoft.NET\Framework\v4.0.30319\System.Linq.dll"
)
code= @"
using System;
using System.Collections;
using System.IO;
using System.Linq;
using System.Xml;
using System.Xml.Linq;
public class Program
{
static void Main()
{ /* the code witch works*/
}
}"@
Add-Type -ReferencedAssemblies $ referencingassemblies -TypeDefinition $ code -LanguageCSharpVersion3-IgnoreWarnings
Powershell给出了一个错误,指出Linq的类型或命名空间不存在。我有Visual Studio express 2013.
如何同时正确地添加或导入两个引用?或者我做错了什么?
Add-Type -ReferencedAssemblies $referencingassemblies -TypeDefinition $code -Language "CSharpVersion3" -IgnoreWarnings
Powershell gives me an error saying that The type or namespace Linq doesn't exist. I have Visual studio express 2013.
How can add or import correctly both References at the same time?or what I'm doing wrong?
推荐答案
Add-Type -ReferencedAssemblies
Add-Type -ReferencedAssemblies
这篇关于PowerShell中的C#:如何添加多个ReferenceAssemblies的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!