OpenOffice.org Forum at OOoForum.orgThe OpenOffice.org Forum
 
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

Cannot find Bootstrap method - upgraded form OO 2.4 to 3.0
Goto page 1, 2  Next
 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API
View previous topic :: View next topic  
Author Message
kasperih
General User
General User


Joined: 17 Oct 2008
Posts: 7

PostPosted: Mon Oct 20, 2008 1:28 am    Post subject: Cannot find Bootstrap method - upgraded form OO 2.4 to 3.0 Reply with quote

Hi

I recently made an application and needed a way in C# to open an .odt file and convert to and pdf file before opening open office, I managed to find a way but after upgrading to 3.0 this doesn't work anymore.

In my visual studio project I reference 4 dll's; cli_basetypes.dll, cli_cppuhelper, cli_types.dll and cli_ure.dll

Here is the code that worked before:

private static string SaveAsPDF(string filename)
{
try
{
XComponentContext localContext = uno.util.Bootstrap.bootstrap();

XMultiServiceFactory multiServiceFactory = (XMultiServiceFactory) localContext.getServiceManager();

XComponentLoader componentLoader =
(XComponentLoader) multiServiceFactory.createInstance("com.sun.star.frame.Desktop");

//sett the property
PropertyValue[] propertyValue = new PropertyValue[1];
PropertyValue aProperty = new PropertyValue();
aProperty.Name = "Hidden";
aProperty.Value = new uno.Any(true);
propertyValue[0] = aProperty;

XComponent xComponent =
componentLoader.loadComponentFromURL(PathConverter(filename), "_blank", 0, propertyValue);

PropertyValue[] saveProps = new PropertyValue[1];
saveProps[0] = new PropertyValue();
saveProps[0].Name = "FilterName";
saveProps[0].Value = new Any("writer_pdf_Export");

string pdffilename = PathConverter(filename.Replace(".odt", ".pdf"));

((XStorable) xComponent).storeToURL(pdffilename, saveProps);

xComponent.dispose();

return pdffilename;
}
catch(Exception e)
{
throw new ODTException("Could not save the .odt document as pdf",ExceptionSeverity.Warn, e);
}
}

Could anyone help me make this work with openoffice 3? It is not important that it is not backward comptatible, so if anyone know how to make it work only with openoffice 3 its fine.

By the way I am running on a win XP machine.
Back to top
View user's profile Send private message
JohnV
Administrator
Administrator


Joined: 07 Mar 2003
Posts: 9183
Location: Lexinton, Kentucky, USA

PostPosted: Mon Oct 20, 2008 5:25 am    Post subject: Reply with quote

Does this help?
http://user.services.openoffice.org/en/forum/viewtopic.php?f=44&t=10825&start=0&st=0&sk=t&sd=a&hilit=bootstrap

Please do not cross post.
Back to top
View user's profile Send private message
rs2.pt
General User
General User


Joined: 20 Oct 2008
Posts: 8

PostPosted: Mon Oct 20, 2008 8:25 am    Post subject: Reply with quote

Hi
I have same problem... have a Windows Form aplication that uses a Calc to do calculations, giving to the user a simple Windows Forms interface.
It was working on 2.4.1, but since 3.0 came out, I uninstalled the 2.41 and installed the 3.00.

After some trouble on replacing dlls references (3.0 puts them on GAC) I have a exception on my line bootstrap:

// get the remote office component context
m_xContext = uno.util.Bootstrap.bootstrap();
MessageBox.Show("Connected to a running office ...");

Cant find any info, with a simple tutorial like this one (for OO 2.0)
www.opendocument4all.com/download/OpenOffice.net.pdf
that demoed how to use/acess to OO apps by c#
Back to top
View user's profile Send private message
hol.sten
Super User
Super User


Joined: 14 Nov 2004
Posts: 3533
Location: Hamburg, Germany

PostPosted: Mon Oct 20, 2008 12:33 pm    Post subject: Reply with quote

JohnV wrote:
Does this help?
http://user.services.openoffice.org/en/forum/viewtopic.php?f=44&t=10825&start=0&st=0&sk=t&sd=a&hilit=bootstrap

That was my first thought, too. But I don't think that that might be the problem, because Java uses JAR files (as mentioned in the thread), whereas C# uses DLLs. And the missing DLLs are really not present after installing OOo 3.0.0. No idea why.
Back to top
View user's profile Send private message
kasperih
General User
General User


Joined: 17 Oct 2008
Posts: 7

PostPosted: Mon Oct 20, 2008 9:24 pm    Post subject: Reply with quote

