Doing the Impossible? :: Is there anyway to access custom .Net DLLsfrom within Perl

S

SteveM

I am thinking from my research that this is probably one of those
things that just can not be done, but just in case I have missed
something let me ask. First off I am NOT talking about accessing Perl
from .Net I know there are ways to do that. What I am wanting to do is
to use in a Perl program a custom .Net library I wrote in C#. Actually
the issue goes bigger then that. We have a great deal of time and
effort invested in a rather large Perl based archatecture in custom
tools and environment. We have recently started investing time and
effort in .Net and C# but do not want to lose the work already done in
Perl. In order to do this we need to be able to call (from inside
Perl) C# and .Net custom crafted DLLs. One example is a library I just
finished that when embeded in a C# program will track the tool's usage
(information about the user, machine, application, etc). This library
works great for C# programs but we would like to use it in the Perl
applications we have as well. Nothing I found as of yet would indicate
that this is possible... does any one have any ideas or know of a way
to do this.
Thanks
-SteveM
 
J

J. Gleixner

SteveM said:
I am thinking from my research that this is probably one of those
things that just can not be done,

Hu.. maybe I don't understand, but searching for "perl 'accessing dll'"
on my favorite Internet search engine showed many links about how
to do this. One of them showed using Win32::API:

http://search.cpan.org/~cosimo/Win32-API-0.47/API.pm

"With this module you can import and call arbitrary functions from
Win32's Dynamic Link Libraries (DLL), without having to write an XS
extension. Note, however, that this module can't do anything (parameters
input and output is limited to simpler cases), and anyway a regular XS
extension is always safer and faster."



Otherwise, you should be able to access it via an XS extension.
 
S

SteveM

Hu.. maybe I don't understand, but searching for "perl 'accessing dll'"
on my favorite Internet search engine showed many links about how
to do this. One of them showed using Win32::API:

http://search.cpan.org/~cosimo/Win32-API-0.47/API.pm

"With this module you can import and call arbitrary functions from
Win32's Dynamic Link Libraries (DLL), without having to write an XS
extension. Note, however, that this module can't do anything (parameters
input and output is limited to simpler cases), and anyway a regular XS
extension is always safer and faster."

Otherwise, you should be able to access it via an XS extension.

Actually I saw these posts, and believe it or not I did spend some
time on google. The problem is not getting perl to use DLLs, as you
stated that can be easily done, but .Net DLLs are a little trickier.
not just with Perl but with almost any non .Net language. I am fairly
certain from what I read that the Win32-API will not work for want I
want to do. Thanks for the suggestion though.
-SteveM
 
J

J. Gleixner

SteveM said:
Actually I saw these posts, and believe it or not I did spend some
time on google. The problem is not getting perl to use DLLs, as you
stated that can be easily done, but .Net DLLs are a little trickier.
not just with Perl but with almost any non .Net language. I am fairly
certain from what I read that the Win32-API will not work for want I
want to do. Thanks for the suggestion though.
-SteveM

Hmmm... OK.. how about this:

http://www.perlmonks.org/?node_id=392275
 
B

Ben Morrow

Quoth SteveM said:
Actually I saw these posts, and believe it or not I did spend some
time on google. The problem is not getting perl to use DLLs, as you
stated that can be easily done, but .Net DLLs are a little trickier.
not just with Perl but with almost any non .Net language. I am fairly
certain from what I read that the Win32-API will not work for want I
want to do. Thanks for the suggestion though.

Note that this is exactly the same as calling a .Net assembly from C,
C++, or any other unmanaged language, so you would have had more luck
searching for that. IIUC the easiest way is to wrap your assembly in a
COM component, and call that using Win32::OLE. See e.g.
http://msdn2.microsoft.com/en-us/library/zsfww439(VS.71).aspx .

Alternatively you could put some effort into writing an Inline::CSharp
module, that knows how to load and start the CLR and then load the
assembly, though I expect that would be quite a lot of work.

Ben
 
S

SteveM

Quoth SteveM <[email protected]>:







Note that this is exactly the same as calling a .Net assembly from C,
C++, or any other unmanaged language, so you would have had more luck
searching for that. IIUC the easiest way is to wrap your assembly in a
COM component, and call that using Win32::OLE. See e.g.http://msdn2.microsoft.com/en-us/library/zsfww439(VS.71).aspx.

Alternatively you could put some effort into writing an Inline::CSharp
module, that knows how to load and start the CLR and then load the
assembly, though I expect that would be quite a lot of work.

Ben- Hide quoted text -

- Show quoted text -

Thanks to all who have responded... the COM angle looks intriguing, I
will investigate that more. This is exactly what I was looking for,
and may prove out to be the answer. Thanks again for your responses
-SteveM
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top