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:
@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.
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=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.
[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 ?
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”)
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.
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.
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):
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.