OLEobject - ReportManager

I always used to generate reports ReportManager, in previous versions could include it as an ActiveX. I do not remember which version change this. Since then I have been using it as follows:

Dim rep As New OLEObject (“ReportMan.ReportManX”)

Now in the new version 2013r3, I can no longer use it, causes this error:

        Unknown error: -2147221008

in that line of code.

I would appreciate any help.


Siempre he usado ReportManager para generar reportes; en versiones anteriores podía incluirlo como un activeX. No recuerdo en que versión cambio esto. Desde entonces he estado usándolo de la manera siguiente:

Dim rep As New OLEObject(“ReportMan.ReportManX”)

Ahora en la nueva versión 2013r3, ya no puedo usarlo, provoca este error:

       Unknown error: -2147221008

en esa linea de código.

Agradecería cualquier ayuda.

In Web, nothing works with OLEObject, examples that are in the help, do not work, always show the same error:

      Dim word as New OLEObject ("Word.Application")

      Unknown error: -2147221008

In DeskTop works well.

Seems to be a bug errors.


En Web, no funciona nada con OLEobject; los ejemplos que están en la ayuda, no funcionan, siempre muestran el mismo error:

     Dim word as New OLEObject("word.Application")

     Unknown error: -2147221008

En DeskTop funciona bien.

Parece ser un bug error.

[quote=35736:@Adalberto Del Rosario]In Web, nothing works with OLEObject, examples that are in the help, do not work, always show the same error:

      Dim word as New OLEObject ("Word.Application")

      Unknown error: -2147221008

In DeskTop works well.

Seems to be a bug errors.


En Web, no funciona nada con OLEobject; los ejemplos que están en la ayuda, no funcionan, siempre muestran el mismo error:

     Dim word as New OLEObject("word.Application")

     Unknown error: -2147221008

En DeskTop funciona bien.

Parece ser un bug error.[/quote]

It’s not a bug.

OLEObject is only supported for desktop on windows platform, as explained in Supported platforms: http://documentation.xojo.com/index.php/OLEObject

Ok, but in previous versions to 2013r3 I worked to perfection in web applications. So to change it?.


Ok, pero en las versiones anteriores a 2013r3 me funcionaba a la perfeccion, en aplicaciones web. Entonces para que cambiarlo?.

@John Hansen: The OP is correct. In XOJO 2013 R2, with a web app hosted on a Windows server, OLE objects work well. I created a feecbeck case a few days ago. For now, I am stuck at R2 because of this. As far as I am concerned, it is a bug.

