StringBuilder error (Chunk Length)

I created a program to keep several folders in sync with their backups. The testing and copying is done with a background worker which reads a list of the files in the "original" folder, looks for the same file in the backup and skips if it is
there or else copies it. It has been working just fine for months but suddenly I am seeing this error:
{"Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: chunkLength"}
   at System.Text.StringBuilder.ToString()
   at FileSynch.Form1.BGW_Copy_ProgressChanged(Object sender, ProgressChangedEventArgs e)
   at System.ComponentModel.BackgroundWorker.OnProgressChanged(ProgressChangedEventArgs e)
   at System.ComponentModel.BackgroundWorker.ProgressReporter(Object arg)
the line of code that throws the error is : TxtResults.AppendText(SB.ToString)
I tried setting the StringBuilder with the Int32,Int32 overload to a high value, which did not help. I tried synclock which didn't help. I haven't any idea if the chunk_length can be changed, nothing I find says it can.  Here are some of the details
from one exception:
Actual SB.Length = 4492 (&H118C)
SB.Capacity = &H5E80
SB.m_chunk_length = &H118A
SB.m_chunk_chars {Length = 24192}
MaxChunkSize = &H1F40
MaxCapacity = &H7FFFFFFF
this is the backgroundworker code:
For Each filename As String In Filelist
Sourcename = Path.GetFullPath(filename).Replace(Source, "")
DestnName = Path.Combine(Destn, Sourcename.Remove(0, 1))
FilesScanned += 1
SB.Append(Now.ToLongTimeString & "-Checking " & Sourcename)
If BGW_Copy.CancellationPending Then
BGW_Copy.ReportProgress(-1) ' just reports "User Cancelled"
Exit Sub
End If
If File.Exists(DestnName) Then
SB.Append(" - Backup Exists")
FilesSkipped += 1
Else
Try
SW.Restart()
Directory.CreateDirectory(Path.GetDirectoryName(DestnName))
File.Copy(filename, DestnName, False)
SW.Stop()
FilesCopied += 1
FLength = My.Computer.FileSystem.GetFileInfo(filename).Length
BytesCopied += FLength
SB2.Append(filename & " " & FLength.ToString & " " & TotalBytes.ToString & vbNewLine)
SB.Append(" - Copied " & ShowFriendlyNumber(FLength) & " in " & ShowFriendlyTime(SW.ElapsedMilliseconds))
Catch ex As Exception
SB.Append(" - Copy Failed " & ex.Message)
End Try
End If
SB.Append(vbNewLine)
If FilesScanned Mod UpdateFreq = 0 Then
BGW_Copy.ReportProgress(FilesScanned)
SB.Clear() End If
If BGW_Copy.CancellationPending Then
BGW_Copy.ReportProgress(-1) ' this just reports "User Cancelled"
Exit Sub
End If
Next
Progress Changed Code (simplified):
TxtResults.AppendText(SB.ToString) ' error here
UpdateFreq comes from a NumericUpDown and defaults to 10
A typical line of output:
9:46:34 AM-Checking \My DVD.iso - Backup Exists
or this:
9:48:12 AM-Checking \My DVD.iso - Copied 2.77 GiB in 38.0 sec.

Read another thread over at
stackoverflow suggesting that you should pass stringbuilder.Tostring across threads instead of the stringbuilder itself... Have you tried this?
“If you want something you've never had, you need to do something you've never done.”
Don't forget to mark
helpful posts and answers
! Answer an interesting question? Write a
new article
about it! My Articles
*This post does not reflect the opinion of Microsoft, or its employees.

