I have an application that integrates the web viewer into an existing web project. This web project is currently running against the .net framework 3.5.
In addition to this I have a separate project that I use for building my reports. I then load the report using the MEF framework (via reflection) when the main web application starts.
In the original version of the web application I used to load a report (source) into the webviewer using the following code:
dim source as new TestReport
me.reportviewer1.Report = Source
Once I'd upgraded I found this no longer worked. I have since modified the code as follows:
dim instance as new telerik.reporting.instancereportsource
instance.reportdocument = source
me.reportviewer1.reportsource = instance
So far so good - only its not. I'm finding that when creating a new instance of the report as shown in the first example the report loads with no issue. Loading the report via MEF as in the second example doesn't work. No data is returned and the report is empty.
I know the same type is being loaded as I can modify the report header and in both examples the header is rendered but the report loaded via MEF is never populated. I can see no errors or reason why data would not be returned.
Is there any way I can somehow diagnose what the problem is here?
In addition to this I have a separate project that I use for building my reports. I then load the report using the MEF framework (via reflection) when the main web application starts.
In the original version of the web application I used to load a report (source) into the webviewer using the following code:
dim source as new TestReport
me.reportviewer1.Report = Source
Once I'd upgraded I found this no longer worked. I have since modified the code as follows:
dim instance as new telerik.reporting.instancereportsource
instance.reportdocument = source
me.reportviewer1.reportsource = instance
So far so good - only its not. I'm finding that when creating a new instance of the report as shown in the first example the report loads with no issue. Loading the report via MEF as in the second example doesn't work. No data is returned and the report is empty.
I know the same type is being loaded as I can modify the report header and in both examples the header is rendered but the report loaded via MEF is never populated. I can see no errors or reason why data would not be returned.
Is there any way I can somehow diagnose what the problem is here?
6 Answers, 1 is accepted
0
Mike
Top achievements
Rank 1
answered on 22 Aug 2012, 09:00 AM
I have narrowed the issue down to the SQLDataSource.
Essentially for whatever reason the sql datasource does not appear to be returning data. I have attempted renaming the source as it was originally called "Main" which I figured wa sa reserved word. This made no difference.
I have now created a new sql datasource, copied the sql across and recreated the parameters. I then changed the report datasource to the new one and the report has started working. If I switch back to the old source it stops working?
I have reviewed all code in the code behind even comparing the resource files and can find no difference other than the name?
I now have a work around (recreate all sql datasources) but unfortunately I have a large amount of reports so will need to continue trying to find a solution. Does anybody have any ideas?
Essentially for whatever reason the sql datasource does not appear to be returning data. I have attempted renaming the source as it was originally called "Main" which I figured wa sa reserved word. This made no difference.
I have now created a new sql datasource, copied the sql across and recreated the parameters. I then changed the report datasource to the new one and the report has started working. If I switch back to the old source it stops working?
I have reviewed all code in the code behind even comparing the resource files and can find no difference other than the name?
I now have a work around (recreate all sql datasources) but unfortunately I have a large amount of reports so will need to continue trying to find a solution. Does anybody have any ideas?
0
Mike
Top achievements
Rank 1
answered on 22 Aug 2012, 01:31 PM
FINALLY - I have identified the cause and fixed the issue!!!!!!!!!
It would appear the issue had nothing to do with MEF or the SQLDataSource. The problem is with Report Parameters.
Essentially I was setting the report parameter values programatically before running the report. In previous versions of telerik reporting I had been setting parameter.value to DBNull.Value. This no longer appears to be supported as if I do NO data is returned from the sqldatasource. Setting the value to nothing however results in the expected behaviour.
I assume this has been changed by design but cannot fathom why?
In addition to this I have also found another issue with parameters. In previous versions creating a report parameter of type integer would have resulted in the parameter.value object containing an integer. In the current version the parameter.value object always seems to contain a string. This has also caused me coding problems but now I know about this bug I am coding around it!!!
It would appear the issue had nothing to do with MEF or the SQLDataSource. The problem is with Report Parameters.
Essentially I was setting the report parameter values programatically before running the report. In previous versions of telerik reporting I had been setting parameter.value to DBNull.Value. This no longer appears to be supported as if I do NO data is returned from the sqldatasource. Setting the value to nothing however results in the expected behaviour.
I assume this has been changed by design but cannot fathom why?
In addition to this I have also found another issue with parameters. In previous versions creating a report parameter of type integer would have resulted in the parameter.value object containing an integer. In the current version the parameter.value object always seems to contain a string. This has also caused me coding problems but now I know about this bug I am coding around it!!!
0
Hello Mike,
Indeed, the DBNull usage has been replaced with Nothing (null) as we consider this the correct way.
As to the return value of the parameters, the parameters should still return the right type. You can easily try that with the following expression and an Integer parameter:
=Parameters.MyParameter.Value * 2
if it is string the multiplication will result in an error.
Can you please further elaborate on the case and describe the abnormal behaviour that your experiencing.
Regards,
Elian
the Telerik team
Indeed, the DBNull usage has been replaced with Nothing (null) as we consider this the correct way.
As to the return value of the parameters, the parameters should still return the right type. You can easily try that with the following expression and an Integer parameter:
=Parameters.MyParameter.Value * 2
if it is string the multiplication will result in an error.
Can you please further elaborate on the case and describe the abnormal behaviour that your experiencing.
Regards,
Elian
the Telerik team
BLOGGERS WANTED! Write a review about Telerik Reporting or the new Report Designer, post it on your blog and get a complimentary license for Telerik Reporting. We’ll even promote your blog and help bring you a few fresh readers. Yes, it’s that simple. And it’s free. Get started today >
0
Mike
Top achievements
Rank 1
answered on 24 Aug 2012, 03:40 PM
Hello,
I have resolved the issue but for your information the expression below does fail. I bookmarked the code where the parameter value is set and set the code to Parameters.MyParameter.Value *= 2 which resulted in an error because event though the data type was set to integer, the parameter value was of type string and contained "".I have coded around this now by checking for empty string and assuming the value to be zero if found.
Thanks
Mike
P.S - One strange thing I have noticed is that this behaviour only seems to happen to those parameters that were part of as report that has been upgraded. New reports do not seem to have this issue.
I have resolved the issue but for your information the expression below does fail. I bookmarked the code where the parameter value is set and set the code to Parameters.MyParameter.Value *= 2 which resulted in an error because event though the data type was set to integer, the parameter value was of type string and contained "".I have coded around this now by checking for empty string and assuming the value to be zero if found.
Thanks
Mike
P.S - One strange thing I have noticed is that this behaviour only seems to happen to those parameters that were part of as report that has been upgraded. New reports do not seem to have this issue.
0
António
Top achievements
Rank 1
answered on 29 Aug 2012, 02:29 PM
Hello Mike,
I'm sorry if this may sound abusing, but could you possible show how you managed to load the report using MEF?
I've been trying to do the same but haven't succeeded yet. I'm starting to get desperate....
Thank you so much!
I'm sorry if this may sound abusing, but could you possible show how you managed to load the report using MEF?
I've been trying to do the same but haven't succeeded yet. I'm starting to get desperate....
Thank you so much!
0
Mike
Top achievements
Rank 1
answered on 29 Aug 2012, 03:26 PM
Hi Antonio,
Here's the code I use to import via MEF. I've actually got a second routine that uses reflection as I've found MEF to be a bit inconsistent at times.
The list of reports is defined as:
The code to populate the list is:
Cheers
Mike
Here's the code I use to import via MEF. I've actually got a second routine that uses reflection as I've found MEF to be a bit inconsistent at times.
The list of reports is defined as:
<ImportMany(AllowRecomposition:=
True
)>
Private
Property
_reports()
As
New
List(Of Telerik.Reporting.Report)
'Set the folder
Dim
folder
As
String
=
"c:\reports\"
'Create a new catalog
Dim
catalog
As
New
AggregateCatalog
catalog.Catalogs.Add(
New
DirectoryCatalog(folder))
'Create a new container
Dim
container
As
New
CompositionContainer(catalog)
'Populates the _reports property as it uses the ImportMany attribute
container.ComposeParts(
Me
)
Cheers
Mike