Open borjaalonsoarbolus opened 2 years ago
Sounds like you are trying to use the .NET Framework version of the assemblies on .NET 6 (or .NET Core 3.1). This will not work. How are you linking in the IronPython assemblies? You need to use the net6.0 (or netcoreapp3.1) version of the assemblies.
You have also reformatted the example by adding some whitespace at the beginning of the lines. After you resolve the linking problem, the example will still fail. In Python, there are strict rules on indentation of code. The simplest way to fix your test code is by moving def
to the beginning of the line.
I referenced the NET6 dll with add reference in project, its a .NET 6 console app with nothing else. Thanks!
UPDATE: I tried in another machine, now the error is other encoding(same project)
'Failed to load language 'IronPython 3.4.0b1': No data is available for encoding 437. For information on defining a custom encoding, see the documentation for the Encoding.RegisterProvider method.'
This is exactly the issue you would get when trying to use the .NET Framework version of the assemblies. Can you try changing your program to:
Console.WriteLine(IronPython.Runtime.ClrModule.TargetFramework);
What does this output? You should see .NETCoreApp,Version=v6.0
if you are using the correct assemblies.
In any case, I would suggest using the NuGet package instead of referencing the assemblies directly. Assuming you're using the .NET 6 SDK:
dotnet new console
dotnet add package IronPython -v 3.4.0-beta1
Your project file now looks like this:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="IronPython" Version="3.4.0-beta1" />
</ItemGroup>
4. Edit Program.cs to contain the following:
```cs
var engine = IronPython.Hosting.Python.CreateEngine();
engine.Execute("print('Hello World!')");
dotnet run
Hello World!
.Thanks all i will try and tell you if it worked, sorry , its beeing a busy week.
Prerequisites
The issue tracker is used to report bugs and request new features, NOT to ask questions.
Questions should be posted to the users mailing list which can be accessed at https://ironpython.groups.io/g/users.
Description
System.Reflection.TargetInvocationException: 'Failed to load language 'IronPython 3.4.0b1': No data is available for encoding 850. For information on defining a custom encoding, see the documentation for the Encoding.RegisterProvider method.'
Steps to Reproduce
The code: public class Program { static void Main(string[] args) {
}
Expected behavior:
Shot the greeting in console
Actual behavior:
TargetInvocationException
Versions
IronPython 3.4.0b1