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

Determine if a large file is loaded, using CLI and C#
Goto page 1, 2  Next
 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Code Snippets
View previous topic :: View next topic  
Author Message
LarsB
OOo Advocate
OOo Advocate


Joined: 31 Aug 2005
Posts: 445
Location: Hamburg, Germany

PostPosted: Sun Nov 20, 2005 8:42 am    Post subject: Determine if a large file is loaded, using CLI and C# Reply with quote

Hi,

Problem: You have to determine if a large file is complete
loaded to manipulate or save it.

In Java, C++ or OO Basic you could implement and register
the com.sun.star.document.XEventListener class within
the OfficeDocument class.

Fine, but with the current CLI .net implementation this
isn't possible, because the OfficeDocument class isn't
available. This example will show a workaround which
first load a blank document, then get the current frame,
attache an own implementation of the XFrameActionListener
and at least load the specific file into this frame.
If the file is loaded the frame will fire a FrameActionEvent
of the COMPONENT_ATTACHED type. If you recieve this you
could manipulate or save the file.

Code:

using System;
using unoidl.com.sun.star.lang;
using unoidl.com.sun.star.uno;
using unoidl.com.sun.star.bridge;
using unoidl.com.sun.star.frame;

namespace ConsoleApplication1
{
   
   /// <summary>
   /// Problem: You have to determine if a file is complete
   /// loaded to manipulate or save it.
   ///
   /// In Java, C++ or OO Basic you could implement and register
   /// the com.sun.star.document.XEventListener class within
   /// the OfficeDocument class.
   /// Fine, but with the current CLI .net implementation this
   /// isn't possible, because the OfficeDocument class isn't
   /// available. This example will show a workaround which
   /// first load a blank document, then get the current frame,
   /// attache an own implementation of the XFrameActionListener
   /// and at least load the specific file into this frame.
   /// If the file is loaded the frame will fire a FrameActionEvent
   /// of the COMPONENT_ATTACHED type. If you recieve this you
   /// could manipulate or save the file.
   /// </summary>
   class Class1
   {
      [STAThread]
      static void Main(string[] args)
      {
         //Get a ComponentContext

         unoidl.com.sun.star.uno.XComponentContext xLocalContext =
            uno.util.Bootstrap.bootstrap();
         //Get MultiServiceFactory
         unoidl.com.sun.star.lang.XMultiServiceFactory xRemoteFactory =
            (unoidl.com.sun.star.lang.XMultiServiceFactory)
            xLocalContext.getServiceManager();
         //Get a CompontLoader
         XComponentLoader aLoader                              =
            (XComponentLoader) xRemoteFactory.createInstance( "com.sun.star.frame.Desktop" );
         //Load a new writer instance
         XComponent xComponent = initDocument(aLoader,
               "private:factory/swriter", "_blank");
         //Get the current frame
         XFrame xframe         = ((XDesktop)aLoader).getCurrentFrame();
         //Register my FrameActionListener
         xframe.addFrameActionListener(new MyFrameActionListener());         
         //Load a large file - the FrameActionEvent COMPONENT_ATTACHED
         //will fired if the document load is complete
         //Notice: Use _self as target, to make shure that no
         //new OpenOffice instance will start
         initDocument(((XComponentLoader)xframe),
            @"file:///D:/Download/OpenOffice/UNOCpp_AP01.sxw",
            "_self");
         //Wait for input
         Console.ReadLine();
      }

      /// <summary>
      /// Load a given file or create a new blank file
      /// </summary>
      /// <param name="aLoader">A ComponentLoader</param>
      /// <param name="file">The file</param>
      /// <param name="target">The target</param>
      /// <returns>Th Component</returns>
      static XComponent initDocument(
         XComponentLoader aLoader, string file, string target
         )
      {
         XComponent xComponent = aLoader.loadComponentFromURL(
            file, target, 0,
            new unoidl.com.sun.star.beans.PropertyValue[0] );

         return xComponent;
      }
   }

   /// <summary>
   /// XFrameActionListener implementation
   /// </summary>
   public class MyFrameActionListener : XFrameActionListener
   {
      #region XFrameActionListener Member