First of all I seem to recall that I read somewhere that some of the cli dll's should be replvaed by new ones. The only place I found these dll's was in the openoffice cab installation file. What is the GAC and how can I locate whats in it?

I have tried to google a lot regarding OOo 3 and C# but sadly most people seem to use java but that is noy an option for me. The javapostings haven't helped so far.
Back to top
View user's profile Send private message
rs2.pt
General User
General User


Joined: 20 Oct 2008
Posts: 8

PostPosted: Tue Oct 21, 2008 12:42 am    Post subject: Reply with quote

kasperih wrote:
First of all I seem to recall that I read somewhere that some of the cli dll's should be replvaed by new ones. The only place I found these dll's was in the openoffice cab installation file. What is the GAC and how can I locate whats in it?

I have tried to google a lot regarding OOo 3 and C# but sadly most people seem to use java but that is noy an option for me. The javapostings haven't helped so far.


DLLs are now in GAC (Global Assembly Cache) in "C:\Windows\assembly" usualy viewing by Explorer you will see a king of viewing cache, you must navigate by a command line prompt so you can copy the dlls.

I copyed the required dlls and replaced on my project, then refreneced them, usign similar method of the document in: www.opendocument4all.com/download/OpenOffice.net.pdf
(this document is for 2.0 up to 3.0 verison)

As some could possibly found already on Google or http://wiki.services.openoffice.org/wiki/Documentation/DevGuide/ProUNO/CLI/CLI_Language_Binding
cli_types.dll has been repaced on 3.0 by cli_oootypes.dll and some other changes (read the link on doc)
I replaced (as sid before) in my project, my cli_types.dll by cli_oootypes.dll and the other overwrighted the other old ones. Re-referenced all again, the project compiled ok but when run/debug throws an exception when hitting the line where create the bootstrap "m_xContext = uno.util.Bootstrap.bootstrap();"

and finding info for c# using/acessing the 3.0 new OOffice its a pain.
Back to top
View user's profile Send private message
hol.sten
Super User
Super User


Joined: 14 Nov 2004
Posts: 3533
Location: Hamburg, Germany

PostPosted: Tue Oct 21, 2008 1:19 am    Post subject: Reply with quote

rs2.pt wrote:
but when run/debug throws an exception when hitting the line where create the bootstrap "m_xContext = uno.util.Bootstrap.bootstrap();"

And which exception? And where are your DLLs located now? Can you copy the DLLs you need from "C:\Windows\assembly" into a new subfolder "assembly" of the folder "C:\Program Files\OpenOffice.org 3\program" and reference them in your project? Does that prevent the exception?
Back to top
View user's profile Send private message
rs2.pt
General User
General User


Joined: 20 Oct 2008
Posts: 8

PostPosted: Tue Oct 21, 2008 1:38 am    Post subject: Reply with quote

hol.sten wrote:
rs2.pt wrote:
but when run/debug throws an exception when hitting the line where create the bootstrap "m_xContext = uno.util.Bootstrap.bootstrap();"

And which exception? And where are your DLLs located now? Can you copy the DLLs you need from "C:\Windows\assembly" into a new subfolder "assembly" of the folder "C:\Program Files\OpenOffice.org 3\program" and reference them in your project? Does that prevent the exception?


Hi

"System.Runtime.InteropServices.SEHException: External component has thrown an exception.\r\n at cppu.bootstrap(Reference<com::sun::star::uno::XComponentContext>* )\r\n at uno.util.Bootstrap.bootstrap()\r\n at SiaccXpressOO.Form1..ctor() in D:\\WorkTFS\\OpenOfficeSandBox\\SiaccXpressOO\\Form1.cs:line 67"

I have a folder in my project named Resources with the Dlls; and my project referes those dlls. This is a small project I created just to test the concept. because my main project still in 2.4.1 OO and I need to make the most ppossible minimal changes so it can work in 3.0.


maybe I am missing something, and the convertion to 3.0 has some more turn outs.
this small project worked on 2.4.1
it has a windows forms with some textboxs and a button and it makes calculations on a Calc sheet that has some formulas.
The exception, as I understand, will not open the Calc...
Back to top
View user's profile Send private message
hol.sten
Super User
Super User


Joined: 14 Nov 2004
Posts: 3533
Location: Hamburg, Germany

PostPosted: Tue Oct 21, 2008 2:36 am    Post subject: Reply with quote

rs2.pt wrote:
I have a folder in my project named Resources with the Dlls; and my project referes those dlls.