Similar Messages

  • RFC Connection error - Invalid length. Check parameters.

    Hi Forum, Good Morning!
    My ABAP Program will run in BACK Ground Job Processing(SM37) to download data to Presentation server( Local PC Directory). So I have created a RFC destination type TCP/IP to use 'RFC_REMOTE_FILE'  function module in my ABAP Program.
    When I am trying to test RFC connection It is giving following error.
    ERROR   Invalid length. Check parameters
    LOCATION  SAP- Server dsapp05_R3D_10 on host dsapp05 (wp 2)
    COMPONENT   CPIC
    COUNTER   14
    MODULE
    LINE
    RETURN CODE    240
    SUBRC                0
    RELEASE           640
    TIME                   Mon Dec 11 10:08:05  2006
    I did following procedure before I test RFC destination..
    I have created RFC Destination : BJRFC
    Technical Settings: Selected Registered Server Program radio button
    Program ID: BJACCESS
    Gateway host : 172.22.149.199
    gateway Service: sapdp10
    In my local machine Copied  ‘SAPRFC.INI’ file from the TEXT folder to the BIN Folder.
    Then open the SAPRFC.INI file in BIN folder and Register a RFC server program at a SAP Gateway.
    DEST=R3D_R
    TYPE=R
    PROGID=BJACCESS.rfcexec
    GWHOST=172.22.149.199
    GWSERV=sapdp10
    RFC_TRACE=0
    DEST=R3D_R
    TYPE=R
    PROGID=BJACCESS.trfcexec
    GWHOST=172.22.149.199
    GWSERV=sapdp10
    RFC_TRACE=0
    Then entered below command in dos prompt.
    C:\Program Files\SAP\FrontEnd\SAPgui\rfcsdk\bin>rfcexec -aBJACCESS –172.22.149.199 –xsapdp10.
    so how do i proceed in this kind of case.
    any help  please.
    Thanks in advance.

    Hi,
       Just you check whether your program is registered or not.
       If it is registered then you can find in SMGW transaction and go to
       GOTO - Logged on clients
    in that you will be able to see your program name if it registers succesfully.
    you have typed rfcexec -aBJACCESS –172.22.149.199 –xsapdp10
    in this way.
    In this you have misseg 'g' in front of your sap ip.
    Thanks&Regards
    Rajehs Balusu

  • Invoking Xai Service from  BPEL process (Error 411--Length Required)

    Hi Friends,
    I am trying to invoke xai inbound service webserive i.e WSDL from BPEL process, when i am testing the request i am getting the following error
    oracle.sysman.emSDK.webservices.wsdlapi.SoapTestException: oracle.fabric.common.FabricInvocationException: Unable to access the following endpoint(s): http://190.12.19.100:6500/spl/XAIApp/xaiserver/CMMBC
    when i open the above end point url in the browser:
    Error 411--Length Required
    From RFC 2068 Hypertext Transfer Protocol -- HTTP/1.1:
    10.4.12 411 Length Required
    The server refuses to accept the request without a defined Content- Length. The client MAY repeat the request if it adds a valid Content-Length header field containing the length of the message-body in the request message.
    pls help me out
    thanks and regards
    sivaram
    Edited by: sivaram on Apr 21, 2011 6:56 AM

    Yes we have got the same error while invoking from SOAP UI.
    But wsdl alone is opening through browser.
    But when we try opening the endpoint url we are getting the above error.
    Please help!

  • ADFDi  Error : The remote server returned an error: (411) Length Required

    JDeveloper version 11.1.2.1.0
    weblogic Version 10.3.5.0
    Hi All,
    From ADF Desktop integration application, When the user key in username and password the system show the following error message. Please help to me how to tackle it as well as useful blogs.
    Regards
    KT
    Error Detail:
    WebException: The remote server returned an error: (411) Length Required.
    Source: System
    Stack:
    at System.Net.HttpWebRequest.GetResponse()
    at oracle.adf.client.windows.common.internet.http.ManagedHttpResponse..ctor(HttpWebRequest request)
    at oracle.adf.client.windows.common.internet.http.ManagedHttpRequest.GetResponse()
    at oracle.adf.client.windows.datamanager.servletrequest.SyncRequest.BeginResponse()
    at oracle.adf.client.windows.datamanager.servletrequest.TamperCheckRequest.InternalCallSyncServlet()
    at oracle.adf.client.windows.datamanager.servletrequest.SyncServletRequest.CallSyncServlet(Boolean retry)
    at oracle.adf.client.windows.datamanager.ADFBindingContext.SendSyncServletRequest(SyncServletRequest request)
    at oracle.adf.client.windows.datamanager.ADFBindingContext.CheckForTampering()
    at oracle.adf.client.windows.datamanager.ADFBindingContext.PreSyncServletTamperCheck()
    at oracle.adf.client.windows.datamanager.ADFBindingContext.SyncModel(BindingContainer bc, String contentType)
    at oracle.adf.client.windows.datamanager.BindingContainer.Repopulate()
    at oracle.adf.client.windows.datamanager.BindingContainer.SyncModel(Boolean forceSync)
    at oracle.adf.client.windows.excel.runtime.uicomponent.RTActionCollection.DoInvoke(RTColumnCollection parent, String contextLabel)

    In which environment is your application hosted? Are there any other network components sitting between the client and the application, such as CDN or load balancer?
    It would be very helpful if you can capture the client-side HTTP traffic using some tools (e.g. Fiddler - http://www.fiddler2.com/fiddler2/), so that we can know where the "401 length required" error is sent from by looking at the header of the HTTP response of the error.

  • BAD parse error: zero-length content

    Hi there!
    Unfortunately I have a problem with JavaMail which I can not reproduce. Therefore, I don't have any 'debug' output of JavaMail. But maybe some of you have a clue for me. :)
    This is the error stack (just a snippet) which I get from JavaMail:
    javax.mail.MessagingException: A244 BAD parse error: zero-length content;
      nested exception is:
         com.sun.mail.iap.BadCommandException: A244 BAD parse error: zero-length content
         at com.sun.mail.imap.IMAPFolder.getMessagesByUID(IMAPFolder.java:1938)
         at org.zimbra.exchange.service.source.ExtendedEmailSyncSource.getMessagesByUID(ExtendedEmailSyncSource.java:1751)
         at java.lang.Thread.run(Thread.java:619)
    Caused by: com.sun.mail.iap.BadCommandException: A244 BAD parse error: zero-length content
         at com.sun.mail.iap.Protocol.handleResult(Protocol.java:343)
         at com.sun.mail.imap.protocol.IMAPProtocol.fetchSequenceNumbers(IMAPProtocol.java:1284)
         at com.sun.mail.imap.IMAPFolder.getMessagesByUID(IMAPFolder.java:1920)
         ... 13 moreAnd this is my getMessagesByUID method:
         private Message[] getMessagesByUID(long[] uids, IMAPFolder f)
                   throws StoreClosedException {
              Message[] result = new Message[0];
              try {
                   result = f.getMessagesByUID(uids);
              } catch (StoreClosedException e) {
                   throw e;
              } catch (MessagingException e) {
                   log.trace("The messages could not be fetched from the server.",     e);
              } catch (Exception e) {
                   log.error("An unexpected error occurd. "
                                  + e.getClass().getSimpleName(), e);
              return (result);
         }My problem is that I can not reproduce the error and so I don't know why the error is thrown. According to the JavaDoc it should return a 'null' entry for messages where it can not find the UID.
    thanks for your help.

    The error message is coming from your IMAP server. It seems to be complaining about the
    message that JavaMail sent it. The getMessagesByUID method will send an IMAP FETCH
    command. That command doesn't include any variable length content, so I don't know what
    exactly the server could be complaining about.
    Perhaps your server has a log file that might have more information?
    Otherwise, you'll probably need to capture the debug output so that you can examine it later
    the next time this problem occurs.

  • DMS error HTTP error: 411 Length Required

    Hi,
    I am geting following error while creating the content repository on R/3 ( ECC 5.0 ).
    <b>HTTP error: 411 Length Required</b>
    If I click on ok make I am geting next popu error as follow
    <b>HTTP error: 500 (Internal Server Error)  "ContRep ZHTTP_HCP or Storage entry not defined"</b>
    As per SAP note 925327 in need to apply the kernel patch 122 our current patch level is 101.As per the note there is one short term  solution i.e. use SAPHTTP. But am not geting how to do that since we dont have the much time to apply the kernel patch at this step coz our golive data is very near i.e. 23-05-2007.
    So please help me.
    Thanks a lot,
    Harshal

    Hello Harshal,
    I have the same error. Did you solve your problem ?
    Dimitry

  • HTTP Error 411 "Length Required" when I try to call a service via POST

    Hi All,
    I've got a service I want to call from within Flex, and I used the Data/Services tab to setup the new service call.  It's called "CommitChanges" and it's supposed to cause the server to commit the changes that were submitted, incrementally, during this session.  You can think of it as being like a "save" command.  It takes no arguments.
    In keeping with the suggested use of POST for operations that causes changes to data on the server, I setup this request to use POST.  However, when I try to call the service I get the following error:
    Response Received:
    Length Required
    HTTP Error 411. The request must be chunked or have a content  length.
    If I change the request type to GET it works, but I'd like to get it working with POST.
      -Josh

    Right after Skype crash open Windows Event Viewer -> Custom Views -> Administrative Events. Look for the most recent error messages. Copy and paste here the text from the General tab.

  • Shopping cart error regarding length

    Hi All,
    The user is getting an error " document name exceeds allowed length" and when checked, the length of the Shopping Cart is less that 20 characters even.
    Do you guys have any idea, what leads to this error?
    Regards,
    Ssingh

    Hi,
    Is there any attachment exist with the long URL in the shopping cart?(Please refer note 1269204 in case long attachment URL).
    Thanks,
    Ankur

  • Getting error Invalid length parameter passed

    Hi,
    I'm getting an error running my query. It say "Invalid length parameter passed to the LEFT or SUBSTRING  function. I will be getting the string in between of hyphen using the code below. May i ask your assistance or idea on how to fix this issue.
    thank you.
     Substring(ins.itemid,11,CHARINDEX('-',ins.itemid+'-',11)-11) AS MODEL
    Msg 537, Level 16,
    State 3, Line 1
    Invalid length parameter passed to the LEFT or SUBSTRING
    function.
    Sample data of Itemid.
    B300-4410-ONEMAX-U
    B300-1725-XWHT-U
    B300-3110-VT981-U
    B300-1720-DRZRKCROBLK-U
    B300-1720-DRDTHN32BLK-U

    That'll cause empty strings to show up into you're result set but shouldn't cause the the SUBSTRING function to fail. 
    The error is the result of the SUBSTRING function trying to bring back a negative number of characters.
    Try running the following and see what comes back...
    SELECT ins.itemid
    FROM dbo.TableName ins
    WHERE LEN(ins.itemid) < 11
    If you don't find any itemids what are less than 11 characters (I'm 99% sure you will), try using a little test script like the following to test suspect values...
    IF OBJECT_ID('tempdb..#temp') IS NOT NULL
    DROP TABLE #temp
    GO
    CREATE TABLE #temp (
    itemid VARCHAR(30)
    INSERT #temp (itemid) VALUES
    ('B300-4410-ONEMAX-U'),
    ('B300-1725- '),
    ('B300- 3110-VT981-U'),
    ('B300-1720-DRZRKCROBLK-U'),
    ('B300- 1720-DRDTHN32BLK-U')
    SELECT ins.itemid
    FROM #temp ins
    WHERE LEN(ins.itemid) < 11
    SELECT
    SUBSTRING(
    ins.itemid, 11, CHARINDEX('-',ins.itemid+'-',11)-11) AS MODEL FROM #temp ins
    HTH,
    Jason
    Jason Long

  • Import error lob length

    When I do import I got the below error
    illegal lob length marker 65279

    Hi,
    The action associated with this error message is "Contact Oracle Support" [see here|http://download.oracle.com/docs/cd/B19306_01/server.102/b14219/impus.htm#sthref10696]
    I don't know what to suggest to you other than following the advise above or perhaps you have a corrupt dump file.
    IMP-00008: unrecognized statement in the export file: string
    Cause: Import did not recognize a statement in the export file. Either the export file was corrupted, or an Import internal error has occurred.
    Action: If the export file was corrupted, retry with a new export file. Otherwise, report this as an Import internal error and submit the export file to customer support.
    Cheers,
    Francisco Munoz Alvarez
    http://www.oraclenz.com
    Edited by: F. Munoz Alvarez on Sep 13, 2008 8:48 PM

  • Open jpg image for readin error -- bandOffsets.length is wrong

    I have the following code to open and image for reading:
              BufferedImage image = javax.imageio.ImageIO.read(new File(url));
    very easy.
    But, I get an error with some images, the error is:
    Exception in thread "main" java.lang.IllegalArgumentException: bandOffsets.length is wrong!
         at javax.imageio.ImageTypeSpecifier$Interleaved.<init>(Unknown Source)
         at javax.imageio.ImageTypeSpecifier.createInterleaved(Unknown Source)
         at com.sun.imageio.plugins.jpeg.JPEGImageReader.getImageTypes(Unknown Source)
         at com.sun.imageio.plugins.jpeg.JPEGImageReader.readInternal(Unknown Source)
         at com.sun.imageio.plugins.jpeg.JPEGImageReader.read(Unknown Source)
         at javax.imageio.ImageIO.read(Unknown Source)
         at javax.imageio.ImageIO.read(Unknown Source)
         at notDefaultPackage.TestOpenImage.main(TestOpenImage.java:16)
    Any idea about what cause the error or how to solve it.
    Thanks for any idea or comment.
    Albert

    The relevant code in the java classes is this:
            public Interleaved(ColorSpace colorSpace,
                               int[] bandOffsets,
                               int dataType,
                               boolean hasAlpha,
                               boolean isAlphaPremultiplied) {
                if (colorSpace == null) {
                    throw new IllegalArgumentException("colorSpace == null!");
                if (bandOffsets == null) {
                    throw new IllegalArgumentException("bandOffsets == null!");
                int numBands = colorSpace.getNumComponents() +
                    (hasAlpha ? 1 : 0);
                if (bandOffsets.length != numBands) {
                    throw new IllegalArgumentException
                        ("bandOffsets.length is wrong!");
                }Did you maybe save an image as jpeg that contained transparency? When I do that with GIMP a warning pops up telling me that jpeg does not support transparency and if I would like to ignore or export. Here you should choose export.
    If that is not the problem I suggest you put some breakpoints and start debugging.

  • Error applying length,getStringVal() to xmltype column

    Hi All
    i have this simple query,and i need to get a length of each xml record returned,when i ran the below query which has 64 xmltype records.
    select t.msg,t.id
    from message_xml
    BUT, when i get the length of the records or use getStringVal() on the xmltype column i get an error "ORA-19011: Character string buffer too small"
    i.e select length(t.msg) len, t.id
    from message_xml
    What alternative way to get a length to an xmltype column and return all my 64 records and my xmltypes length vary from 2000-3800.

    Try using getclobval() instead:
    SQL>  SELECT LENGTH (XMLAGG (o.COLUMN_VALUE).getclobval ()) l
      FROM TABLE (XMLSEQUENCE (CURSOR (SELECT *
                                         FROM all_objects a
                                        WHERE ROWNUM <= 100))) o
             L
         39767

  • Context Menu error: 'length' is null or not an object

    When we run some of our reports (BI 7.0) and right click on the table to display the context menu we get a javascript error in the bottom left of Internet Explorer. The context menu doesn't appear.
    Once you expand the error is  'length' is null or not an object. It doesn't affect all the reports in fact so far we've only discovered 2 reports with this problem although there may be more.
    The reports with problems have had their own individual web templates developed. We haven't developed much of our own Javascript via the script web item and definitely none that would affect the context menu. The only code we have opens help pages/useful web pages/other apps etc. via buttons.
    None of the reports shows an error when you validate in the WAD software.
    We are currently using IE6 (upgrading to IE8 soon) and we have recently applied SP21 on the Java Stack.

    Hi Fred
    Did SAP come back with an OSS note to correct this issue. I am not finding anything in the Service marketplace.
    Thanks
    Adrian

  • APEX 4.0.2 Error on Master Detail Pages - 'length' is null or not an object

    Greetings,
    We just upgraded to APEX 4.0.2.00.07 this past weekend. Now a JavaScript error occurs when Master Detail pages are opened in IE 8. The error is - 'length' is null or not an object. I do not have a page item named length on any of these pages.
    The error does not occur in Chrome or Firefox, but the Add button on the detail portion of the page simply doesn't work.
    The page works when creating the master portion of the page. After the master row is created the region to add detail rows appears and the error occurs. So, the error appears to be with that part of the page.
    We use an Inactive Date column to soft delete rows in the detail portion of the page, so the detail regions have a date column, just in case this column is the problem.
    Does anyone have an idea what the problem might be?
    Thanks, Tony

    I too had this same problem and determined that the problem was due to a missing underscore character between the literal "report" and the report Id in the report template.
    I guess some themes include this underscore and some don't.
    I had to debug the apex_4.0.js to determine this - not easy as it's not nicely formatted.
    It only seems to stop Pagination working in an Updatable Tabular Form Report.
    Edit the Report Template. Go to the "Before Rows" region and edit the Before Rows text box. Locate where it defines the report id and insert an underscore between report#REGION_ID#
    Previous
    &lt;div id="report#REGION_ID#"&gt;
    Fixed
    &lt;div id="report_#REGION_ID#"&gt;

  • Packet Length errors

    We are getting frequent partition crashes in various service objects with
    this type of exception:
    FATAL ERROR: Packet length extracted from data is illegal (0x6d70).
    Class: qqsp_ImplementationException
    Error #: [501, 93]
    Detected at: qqcm_FortePacket::ReadHeader at 1
    Error Time: Tue May 22 17:43:54
    Exception occurred (locally) on partition "a_service_server_cl0_Part9",
    (partitionId = C83527E0-0DB4-11D5-B381-ED2750E6AA77:0x69ba, taskId =
    [C83527E0-0DB4-11D5-B381-ED2750E6AA77:0x69ba.5]) in application
    "a_service_server_cl0", pid 4091 on node tronsha4 in environment
    mdlprime.
    We are running Forte 3.0.M.6, compiled, on Solaris 2.6 with the most recent
    patches. I haven't found anything on this in the tech notes or the
    forte-users archive. I would suspect some port scanner activity, but this
    system is not attached to the public network, so I don't think that is
    possible.
    Any information would be greatly appreciated.
    Thanks,
    Mike Lapeyre
    EDS bluesphere

    Do you have any docs or infos with "mib" oder something i should check is the ap is a good condition. i have the problem that sometimes some aps "die" -> i have to reboot them, the problem is that i have to drive to them, they are not in my office.
    hope you can help me
    bernhard

Maybe you are looking for

  • Need a report with po,gr,ir values in LC and FC

    Dear experts, How can I develop this custom report  with po,gr,ir values in LC and FC with the following fields is their any standard sap report .Please advise PO NO PO DATE GRNO GR DT IR NO IR DATE VENDOR GR VALUE IR VALUE GR VALUE IN FC IR VALUE IN

  • Inter company cheque payment through F110

    Hi all, what customization needs for intercompany payments through F110. i customized settings, but cheques are not generated. can any one kindly tell me details of this settings. points will be awarded. Rgds, Soma

  • Sender Comm channel issue

    Hi to All. I am facing a issue sender comm channel? comm channel is picking the file before placing the file in the source dir, the file size is some times coming morethan 6MB. Could you please help me on this? Thanks in advance.

  • Using item values in the query

    Hi, Is there a way I can use item values in the query...? as an example, something like this select a.*, :P20_CUST_NAME as CUSTOMER_NAME from table TEMP a; haven't tried it yet but want to get the feedback first before making an attempt... Thanks

  • Integration Process and Action

    Hi everyone, Can some one explain about why do we need to create Action and Integration Process in ESR and use this Integration Process in Configuration Scenario.what's the use of creating this?