      /// <summary>
      /// Called when ever a frame action occurs
      /// </summary>
      /// <param name="Action">The action</param>
      public void frameAction(FrameActionEvent Action)
      {
         if(Action.Action == FrameAction.FRAME_UI_ACTIVATED)
            Console.WriteLine("FrameEvent FRAME_UI_ACTIVATED");
         else if(Action.Action == FrameAction.FRAME_ACTIVATED)
            Console.WriteLine("FrameEvent FRAME_ACTIVATED");
         else if(Action.Action == FrameAction.CONTEXT_CHANGED)
            Console.WriteLine("FrameEvent CONTEXT_CHANGED");
         //If these occours, the file is complete loaded
         else if(Action.Action == FrameAction.COMPONENT_ATTACHED)
            Console.WriteLine("FrameEvent COMPONENT_ATTACHED");
      }

      #endregion

      #region XEventListener Member
      /// <summary>
      /// Disposed
      /// </summary>
      /// <param name="Source">The event object</param>
      public void disposing(EventObject Source)
      {
         Console.WriteLine("Frame disposed!");
      }

      #endregion
   }
}

Hope this wil help Wink

Cheers
LarsB
_________________
AODC - A free OpenDocument Converter
AODL - An independent OpenDocument Library C#
EmbeddedOpenOffice .net UserControl C#
EmbeddedOpenOffice Visual Studio .net Add In

http://www.OpenDocument4all.com/
Back to top
View user's profile Send private message Visit poster's website
007dad
General User
General User


Joined: 03 Jan 2006
Posts: 9

PostPosted: Tue Jan 03, 2006 1:43 pm    Post subject: my computer was too fast for the xFrame Reply with quote

my computer was too fast for the xFrame
this solved the problem:

Code:

xframe   = null;
while(xframe == null)
{
   Thread.Sleep(100);
   xframe         = ((XDesktop)aLoader).getCurrentFrame();
}
Back to top
View user's profile Send private message Visit poster's website
LarsB
OOo Advocate
OOo Advocate


Joined: 31 Aug 2005
Posts: 445
Location: Hamburg, Germany

PostPosted: Fri Jan 06, 2006 12:32 am    Post subject: Advantage Reply with quote

Hi,

thank you for your reply. Normally the side effect you have will only occour if there isn't already running an OpenOffice process in the windows processes. The loading of blank document is as fast as possible.

Cheers
LarsB
_________________
AODC - A free OpenDocument Converter
AODL - An independent OpenDocument Library C#
EmbeddedOpenOffice .net UserControl C#
EmbeddedOpenOffice Visual Studio .net Add In

http://www.OpenDocument4all.com/
Back to top
View user's profile Send private message Visit poster's website
007dad
General User
General User


Joined: 03 Jan 2006
Posts: 9

PostPosted: Fri Jan 06, 2006 4:08 pm    Post subject: Reply with quote

I love your call back system
your work helped me alot

do you know how I can get an xframe or any thing to "addFrameActionListener" with
when the xComponent is loaded with a PropertyValue of "Hidden" = false
Back to top
View user's profile Send private message Visit poster's website
007dad
General User
General User


Joined: 03 Jan 2006
Posts: 9

PostPosted: Mon Jan 09, 2006 3:15 pm    Post subject: Reply with quote

The code works great from commandline execution
but as .Net web page it hangs on the line:
xLocalContext = uno.util.Bootstrap.bootstrap();

Does any know what permissions I need to add to allow this code to work from IIS?
Back to top
View user's profile Send private message Visit poster's website
LarsB
OOo Advocate
OOo Advocate


Joined: 31 Aug 2005
Posts: 445
Location: Hamburg, Germany

PostPosted: Mon Jan 09, 2006 8:59 pm    Post subject: User in machine.config Reply with quote

Hi,

you have to change the ASP.net user which is the owner of the executing webpage. You can do this via the machine.config try to run it as System or create a new user and start with the new user at least one time OO, so that OO could write the settings for this user.

