Home: Perl Programming Help: Intermediate:
Win32::API chokes on .NET dependency



aaronmj
New User

Apr 25, 2014, 9:44 AM


Views: 12372
Win32::API chokes on .NET dependency

I have a C DLL that provides an external interface to my software. I've been creating examples in various languages, and I'd like to add one for Perl.

The problem that I am running into is that my DLL loads a .NET class library. When that happens the program crashes out with an unhandled .NET exception because it can't locate the library file. All of the files are in the same directory so I don't know why it is not being found.

Any suggestions?


FishMonger
Veteran / Moderator

Apr 25, 2014, 10:16 AM


Views: 12369
Re: [aaronmj] Win32::API chokes on .NET dependency

So, the perl script is able to call your dll function, but that function needs to load a .NET library to do its work but fails to load that library.

To me that indicates that your dll function needs some additional work.

Is it possible that the dll function expects a particular environment and that your "examples" in the other languages were setting that up but the perl script isn't?


aaronmj
New User

Apr 25, 2014, 11:16 AM


Views: 12367
Re: [FishMonger] Win32::API chokes on .NET dependency

I'm thinking it is some kind of environment issue--like a dll search path. I don't have any idea where that might be, though.

These are really, REALLY trivial examples I'm building; on the order of 10 lines. There's nothing at all being set up in the other examples. My user base is not likely to have much coding experience, so I'm just trying to give them a boilerplate to build off of.


FishMonger
Veteran / Moderator

Apr 25, 2014, 11:36 AM


Views: 12364
Re: [aaronmj] Win32::API chokes on .NET dependency

Environment settings in perl are stored in the %ENV hash. If you need to adjust the path environment, you would modify the value of $ENV{PATH}.

Besides modifying existing environment settings, you can also add/delete environment items via the %ENV hash.


(This post was edited by FishMonger on Apr 25, 2014, 11:37 AM)


aaronmj
New User

Apr 28, 2014, 7:10 AM


Views: 11730
Re: [FishMonger] Win32::API chokes on .NET dependency

The path variable doesn't seem to be the issue. It contains all the right locations. I tried concatenating the application directory to the path, but that didn't help.


FishMonger
Veteran / Moderator

Apr 28, 2014, 8:12 AM


Views: 11707
Re: [aaronmj] Win32::API chokes on .NET dependency

I think you need to focus your troubleshooting on your DLL function(s).


Quote
the program crashes out with an unhandled .NET exception

That error is telling you that you need to add additional error handling in the dll function. After adding that additional error handling, you may get a more descriptive message pointing to the source of the problem.