oleg-shilo / cs-script.net-framework

A mirror of the oleg-shilo/cs-script repository of CS-Script for .NET Framework. A copy of the repo before the product migration on .NET 5migrat
MIT License
30 stars 10 forks source link

Error loading CSScriptLibrary.dll in Powershell #6

Closed Davider-code closed 1 year ago

Davider-code commented 1 year ago

hello,

I tried to load CSScriptLibrary.dll in powershell, but it will be prompted with the following error: appears to be missing Mono related assemblies. Can disable loading them on the Windows platform? Or are there any other solutions? Thanks in advance

system: windows7 x64 + powershell5.1 + .NET4.8

powershell code:


try
{
    Add-Type -Path "$HOME\Desktop\Binaries_for_DOTNET_4.8\CSScriptLibrary.dll"
}
catch
{
    $_.Exception.LoaderExceptions | % { Write-Host $_.Message }
}

Error info: Could not load file or assembly 'Mono.Posix, Version=4.0.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756' or one of its dependencies. The system cannot find the specified file Could not load file or assembly 'Mono.CSharp, Version=4.0.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756' or one of its dependencies. The system cannot find the specified file

oleg-shilo commented 1 year ago

The problem is caused (most likely) by not having CS-Script NuGet packages imported. Please see the #7 answer.

oleg-shilo commented 1 year ago

I am kinda puzzled. You are using a script engine (PS) to run another script engine (CS-Script).

Why don't you just run C# scripts directly from your shell/terminal with the CS-Script engine?

Davider-code commented 1 year ago

I am kinda puzzled. You are using a script engine (PS) to run another script engine (CS-Script).

Why don't you just run C# scripts directly from your shell/terminal with the CS-Script engine?

Thank you for your reply . I manually downloaded the two missing DLL files from nuget.org and now load the DLL normally

. My main function code is in Powershell scripts. Sometimes, when implementing a certain function, there is ready-made C # function code, and I want to execute it immediately in Powershell code.

I am not proficient in C # programming, and using CS-Script can directly use C # code in Powershell, which is a great experience for Powershell users

oleg-shilo commented 1 year ago

Glad you solved it