Exactly that might cause the problem. Perhaps the DLLs are as dumb as the JARs to locate soffice.exe. With the JARs that was no problem with OOo 2.x, because they were located in a folder, where they could find soffice.exe. But since OOo 3.0 and the new folder structure, they cannot find soffice.exe any longer.

So my question again: Can you copy the DLLs you need from "C:\Windows\assembly" into a new subfolder "assembly" of the folder "C:\Program Files\OpenOffice.org 3\program" and reference them in your project? Does that prevent the exception?
Back to top
View user's profile Send private message
rs2.pt
General User
General User


Joined: 20 Oct 2008
Posts: 8

PostPosted: Tue Oct 21, 2008 2:47 am    Post subject: Reply with quote

hol.sten wrote:
rs2.pt wrote:
I have a folder in my project named Resources with the Dlls; and my project referes those dlls.

Exactly that might cause the problem. Perhaps the DLLs are as dumb as the JARs to locate soffice.exe. With the JARs that was no problem with OOo 2.x, because they were located in a folder, where they could find soffice.exe. But since OOo 3.0 and the new folder structure, they cannot find soffice.exe any longer.

So my question again: Can you copy the DLLs you need from "C:\Windows\assembly" into a new subfolder "assembly" of the folder "C:\Program Files\OpenOffice.org 3\program" and reference them in your project? Does that prevent the exception?


hi sorry, forgot that last point
did as you sugested but still same exception,
but even if it worked, it will not be an option to me because my App will be deployed via ClicOnce for many clients and could not aford to make this copy from GAC on all computers. I think some of them will not even had all necessary Policies to do so. unless the aplication after compiled used the client GAC assemblies and they gained some smartness or so.
Back to top
View user's profile Send private message
hol.sten
Super User
Super User


Joined: 14 Nov 2004
Posts: 3533
Location: Hamburg, Germany

PostPosted: Tue Oct 21, 2008 3:01 am    Post subject: Reply with quote

rs2.pt wrote:
hi sorry, forgot that last point

No problem, it was nothing but clutching at straws anyway. So at least you know now, that moving around the DLLs does not cause your problem...
Back to top
View user's profile Send private message
kasperih
General User
General User


Joined: 17 Oct 2008
Posts: 7

PostPosted: Tue Oct 21, 2008 10:39 pm    Post subject: Reply with quote

I tried to do the same thing as you rs2.pt and I ot the exacxt same exception
Back to top
View user's profile Send private message
rs2.pt
General User
General User


Joined: 20 Oct 2008
Posts: 8

PostPosted: Wed Oct 22, 2008 12:59 am    Post subject: Reply with quote

kasperih wrote:
I tried to do the same thing as you rs2.pt and I ot the exacxt same exception


Hi.
As I understand, the problem is finding the app to call it and run it.
In my case is to open an ODS with Calc.exe, so with this problem I cant even cant get Calc.exe run.

I understand the problem, of not getting found, now I cant find a solution, I am about 2 days now trying to find info of this on net, today I will give a on day more so maybe get some answers from some foruns.

at this point I am looking to find simple example, of opening a ODS file with calc using C# on VistualStudio .net on new 3.0 OpenOffice... just that.
Back to top
View user's profile Send private message
parc
Power User
Power User


Joined: 09 Nov 2007
Posts: 55
Location: Hamburg

PostPosted: Thu Oct 23, 2008 1:40 am    Post subject: Reply with quote

rs2.pt wrote:
Hi
I have same problem... have a Windows Form aplication that uses a Calc to do calculations, giving to the user a simple Windows Forms interface.
It was working on 2.4.1, but since 3.0 came out, I uninstalled the 2.41 and installed the 3.00.

After some trouble on replacing dlls references (3.0 puts them on GAC) I have a exception on my line bootstrap:

// get the remote office component context
m_xContext = uno.util.Bootstrap.bootstrap();
MessageBox.Show("Connected to a running office ...");

Cant find any info, with a simple tutorial like this one (for OO 2.0)
www.opendocument4all.com/download/OpenOffice.net.pdf
that demoed how to use/acess to OO apps by c#


Perhaps you might lok at:

http://www.oooforum.org/forum/viewtopic.phtml?t=76356&start=0&postdays=0&postorder=asc&highlight=[/url]
Back to top
View user's profile Send private message Visit poster's website
kasperih
General User
General User


Joined: 17 Oct 2008
Posts: 7

PostPosted: Sun Oct 26, 2008 11:56 pm    Post subject: Reply with quote

Hi

My app is now working by following Parc's instruction, thanks.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API All times are GMT - 8 Hours
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group