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

질문됨 2년 전281회 조회
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

답변함 2년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