Quantcast
Channel: ActiveState Community Site - PDK discussion
Viewing all articles
Browse latest Browse all 116

Run time error 'Can't locate (perl) object method' under Visual Studio 2013 C#

$
0
0

I just installed PDK under Win 7, with the latest ActiveState Community perl 64 bit. I'm trying to wrap my first perl code into a DLL so I can use Visual Studio 2013 Express to build a nice gui, with the Perl code tied in, but am getting a strange run-time error as follows:

I have this 'test_perlnet.pl' file :

use warnings;
use strict;

# Putting the following 'use Log::Report' line here (before the package
# and subroutine definition below) causes a Visual Studio
# run time error when I try to call 'do_some_thing()'

use Log::Report;  # Or, using many other perl packages also gives error

# Declare my own package now:
package test_perlnet;

=for interface
    [interface: pure]
    str do_some_thing();
=cut

sub do_some_thing {
      return "hello there.";
}

# But putting the 'use Log::Report' line here (after the package
# and subroutine definition above) works just fine;
# Visual Studio can see and call 'do_some_thing()' and I get "hello there."
# in the C# callback.

#use Log::Report;

I created a test_perlnet.dll (using plc) and added it into my C sharp project references. I then invoke the perl code from this C# button-click callback:

private void Button_Click_1(object sender, RoutedEventArgs e)
{
   test_perlnet tp = new test_perlnet();
   Console.WriteLine("Message from the perl code: {0}", tp.do_some_thing());
}

But when I click the button, I get this Visual Studio 2013 Express error if I put the 'use Log::Report;' line before my package definition in the perl code, as shown above.

An unhandled exception of type 'PerlRuntime.PerlException' occurred in test_perlnet.dll
Additional information: Can't locate object method "do_some_thing" via package "test_perlnet"

Why is this? I really need to 'use' other perl, standard libraries in my code. Thank you!


Viewing all articles
Browse latest Browse all 116

Trending Articles