Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to lock .py file
#3
Thanks Metulburr for reply. I already tried Generating *.pyc file and making it bytecoded. My problem is that I am using *.py file in my C# code. As long as i specify file as *.py code works fine but as soon as i define it as *.pyc it gives me this error.
Error:
An exception of type 'System.ArgumentException' occurred in Microsoft.Scripting.dll but was not handled in user code System.ArgumentException was unhandled by user code HResult=-2147024809 Message=File extension '.pyc' is not associated with any language. Source=Microsoft.Scripting StackTrace: at Microsoft.Scripting.Hosting.ScriptRuntime.UseFile(String path) at WpfApp.MainWindow.func() in C:\Users\documents\visual studio 2015\Projects\WpfApp\WpfApp\MainWindow.xaml.cs:line 42 at WpfApp.MainWindow..ctor() in C:\Users\documents\visual studio 2015\Projects\WpfApp\WpfApp\MainWindow.xaml.cs:line 31 InnerException:
My C# code is like this

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using IronPython.Hosting;
using Microsoft.Scripting.Hosting;




namespace WpfApp
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
            func();
        }
        public void func()
        {
                        
            var ipy = Python.CreateRuntime();
            dynamic test = ipy.UseFile("pythonFunctions.pyc");
            lblText.Content=test.calcu(1,2,3,4,5);
            
        }
        
    }
}
It gives me error at line 37. I tried importing dll as reference too but that also didn't work.
Is there any way in C# to convert .pyc back to .py within code itself?
Reply


Messages In This Thread
How to lock .py file - by braveYug - Nov-16-2017, 06:47 AM
RE: How to lock .py file - by metulburr - Nov-16-2017, 12:51 PM
RE: How to lock .py file - by braveYug - Nov-16-2017, 01:31 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Cant find root cause of thread.lock error burlyboys 0 1,590 May-18-2020, 12:51 PM
Last Post: burlyboys
  Read write Lock concerns arvindh 1 2,487 Apr-24-2018, 11:36 PM
Last Post: ODIS
  Brute Force Pad Lock Guesser RedSkeleton007 4 4,063 Mar-03-2018, 07:42 AM
Last Post: RedSkeleton007

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020