Cheers
LarsB
_________________
AODC - A free OpenDocument Converter
AODL - An independent OpenDocument Library C#
EmbeddedOpenOffice .net UserControl C#
EmbeddedOpenOffice Visual Studio .net Add In

http://www.OpenDocument4all.com/
Back to top
View user's profile Send private message Visit poster's website
007dad
General User
General User


Joined: 03 Jan 2006
Posts: 9

PostPosted: Tue Jan 10, 2006 4:15 pm    Post subject: Reply with quote

your answers are fantastic
you have been increadably helpful
I hope you dont mind a fiew more questions

the following code works great for local html files
but crashes when I load html files from the web or localhost
do you think I need some opening propperty value that I am not thinking of?

Code:

using System;
using System.Reflection;
using System.Threading;
using System.Globalization;
using System.Text.RegularExpressions;

//// C:\Program Files\OpenOffice.org 2.0\program\assembly\*.dll
//// [assembly: CLSCompliant(false)]
using unoidl.com.sun.star.lang; 
using unoidl.com.sun.star.uno; 
using unoidl.com.sun.star.bridge; 
using unoidl.com.sun.star.frame;
using unoidl.com.sun.star.beans;

namespace htmlToPdf
{
   /// http://opendocument4all.com/content/view/68/1/
   /// http://www.oooforum.org/forum/viewtopic.phtml?t=27372&highlight=unoidl+com+sun+star+uno
   /// http://www.oooforum.org/forum/viewtopic.phtml?t=29198&highlight=storetourl+unoidl+com+sun+star+uno
   /// http://api.openoffice.org/docs/common/ref/com/sun/star/frame/XComponentLoader.html
   /// <summary>
   ///
   ///
/*
         To assign permissions:
            Double-click Administrative Tools, and then double-click Component Services.
            In the Component Services snap-in, expand Computers, expand My Computer, and double-click DCOM Config.
            In the right pane, locate the program OpenOffice.org.
            Right-click the program name, and then select Properties.
            On the Security tab, in the Launch and Activation Permissions group box, select Customize, and then click Edit.
            Add ASP.NET and BATCH to each custom list

            In C:\WINNT\Microsoft.NET\Framework\v1.0.3705\CONFIG\machine.config
            change userName="machine" to userName="system"
            Special users: "SYSTEM": run as localsystem (high privilege admin) account.
            "machine": run as low privilege user account named "ASPNET".
         
            Win2K you also have to allow the ASPNET to act as part of the operating system
            (Windows XP and .NET server don't require this setting).
            Select Start/Programs/Administrative Tools/Local Security Policy.
            Then select Local Policies/User Rights Assignment/Act as part of the operating system.
            Add the local ASPNET account.
         */
   ///
   /// Below is a complete list of the OpenOffice filters that are registered in 1.1rc1. The list is truly impressive.
/*
   'AportisDoc Palm DB',
   'BMP - MS Windows',
   'CGM - Computer Graphics Metafile',
   'DIF',
   'DXF - AutoCAD Interchange',
   'DocBook File',
   'EMF - MS Windows Metafile',
   'EPS - Encapsulated PostScript',
   'Flat XML File',
   'GIF - Graphics Interchange',
   'HTML',
   'HTML (StarCalc)',
   'HTML (StarWriter)',
   'JPG - JPEG',
   'Lotus',
   'MET - OS/2 Metafile',
   'MS Excel 4.0',
   'MS Excel 4.0 Vorlage/Template',
   'MS Excel 5.0/95',
   'MS Excel 5.0/95 Vorlage/Template',
   'MS Excel 95',
   'MS Excel 95 Vorlage/Template',
   'MS Excel 97',
   'MS Excel 97 Vorlage/Template',
   'MS PowerPoint 97',
   'MS PowerPoint 97 Vorlage',
   'MS WinWord 6.0',
   'MS Word 95',
   'MS Word 95 Vorlage',
   'MS Word 97',
   'MS Word 97 Vorlage',
   'MathML XML (Math)',
   'MathType 3.x',
   'Microsoft Word 2003 XML',
   'PBM - Portable Bitmap',
   'PCT - Mac Pict',
   'PCX - Zsoft Paintbrush',
   'PGM - Portable Graymap',
   'PNG - Portable Network Graphic',
   'PPM - Portable Pixelmap',
   'PSD - Adobe Photoshop',
   'RAS - Sun Rasterfile',
   'Rich Text Format',
   'Rich Text Format (StarCalc)',
   'SGF - StarOffice Writer SGF',
   'SGV - StarDraw 2.0',
   'SVM - StarView Metafile',
   'SYLK',
   'StarCalc 1.0',
   'StarCalc 3.0',
   'StarCalc 3.0 Vorlage/Template',
   'StarCalc 4.0',
   'StarCalc 4.0 Vorlage/Template',
   'StarCalc 5.0',
   'StarCalc 5.0 Vorlage/Template',
   'StarChart 3.0',
   'StarChart 4.0',
   'StarChart 5.0',
   'StarDraw 3.0',
   'StarDraw 3.0 (StarImpress)',
   'StarDraw 3.0 Vorlage',
   'StarDraw 3.0 Vorlage (StarImpress)',
   'StarDraw 5.0',
   'StarDraw 5.0 (StarImpress)',
   'StarDraw 5.0 Vorlage',
   'StarDraw 5.0 Vorlage (StarImpress)',
   'StarImpress 4.0',
   'StarImpress 4.0 Vorlage',
   'StarImpress 5.0',
   'StarImpress 5.0 (packed)',
   'StarImpress 5.0 Vorlage',
   'StarMath 2.0',
   'StarMath 3.0',
   'StarMath 4.0',
   'StarMath 5.0',
   'StarOffice XML (Calc)',
   'StarOffice XML (Chart)',
   'StarOffice XML (Draw)',
   'StarOffice XML (Impress)',
   'StarOffice XML (Math)',
   'StarOffice XML (Writer)',
   'StarWriter 1.0',
   'StarWriter 2.0',
   'StarWriter 3.0',
   'StarWriter 3.0 (StarWriter/GlobalDocument)',
   'StarWriter 3.0 (StarWriter/Web)',
   'StarWriter 3.0 Vorlage/Template',
   'StarWriter 4.0',
   'StarWriter 4.0 (StarWriter/GlobalDocument)',
   'StarWriter 4.0 (StarWriter/Web)',
   'StarWriter 4.0 Vorlage/Template',
   'StarWriter 4.0/GlobalDocument',
   'StarWriter 5.0',
   'StarWriter 5.0 (StarWriter/GlobalDocument)',
   'StarWriter 5.0 (StarWriter/Web)',
   'StarWriter 5.0 Vorlage/Template',
   'StarWriter 5.0/GlobalDocument',
   'StarWriter DOS',
   'StarWriter/Web 4.0 Vorlage/Template',
   'StarWriter/Web 5.0 Vorlage/Template',
   'TGA - Truevision TARGA',
   'TIF - Tag Image File',
   'Text',
   'Text (StarWriter/Web)',
   'Text (encoded)',
   'Text (encoded) (StarWriter/GlobalDocument)',
   'Text (encoded) (StarWriter/Web)',
   'Text - txt - csv (StarCalc)',
   'WMF - MS Windows Metafile',
   'XBM - X-Consortium',
   'XHTML File',
   'XPM',
   'bmp_Export',
   'bmp_Import',
   'calc_HTML_WebQuery',
   'calc_StarOffice_XML_Calc_Template',
   'calc_pdf_Export',
   'dBase',
   'draw_PCD_Photo_CD_Base',
   'draw_PCD_Photo_CD_Base16',
   'draw_PCD_Photo_CD_Base4',
   'draw_StarOffice_XML_Draw_Template',
   'draw_bmp_Export',
   'draw_emf_Export',
   'draw_eps_Export',
   'draw_flash_Export',
   'draw_gif_Export',
   'draw_html_Export',
   'draw_jpg_Export',
   'draw_met_Export',
   'draw_pbm_Export',
   'draw_pct_Export',
   'draw_pdf_Export',
   'draw_pgm_Export',
   'draw_png_Export',
   'draw_ppm_Export',
   'draw_ras_Export',
   'draw_svg_Export',
   'draw_svm_Export',
   'draw_tif_Export',
   'draw_wmf_Export',
   'draw_xpm_Export',
   'dxf_Import',
   'emf_Export',
   'emf_Import',
   'eps_Export',
   'eps_Import',
   'gif_Export',
   'gif_Import',
   'impress_StarOffice_XML_Draw',
   'impress_StarOffice_XML_Impress_Template',
   'impress_bmp_Export',
   'impress_emf_Export',
   'impress_eps_Export',
   'impress_flash_Export',
   'impress_gif_Export',
   'impress_html_Export',
   'impress_jpg_Export',
   'impress_met_Export',
   'impress_pbm_Export',
   'impress_pct_Export',
   'impress_pdf_Export',
   'impress_pgm_Export',
   'impress_png_Export',
   'impress_ppm_Export',
   'impress_ras_Export',
   'impress_svg_Export',
   'impress_svm_Export',
   'impress_tif_Export',
   'impress_wmf_Export',
   'impress_xpm_Export',
   'jpg_Export',
   'jpg_Import',
   'math_pdf_Export',
   'met_Export',
   'met_Import',
   'pbm_Export',
   'pbm_Import',
   'pcd_Import_Base',
   'pcd_Import_Base16',
   'pcd_Import_Base4',
   'pct_Export',
   'pct_Import',
   'pcx_Import',
   'pgm_Export',
   'pgm_Import',
   'placeware_Export',
   'png_Export',
   'png_Import',
   'ppm_Export',
   'ppm_Import',
   'psd_Import',
   'ras_Export',
   'ras_Import',
   'sgf_Import',
   'sgv_Import',
   'svg_Export',
   'svm_Export',
   'svm_Import',
   'tga_Import',
   'tif_Export',
   'tif_Import',
   'wmf_Export',
   'wmf_Import',
   'writer_StarOffice_XML_Writer_Template',
   'writer_globaldocument_StarOffice_XML_Writer',
   'writer_globaldocument_StarOffice_XML_Writer_GlobalDocument',
   'writer_globaldocument_pdf_Export',
   'writer_pdf_Export',
   'writer_web_HTML_help',
   'writer_web_StarOffice_XML_Writer',
   'writer_web_StarOffice_XML_Writer_Web_Template',
   'writer_web_pdf_Export',
   'xbm_Import',
   'xpm_Export',
   'xpm_Import'
*/
   /// </summary>
   class Class1
   {
      enum ARG {path=0, pdfPath}

