Lambda function - (C#/PowerShell)

0

Hello,
I would like to request your help for simple question about if it possible to code c# script bloc inside a PowerShell lambda function. Just as follow:
$code = @"
using System;
namespace HelloWorld
{
public class Program
{
public static void Main(){
Console.WriteLine("Hello world!");
}
}
}
"@

Add-Type -TypeDefinition $code -Language CSharp

My code is correct, and I can run it in PowerShell without no issue, however, when I try to execute them inside à lambda expression, I got a strange error “Could not fin part of the path ‘/var/runtime/ref’
Anyone could help me please?
Thank you

已提問 3 年前檢視次數 307 次
1 個回答
0

So, I didn’t know / understand the reason…., however by compiling the C# code inside a DLL and then call that DLL it works well. It’s strange but it works.
If that can help….

Thank you
Best Regards
Joao Fernandes

已回答 3 年前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南