Discussion:
[Ikvm-developers] Problem with calling Fop C# from another assembly
Nguyen, Thang
2007-04-16 07:25:35 UTC
Permalink
hi,

my problem is: I put the fop code to a dll (reference to fop.dll, gnuclasspath.dll, ikvmruntime.dll) and call it from the executable and it didn't work (1).

But if I put the fop code into the executable (2) then everything works fine.

in case (1) even I already have:

java.lang.System.setProperty("javax.xml.parsers.SAXParserFactory",
"org.apache.xerces.jaxp.SAXParserFactoryImpl");

but

_saxFactory = SAXParserFactory.newInstance();

still returns a gnu sax factory instead of xerces factory

my guess is current domain needs to load the fop.dll, I did make a try but can not solve the problem. Plz help.

thanks,

Thang.


This email may contain material that is confidential, privileged and/or attorney work product for the sole use of the intended recipient. Any review, reliance or distribution by others or forwarding without express permission is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies.
Jeroen Frijters
2007-04-16 07:36:36 UTC
Permalink
Post by Nguyen, Thang
my problem is: I put the fop code to a dll (reference to fop.dll,
gnuclasspath.dll, ikvmruntime.dll) and call it from the executable and
it didn't work (1).
But if I put the fop code into the executable (2) then everything works fine.
The system class loader needs to see the xerces resources. In IKVM the system class loader is the assembly class loader associated with the entry assembly (i.e. the .exe assembly). So you need to make sure that your .exe links with the fop.dll (for example by adding a typeof(some.fop.type) to your .exe code).

Regards,
Jeroen
Nguyen, Thang
2007-04-17 04:23:25 UTC
Permalink
yes, thank you, typeof did the work. Is there any other way to not to touch the .exe assembly (at least I don't have to reference to fop.dll) by loading assembly at runtime or reflection, .. to do this ? I tried a few but couldn't find any.

I already read on your web-blog about architecture of the class loader, it seems that in previous version I can access the system class loader but it's not possible now ?

thanks,

Thang.


-----Original Message-----
From: Jeroen Frijters [mailto:***@sumatra.nl]
Sent: Mon 4/16/2007 2:36 PM
To: Nguyen, Thang; ikvm-***@lists.sourceforge.net
Cc:
Subject: RE: [Ikvm-developers] Problem with calling Fop C# from another assembly
Post by Nguyen, Thang
my problem is: I put the fop code to a dll (reference to fop.dll,
gnuclasspath.dll, ikvmruntime.dll) and call it from the executable and
it didn't work (1).
But if I put the fop code into the executable (2) then everything works fine.
The system class loader needs to see the xerces resources. In IKVM the system class loader is the assembly class loader associated with the entry assembly (i.e. the .exe assembly). So you need to make sure that your .exe links with the fop.dll (for example by adding a typeof(some.fop.type) to your .exe code).

Regards,
Jeroen






This email may contain material that is confidential, privileged and/or attorney work product for the sole use of the intended recipient. Any review, reliance or distribution by others or forwarding without express permission is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies.
Jeroen Frijters
2007-04-17 05:25:09 UTC
Permalink
Hi Thang,

You can try setting the thread context class loader to the fop.dll class loader.

Regards,
Jeroen
Post by Nguyen, Thang
-----Original Message-----
Sent: Tuesday, April 17, 2007 06:23
Subject: RE: [Ikvm-developers] Problem with calling Fop C# from another
assembly
yes, thank you, typeof did the work. Is there any other way to not to
touch the .exe assembly (at least I don't have to reference to fop.dll)
by loading assembly at runtime or reflection, .. to do this ? I tried a
few but couldn't find any.
I already read on your web-blog about architecture of the class loader,
it seems that in previous version I can access the system class loader
but it's not possible now ?
thanks,
Thang.
-----Original Message-----
Sent: Mon 4/16/2007 2:36 PM
Subject: RE: [Ikvm-developers] Problem with calling Fop C# from
another assembly
Post by Nguyen, Thang
my problem is: I put the fop code to a dll (reference to fop.dll,
gnuclasspath.dll, ikvmruntime.dll) and call it from the executable
and
Post by Nguyen, Thang
it didn't work (1).
But if I put the fop code into the executable (2) then everything works fine.
The system class loader needs to see the xerces resources. In IKVM the
system class loader is the assembly class loader associated with the
entry assembly (i.e. the .exe assembly). So you need to make sure that
your .exe links with the fop.dll (for example by adding a
typeof(some.fop.type) to your .exe code).
Regards,
Jeroen
This email may contain material that is confidential, privileged and/or
attorney work product for the sole use of the intended recipient. Any
review, reliance or distribution by others or forwarding without
express permission is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.
Nguyen, Thang
2007-04-17 07:29:03 UTC
Permalink
thank you again, I did it with the below codes

org.apache.xerces.jaxp.SAXParserFactoryImpl sax = new org.apache.xerces.jaxp.SAXParserFactoryImpl();
java.lang.ClassLoader cl = sax.getClass().getClassLoader();
java.lang.Thread.currentThread().setContextClassLoader(cl);

Thang.


-----Original Message-----
From: Jeroen Frijters [mailto:***@sumatra.nl]
Sent: Tue 4/17/2007 12:25 PM
To: Nguyen, Thang; ikvm-***@lists.sourceforge.net
Cc:
Subject: RE: [Ikvm-developers] Problem with calling Fop C# from another assembly

Hi Thang,

You can try setting the thread context class loader to the fop.dll class loader.

Regards,
Jeroen
Post by Nguyen, Thang
-----Original Message-----
Sent: Tuesday, April 17, 2007 06:23
Subject: RE: [Ikvm-developers] Problem with calling Fop C# from another
assembly
yes, thank you, typeof did the work. Is there any other way to not to
touch the .exe assembly (at least I don't have to reference to fop.dll)
by loading assembly at runtime or reflection, .. to do this ? I tried a
few but couldn't find any.
I already read on your web-blog about architecture of the class loader,
it seems that in previous version I can access the system class loader
but it's not possible now ?
thanks,
Thang.
-----Original Message-----
Sent: Mon 4/16/2007 2:36 PM
Subject: RE: [Ikvm-developers] Problem with calling Fop C# from
another assembly
Post by Nguyen, Thang
my problem is: I put the fop code to a dll (reference to fop.dll,
gnuclasspath.dll, ikvmruntime.dll) and call it from the executable
and
Post by Nguyen, Thang
it didn't work (1).
But if I put the fop code into the executable (2) then everything works fine.
The system class loader needs to see the xerces resources. In IKVM the
system class loader is the assembly class loader associated with the
entry assembly (i.e. the .exe assembly). So you need to make sure that
your .exe links with the fop.dll (for example by adding a
typeof(some.fop.type) to your .exe code).
Regards,
Jeroen
This email may contain material that is confidential, privileged and/or
attorney work product for the sole use of the intended recipient. Any
review, reliance or distribution by others or forwarding without
express permission is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.
This email may contain material that is confidential, privileged and/or attorney work product for the sole use of the intended recipient. Any review, reliance or distribution by others or forwarding without express permission is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies.
Loading...