      [STAThread]
      static void Main(string[] args)
      {
         string               path;
         string               pdfPath;
         XComponentContext      xLocalContext;
         XMultiServiceFactory   xServiceManager;
         XComponentLoader      xDesktop;
         XComponent            xComponent;
         XFrame               xframe;
         PropertyValue[]         propertyValues;
         MyFrameActionListener   callback;


         try
         {
            path      = args[(int)ARG.path];
            path      = ToFileURL(path);
            pdfPath      = args[(int)ARG.pdfPath];
            pdfPath      = ToFileURL(pdfPath);
            

            callback      = new MyFrameActionListener();
            xLocalContext   = uno.util.Bootstrap.bootstrap();
            Console.WriteLine("successfull bootstrap");
            xServiceManager   = (XMultiServiceFactory)xLocalContext.getServiceManager();
            xDesktop      = (XComponentLoader)xServiceManager.createInstance("com.sun.star.frame.Desktop");
            
            //Load a new writer instance
            xComponent   = xDesktop.loadComponentFromURL("private:factory/swriter", "_blank", 0, new PropertyValue[0]);
            xframe      = null;
            while(xframe == null)
            {
               Thread.Sleep(100);
               xframe      = ((XDesktop)xDesktop).getCurrentFrame();
            }
            Console.WriteLine("xframe loaded");

            //Register the call back
            xframe.addFrameActionListener(callback);

            //load the real file
            xComponent   = ((XComponentLoader)xframe).loadComponentFromURL(path, "_self", 0, new PropertyValue[0]);
            while(!callback.loaded)
            {
               Thread.Sleep(100);
            }

            //save as
            //propertyValues      = new PropertyValue[4];            
            //propertyValues[0]   = SetPropertyValue("FilterName", "writer_pdf_Export");
            //propertyValues[1]   = SetPropertyValue("ReadOnly", false);
            //propertyValues[2]   = SetPropertyValue("Overwrite", true);
            //((XStorable)xComponent).storeToURL(pdfPath, propertyValues);

            //close the app
            //xComponent.dispose();
         }
         catch(unoidl.com.sun.star.io.IOException exc)
         {
            Console.WriteLine(exc.ToString());
         }
      }

