I have an application installed at a client's site that was built with DevEx v9.3, and I am trying to write a VB script in a report file that needs to access an object from another assembly. I have read a lot about setting ScriptReferencesString at run time, but nothing that indicates you can do this from within a script. Is it possible to do this in the script, and if so, which event should I be using?
Currently I am trying to set ScriptReferencesString right before the line of code that accesses the object (in a BeforePrint event), but it doesn't seem to make any difference. I have hard coded the path to make sure I have that correct, but nothing seems to work.
Is it possible to do this without re-building the application?
Please define the ScriptReferencesString property in the constructor of the XtraReport1 class. Here is some sample code:
Hope this helps you. Thanks for your feedback in advance.[VB.NET]
.... Partial Public Class XtraReport1 Inherits DevExpress.XtraReports.UI.XtraReport Public Sub New() InitializeComponent() 'Uncomment following string to add the reference at runtime. 'report.ScriptReferencesString = "Dlls\\MyAssembly1.dll\r\nDlls\\MyAssembly2.dll"; End Sub End Class ....
Thanks for your response, however it appears to me that your solution is to be implemented in the project source (from Visual Studio), not the script. In my original request I stated that in this case I am not able to rebuild the application, so I am looking for a solution that can be implemented entirely within the script. To clarify, the application allows the user to open the report in the designer and edit the scripts, so that is where I am trying to implement the solution.
In any case, I had a go at your suggestion by adding a constructor to the scripts, and although I can verify that the code runs, it does not solve the problem. This is what I added to the scripts section (from the run time report designer available in the application):
Public Sub New
Dim r As XtraReport = CType(PageHeader.Parent, XtraReport)
r.ScriptReferencesString = "C:\DLLPath\MyCustomLibrary.dll"
Note that I am accessing the "Report" via the PageHeader because the keyword "Me" refers to the ScriptingReport object at this point. If I use Me.ScriptReferencesString I get the error:
'ScriptReferencesString' is not a member of 'ScriptingNamespace.ScriptingReport'
There's probably a better way, but this at least runs without error. However, even though this executes successfully before the line that references the object in my dll, I still get the original error:
error BC30002: Type 'MyCustomLibrary.TransactionList' is not defined.
P.S. I note that in your solution you have used a double backslash in the path: Dlls\\MyAssembly1.dll
I tried this as well but it made no difference.
Thank you for the update. The problem is caused by the fact that it is too late to update the report's ScriptReferencesString from its scripts since they are compiled before they are executed. Thus, adding script references from the scripts will not have any effect. You should accomplish this from the code-behind of your application before the report preview is invoked. However, you can do this in the End-User Report Designer , too. Attached is a small solution and screencast, illustrating how this can be done. Hopefully, you will find this information helpful.
P. S.: Please note that this scenario will only work in v2010 vol 1.8 and later versions due to the Scripts - Functionality from an external assembly breaks scripts until placed along with the application executable bug.