Doing the Impossible? :: Is there anyway to access custom .Net DLLs

Doing the Impossible? :: Is there anyway to access custom .Net DLLs

am 07.12.2007 17:05:13 von 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

Re: Doing the Impossible? :: Is there anyway to access custom .NetDLLs from within Perl

am 07.12.2007 17:39:05 von glex_no-spam

SteveM wrote:
> 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.

Re: Doing the Impossible? :: Is there anyway to access custom .Net

am 07.12.2007 17:50:52 von stevem

On Dec 7, 8:39 am, "J. Gleixner"
wrote:
> SteveM wrote:
> > 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.

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

Re: Doing the Impossible? :: Is there anyway to access custom .Net DLLs from within Perl

am 07.12.2007 18:09:39 von glex_no-spam

SteveM wrote:
> On Dec 7, 8:39 am, "J. Gleixner"
> wrote:
>> SteveM wrote:
>>> 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.
>
> 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

Re: Doing the Impossible? :: Is there anyway to access custom .Net

am 07.12.2007 18:15:31 von Ben Morrow

Quoth SteveM :
> On Dec 7, 8:39 am, "J. Gleixner"
> wrote:
> > SteveM wrote:
> > > 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:
>
> 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).asp x .

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

Re: Doing the Impossible? :: Is there anyway to access custom .Net

am 07.12.2007 18:50:07 von stevem

On Dec 7, 9:15 am, Ben Morrow wrote:
> Quoth SteveM :
>
>
>
>
>
> > On Dec 7, 8:39 am, "J. Gleixner"
> > wrote:
> > > SteveM wrote:
> > > > 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:
>
> > 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- 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