Hi Louis, I am also stuck in the version 2013r2. All reports stopped working in version 2013r3. : (

Hola Louis,Tambien estoy atrapado en la version 2013r2. Todos los reportes dejaron de funcionar en la version 2013r3. :frowning:

Please report this as a bug, and also a note to update the documentation, thanks.

William Yu: I already created a feedback case. # 29668. Status verified. I would not mind to see this functioanlity work again in the next update. :wink:

Thanks, I realized this is related to another bug and merged the two. For now you can use this workaround:

Declare Sub CoInitialize Lib “ole32” (reserved As Integer)
CoInitialize(0)
Dim word as New OLEObject (“Word.Application”)

With the changes to the threading model in 2013r3 it is now required to call CoInitialize on each separate thread that uses OLEObject. It may not look like your Web app uses any threads but under the hood each Session is its own thread, so that is why this bug is happening more apparently in Web Apps.

Thank you William. I am actually glad to see that each session is executed in a separate thread.
I have a few questions about the workaround:

  • is the CoInitialize a one shot per session, or do we need to do this for each OLEObject?
  • Is it always CoInitialize(0), or do we need to increment (0) for each usage of the call?
  • Is this something that will go away, or is it a “permanent workaround”?

[quote=35954:@Louis Desjardins]Thank you William. I am actually glad to see that each session is executed in a separate thread.
I have a few questions about the workaround:

  • is the CoInitialize a one shot per session, or do we need to do this for each OLEObject?
  • Is it always CoInitialize(0), or do we need to increment (0) for each usage of the call?
  • Is this something that will go away, or is it a “permanent workaround”?[/quote]

CoInitialize only needs to be called once per thread/session. Ideally you should also call CoUninitialize at the end as well (after you’ve done all your OLEObject stuff), and you will always pass in 0 as the parameter. This is just a temporary workaround, we’ll fix this permanently in the framework, sorry for any inconvenience.

Ah, but The Sessions themselves are not threads. The requests are however. This means that you’ll probably need to call this every time you use them.

[quote=35947:@William Yu]Thanks, I realized this is related to another bug and merged the two. For now you can use this workaround:

Declare Sub CoInitialize Lib “ole32” (reserved As Integer)
CoInitialize(0)
Dim word as New OLEObject (“Word.Application”)

With the changes to the threading model in 2013r3 it is now required to call CoInitialize on each separate thread that uses OLEObject. It may not look like your Web app uses any threads but under the hood each Session is its own thread, so that is why this bug is happening more apparently in Web Apps.[/quote]

You don’t need to CoUninitialize the COM library from the thread as well when finished ?

You do, as I mentioned in my previous post.

Oops… Missed that line :slight_smile:

Hi William, I have tried to do what you indicate, now no longer displays the error, but after running the function I show below, the application stops responding, even more, after that I can no longer run it again until I reboot the pc .

Sub GeneratePDF(NombreArchivo As String)
Declare Sub CoInitialize Lib “ole32” (reserved As Integer)
CoInitialize(0)
Dim rep As New OLEObject(“reportman.ReportManX”)

Try
rep.filename = filename
rep.SetDatasetSQL “ESTADO”, “SELECT * FROM estado”
rep.SetParamValue “Empresa”, CiaSystem.Nombre

rep.saveToPDF NombreArchivo, False

Catch oError As RuntimeException
MsgBox "Error : " + Str(oError.ErrorNumber) + EndOfLine + EndOfLine + oError.Message
end Try
CoInitialize(0)
End Sub

What am I doing wrong,
I appreciate your help.


Hola William, he tratado de hacer lo que indicas, ahora ya no muestra el error, pero luego de ejecutar la funcion que muestro abajo, la aplicacion deja de responder, es mas, despus de esto ya no puedo ejecutarla nuevamente hasta que reinicio la pc.

Que estoy haciendo mal,
Agradezco tu ayuda.

I think you meant to call CoUninitialize at the end instead of CoInitialize. It’s also advantageous to dispose of your OLEObject before uninitializing, i.e.

Catch oError As RuntimeException
    MsgBox "Error : " + Str(oError.ErrorNumber) + EndOfLine + EndOfLine + oError.Message
end Try
rep = Nil
CoUninitialize()

Hi William,

I downloaded the version 2013.r32, which appears OLEObjet solved the problem, but I have not been able to print reports using the ocx of ReportManager. By using the following code in my web application, the application stops responding and even I can no longer run the code more, I have to restart the pc in order to try again (Note: in version 2013.r2 still worked perfectly):

   Sub GeneratePDF(NombreArchivo As String)
   Dim rep As New OLEObject("reportman.ReportManX")

  Try
  rep.filename = filename
  rep.SetDatasetSQL "ESTADO", "SELECT * FROM estado"
  rep.SetParamValue "Empresa", CiaSystem.Nombre

 rep.saveToPDF NombreArchivo, False

 Catch oError As RuntimeException
        MsgBox "Error : " + Str(oError.ErrorNumber) + EndOfLine + EndOfLine + oError.Message
  end Try
  End Sub

I would appreciate any help.

Regards,
Adalberto


Hola William,

He descargado la versin 2013.r32, en la que aparece resuelto el problema del OLEObjet, pero aun no he podido imprimir los reportes usando el ocx de reportmanager. Al usar el siguiente cdigo en mi aplicacin web, la aplicacin deja de responder e incluso ya no puedo ejecutar mas el cdigo, tengo que reiniciar la pc para poder probar nuevamente (Nota: en la versin 2013.r2 aun funcionaba perfectamente):

Agradecera cualquier ayuda.

Saludos,
Adalberto

William,

I have a smallish example app that consistently generates an OLEException when running inside a thread but works fine on the main thread. I have used CoInitialize as you’ve stated and am running 2013r3.2.

Would you like a copy of the app? It’s based on code written by Joe Ranieri.

Yes please file a Feedback report, there may still be some issues in our OLEObject code that need to be resolved as well. A simple reproducible example would help a lot here, thanks.