      static PropertyValue SetPropertyValue(string propName, object propValue)
      {
         PropertyValue   objReturn;

         objReturn      = new PropertyValue();
         objReturn.Name   = propName;
         objReturn.Value   = new uno.Any(propValue.GetType(), propValue);

         return objReturn;
      }

      static string ToFileURL(string path)
      {
         if(Regex.Match(path, @"^[a-zA-Z]:[\/\\]").Success)
         {
            path   = "file:///"+ path;
         }
         path   = path.Replace("\\", "/");

         return path;
      }
   }

   /// <summary>
   /// XFrameActionListener implementation
   /// </summary>
   public class MyFrameActionListener : XFrameActionListener
   {
      public bool   loaded   = false;

      public void frameAction(FrameActionEvent Action)
      {
         if(Action.Action == FrameAction.COMPONENT_ATTACHED)
         {
            loaded   = true;
         }
         Console.WriteLine(Action.Action.ToString());
      }

      public void disposing(EventObject Source)
      {
         Console.WriteLine("Frame disposed!");
      }
   }
}
Back to top
View user's profile Send private message Visit poster's website
LarsB
OOo Advocate
OOo Advocate


Joined: 31 Aug 2005
Posts: 445
Location: Hamburg, Germany

PostPosted: Wed Jan 11, 2006 5:40 am    Post subject: InputStream Reply with quote

