cancel
Showing results for 
Search instead for 
Did you mean: 

Type 'System.String' cannot be marshaled as an unmanaged structure; ... error is back

0 Kudos

The error discussed in this post http://scn.sap.com/thread/1890650 seems to have crept back into SP12.  The following code:

Using dbConnection As SqlConnection = GetNewSQLConnection()

                    .AddLoginInfo(dbConnection)

                    If TypeOf .Report Is IHasParameters Then

                        DirectCast(.Report, IHasParameters).ApplyParameterValues()

                    End If

                   If .Report.Rows.Count > 0 Then

                        .PrintToPrinter(.PrinterPageSettings.PrinterSettings.Copies, False, _

                                        .PrinterPageSettings.PrinterSettings.FromPage, _

                                        .PrinterPageSettings.PrinterSettings.ToPage)

.

.

.

Gives the error at If .Report.Rows.Count > 0

Type 'System.String' cannot be marshaled as an unmanaged structure; no meaningful size or offset can be computed.

The report does contain a blob - I tried deleting it and dragging it from the table - again, but the same error appears before and after.  The type of the Field object is IFieldBlob.  Oddly enough, other reports that also contain this field, currently seem to be working, although we will have to revisit all of them now.

I am using VS2010 and SQL Server 2005.

Any help would be appreciated. 

Accepted Solutions (1)

Accepted Solutions (1)

former_member183750
Active Contributor
0 Kudos

Don't use SP 12. Update to SP 13 and test.

- Ludek

Senior Support Engineer AGS Product Support, Global Support Center Canada

Follow me on Twitter

0 Kudos

Did that.  No joy.  BTW, the report preview shows the report with no problems - it is only when I try and check on the number of records that this occurs.  I installed SP13, the file dates all show 27/01/2015.

If you don't count the number of records, e.g. catch it in the debugger and step over that point, then the report prints fine.  The workaround seems to be to waste a bunch of paper. I will have to comment that line out in order for the application to work.

Neil

0 Kudos

Partial work-around:

    ''' <summary>

    ''' This function is a workaround of the Crystal Reports bug that causes a report with an image in it

    ''' to fail when the report is checked if it has data.

    ''' </summary>

    ''' <param name="Report">Report to check</param>

    ''' <returns>Number of rows in the report</returns>

    ''' <remarks>If the check throws an exception a value of one will be returned.</remarks>

    Friend Function GetReportRowsCount(Report As ReportClass) As Integer

        Try

            Return Report.Rows.Count

        Catch ex As Exception

            My.Application.Log.WriteException(ex, TraceEventType.Warning, "GetReportRowsCount for " & Report.Name)

            Return 1

        End Try

    End Function


I use this function in place of the check for Report.Rows.Count,


This allows most of my reports to work correctly, but allows the odd blank report with an image on it to print.  Oddly enough, some of the older reports with logo's on them seem to work correctly.  The newer ones run into this problem.


Neil

0 Kudos

Hi Neil,

There have been updates to CR Designer and the embedded Designer built into VS.

Can you try updating one of those reports in VS or if you have the full CR Designer 2008 or above update it in there and test.

Can you attach a few of your reports so I can run them through my app and see what happens?

Use the Advanced editor option, add the reports to a zip file and then rename the zip file to *.txt and then attach. You can't attach a zip file...

Thanks

Don

Answers (0)