Hi,

I didn't do that until now. I guess this thread will be helpfull for you.

http://www.oooforum.org/forum/viewtopic.phtml?p=90856#90856

There's also a java example which work with a InputStream, I guess this
could solve your problem.

Cheers
LarsB
_________________
AODC - A free OpenDocument Converter
AODL - An independent OpenDocument Library C#
EmbeddedOpenOffice .net UserControl C#
EmbeddedOpenOffice Visual Studio .net Add In

http://www.OpenDocument4all.com/
Back to top
View user's profile Send private message Visit poster's website
007dad
General User
General User


Joined: 03 Jan 2006
Posts: 9

PostPosted: Wed Jan 11, 2006 8:20 am    Post subject: Reply with quote

excellent link

adding
a "HTML (StarWriter)" open filter is the solution

Code:

//load the real file
            propertyValues      = new PropertyValue[1];            
            propertyValues[0]   = SetPropertyValue("FilterName", "HTML (StarWriter)");
            xComponent   = ((XComponentLoader)xframe).loadComponentFromURL(path, "_self", 0, propertyValues);


Thanks again for all your help
Back to top
View user's profile Send private message Visit poster's website
007dad
General User
General User


Joined: 03 Jan 2006
Posts: 9

PostPosted: Wed Jan 11, 2006 8:22 am    Post subject: Reply with quote

actualy this filter works even better
"writer_web_HTML_help"
Back to top
View user's profile Send private message Visit poster's website
LarsB
OOo Advocate
OOo Advocate


Joined: 31 Aug 2005
Posts: 445
Location: Hamburg, Germany

PostPosted: Wed Jan 11, 2006 11:26 am    Post subject: Thanks Reply with quote

Hi,

thanks for all code extensions Smile Hope your application is working correctly, now Smile

Cheers
LarsB
_________________
AODC - A free OpenDocument Converter
AODL - An independent OpenDocument Library C#
EmbeddedOpenOffice .net UserControl C#
EmbeddedOpenOffice Visual Studio .net Add In

http://www.OpenDocument4all.com/
Back to top
View user's profile Send private message Visit poster's website
007dad
General User
General User


Joined: 03 Jan 2006
Posts: 9

PostPosted: Wed Jan 11, 2006 4:39 pm    Post subject: Reply with quote

Thanks for all your help

Works great unless I run from ASPX
I even tried calling it as a second process from ASPX and Imersonating ADMIN in the Called app
the called app works fine if any thing but ASPX calls it
when ASPX calls it the
xLocalContext = uno.util.Bootstrap.bootstrap();
hangs. I think it may be because the caller is not visible

Its too bad, I am using old Reflection code to write reports to PDF from ASPX
and it works great except there is no way to recive the callback from large reports
your code is perfect for this
Back to top
View user's profile Send private message Visit poster's website
overit
Newbie
Newbie


Joined: 04 May 2006
Posts: 2
Location: Boston, MA

PostPosted: Thu May 04, 2006 7:40 am    Post subject: Reply with quote

I am new to OpenOffice automation, but have a similar problem. I'm able to load and convert documents to HTML under ASP.NET 2.0 consistently. That is until the ASP.NET Application restarts (eg. if web.config is changed), then I have to call uno.util.Bootstrap.bootstrap() again and a crash occurs. I get this message in the exception:

Attempted to read or write protected memory. This is often an indication that other memory is corrupt.

And the following stack trace from Visual Studio:

File: cli_cppuhelper.dll
at rtl_uString_release(_rtl_uString* )
at rtl.OUString.__dtor(OUString* )
at __CxxCallUnwindDtor(IntPtr , Void* )
at uno.util.to_cli<class com::sun::star::uno::XComponentContext>(Reference<com::sun::star::uno::XComponentContext>* x)
at uno.util.Bootstrap.bootstrap()
at v.Apps.OpenOffice.OOApp.oo_Initialize() in c:\v\sol\ui\App_Code\v\Apps\OpenOffice\OOApp.cs:line 78
at v.Apps.OpenOffice.OOApp.th_Initialize(Object xarg) in c:\v\sol\ui\App_Code\v\Apps\OpenOffice\OOApp.cs:line 72
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart(Object obj)

The thread apartment state is set to STA.
Back to top
View user's profile Send private message
mf3659
General User
General User


Joined: 17 Jul 2006
Posts: 8
Location: Milan, Italy

PostPosted: Mon Jul 17, 2006 11:43 pm    Post subject: Re: User in machine.config Reply with quote

LarsB wrote:
Hi,

you have to change the ASP.net user which is the owner of the executing webpage. You can do this via the machine.config try to run it as System or create a new user and start with the new user at least one time OO, so that OO could write the settings for this user.

Cheers
LarsB


Hi LarsB

I have a question for you:

Usign the program above and following your instruction, I have change the ASP.net user from machine to system but my application, when execute Bootstrap, "freeze" (in processExplorer I see soffice.exe and soffice.bin associated to System user but my application does not response).
to try to solve the problem i've to associated ASP.net user to a domain_user of my LAN. This solution work without problem.
I have also tried to create a new local user and associate it to ASP.net but the application have the same behaviour of "machine" and "system" configuration.

what I mistake?
Why the system configuration of asp.net user don't work correctly?

I have forgotten to tell you that my ASP.Net application run under .net framework 1.1

Thanks
With regards
mf3659

P.S.: excuse me if my english is not perfect Embarassed
Back to top
View user's profile Send private message
pboutin
Newbie
Newbie


Joined: 30 Aug 2006
Posts: 1
Location: Québec, Canada

PostPosted: Wed Aug 30, 2006 7:50 am    Post subject: Reply with quote

Hi

I have the same kind of problem then you mf3659. I made a C# windows application running under .net 2.0 and I get a LoaderLock issue just for the bootstrap() call.

I know I'm not the only one who has this problem, please help me find answers and how I can solve this problem.

regards
pboutin
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 Code Snippets 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