.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Parameter is not valid. memory stream error

Posted By:      Posted Date: May 22, 2011    Points: 0   Category :Windows Application

Hi,  I have these 2 functions that save an image using a stream, it works with small images (1kb) but not with large ones.

and i get the error:

Parameter is not valid.


Line 202: long len = ms.Length;

Line 203: byte[] b = new byte[len];

Line 204: using (System.Drawing.Image image = System.Drawing.Image.FromStream(ms))

 Line 205: {

Line 206: image.Save(Path.Combine(@"C:\Trash\", fileName));


        public static string writeImage(string imageLink)
            string fileName = getFileName(imageLink);
            HttpWebRequest req = (HttpWebRequest)WebRequest.Create(imageLink);
            HttpWebResponse resp = (HttpWebResponse)req.GetResponse();

            using (Stream st = resp.GetResponseStream())

                MemoryStream ms = (MemoryStream)CopyStream(st);
                ms.Seek(0, SeekOrigin.Begin);
                long len = ms.Length;
                byte[] b = new byte[len];
                using (System.Drawing.Image image = System.Drawing.Image.FromStream(ms))

View Complete Post

More Related Resource Links

error: null is not valid value for stream


Dim strm As System.IO.Stream = Me.GetType().Assembly.GetManifestResourceStream("fullbuttonface.bmp")

_buttonFace = New Bitmap(strm)

May be the  bitmap file is not part of the assembly, how do I put it in the assembly


'TDS Protocol stream is not valid' error when running SQL Server 2008 with jdbc driver of version


I am using SQL Server 2008 on Windows Server 2008 R2 and one of our servers running as a windows service (on Windows Server 2008 R2) contacts the SQL Server 2008 in a timely fashion to get some information. During one of these runs, we encountered the following error logs in the service logs and thereby we took a hit in serving client requests. The jdbc jar that is used for database connectivity is of version 3.0 (sqljdbc.jar).


I can provide more details on this issue. Can someone please let us know why this can be occurring ? Just so you know, the set of errors repeats itself after sometime although on a different JDBC Connection (with different ConnectionID). We have a reconnection algorithm running in case the JDBC Connection is lost for some reason (but I would be surprised if this issue relates to the re-connect algorithm).


INFO   | jvm 1    | 2011/02/28 22:26:54 | Feb 28, 2011 10:26:54 PM com.microsoft.sqlserver.jdbc.TDSParser throwUnexpectedTokenException
INFO   | jvm 1    | 2011/02/28 22:26:54 | SEVERE: TDSReader@4686d ( ConnectionID:25 TransactionID:0x0000000000000000): FetchBufferTokenHandler: Encountered unexpected TDS_RET_STAT (0x79)
INFO   | jvm 1    | 2011/02/28 22:26:54 | Feb 28, 2011 10:26:54 PM com.microsoft.sqlserver.jdbc.TDSReade

Tools for memory error check in VS2005


Dear all,

I am going to write vs2005 program with ASP.NET and C++.

As you know that C++ will involve a lot of memory error handling.

Do you know is there any tools for checking memory error in Code Behind C++??

override error message (The value 'test' is not valid for Age) when input incorrect data type for in


Hello everyone,

I've tried to override error message when input incorrect data type in input field on HTML form. For example I have the model like this.

public class Person
public string FirstName {get;set;}
public int Age {get;set;}


For view, I put text input for Age to get it value.

When type some string in Age text box like 'test' and press submit button. I got this error message

The value 'xxx' is not valid for Age

However, I want to change this message and try many way. There 's nothing effect this message value.

Please could you help me to solve this problem.

Conversion of Byte Array to Memory stream


how to convert byte array to memory stream in vb.net.

ssrs 2008 R2 - report parameter with no default set throws java script error

We have recently upgraded from SQL Server 2008 to SQL Server 2008 R2....I am experiencing a problem with my report parameters on my SSRS reports. It seems that my report parameters that I do not have a specified 'default' value throws a java script error when I try and run/render the report under R2.  As soon as I put a 'default' value on the report param, everything is fine.  However, that is not the behavior we need for our reports...the user needs to pick their selection. Can anyone shed some light on this, it seems to be an AJAX problem...I need to be able to have report parameters with a list of values, but no 'default' value on the parameter.

sql 2005 sp2 memory error FAIL_VIRTUAL_RESERVE

We're running SQL Server 2005 SP (9.00.4035.00) 32 bit on Windows Server 2008 SP2 Enterprise.   The server has 8gb of RAM and is only used for SQL Server.  Since Windows 2008 SP2 was installed on 8/23/2009, once every week or so the server has become unresponsive.  Early in in the course of the problem I notice the following error in the SQL Server error log:  Failed Virtual Allocate Bytes: FAIL_VIRTUAL_RESERVE 1048576 That's followed by the output of DBCC MEMORYSTATUS, which I'll include at the end of this post. After that, things work normally for several hours, except for some occurences of Downgrading backup log buffers from 1024K to 64K That appear in the SQL Server error log when our transaction log backups occur.  Some time after that, we begin to receive Event ID: 701 There is insufficient system memory to run this query. In the event logs of our server. At that point, the server becomes unresponsive.  Restarting the SQL Server Service resolves the issue. Is anyone else experiencing this? It's only been happening 1 time per week (not consistently the same time) and has only occurred since Windows Server 2008 SP2 was installed.  I don't know if that's related, but it's the only real change to that server.  Workload has been consistent on that server for months. Can someone please help? Thanks. Here's the DBCC output. Memory Manager     VM Reserved =

AdomdDataAdapter.Fill returns memory error when querying an SSAS Cube(2008)

For certain SQL's I will get the following error when calling the Fill method on an AdomdDataAdapter object. "Memory error: While attempting to store a string, a string was found that was larger than the page size selected. The operation cannot be completed."   Snippet of Code: DataSet ds1 = new DataSet(); AdomdCommand acmd1 = cn1.CreateCommand(); acmd1.CommandText = "SELECT ..."; AdomdDataAdapter ad1 = new AdomdDataAdapter(acmd1); ad1.Fill(ds1);   Now when we run this query in Ms Sql Studio we don't get any errors but the query returns 1 row with over 40,000 columns. I'm guessing the # of columns might be an issue but not sure.   When doing a Google search it appears that this problem was found in the 2005 and fixed in that version. Have any of you come across this problem?  

SSAS 2008 - Memory Error

During our unit and load testing of the SSAS database using VSTST 2010 Ultimate; we are getting a memory error with some of our MDX queries (below).  Futher analysis showed: The adomdDataAdapter "Fill" command is our error point The error is occuring when the result data set has getter than 16,384 Columns; actual returned column count is 41,339 columns - business requirement does not let us change this query at this time. The MDX query works fine in MS Excel 2007 The MDX Query works fine in MS SQL Studio 2008 How can we resolve the unit test data set with such a large column count? Memory error: While attempting to store a string, a string was found that was larger than the page size selected. The operation cannot be completed. In reference to thread: http://social.msdn.microsoft.com/Forums/en-US/sqlanalysisservices/thread/4220adbb-438c-42e7-9612-56aebf8df435/ Thank you, Craig  

Help with error "The AdomdDataReader object is not positioned at a valid row"

I have a PerformancePoint grid from which users can drillthrough into records in the underlying cube.  The cube itself imposes no limit on the number of records returned by drillthrough.  The server has a limit of 10,000 drillthrough records.  The Analysis Services build is 10.0.2531.0  In any event, the drillthrough itself always works, but when the number of records is large (say, 6000 or so), users receive the following error when attempting to export the results to excel: Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.InvalidOperationException: The AdomdDataReader object is not positioned at a valid row. Source Error: An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. Stack Trace: [InvalidOperationException: The AdomdDataReader object is not positioned at a valid row.] Microsoft.AnalysisServices.AdomdClient.AdomdDataReader.InternalGetValue(Int32 ordinal) +423 Microsoft.AnalysisServices.AdomdClient.AdomdDataReader.GetString(Int32 ordinal) +7 Microsoft.PerformancePoint.Analytics.WebC

DontSaveSensitive; Key not valid for use in specified state error

I initially had my packages set to 'EncryptSensitivewithPassword' and usedthe config files.  My job executes fine.  But I noticed I was getting THE error "......Key not valid for use in specified state.....".  So, I change the protection level to 'DontSaveSensitive' , saved packaged ,build and re-imported it.  And I still get the same result. What am I doing wrong??   Package is on the same server where it was built. I have a package in production that executes without the error.  I made a change to the package (logging) in test and now it also encounters same error as the package referenced above.

SSRS 2008 Export to PDF fails for large data with System.Exception: Parameter is not valid

Hi, We are working on Range Bar Chart using SSRS 2008. The report has huge data. It is properly displaying the data, but when we tried to export to pdf it is failing with the following exception. Exporting to excel works fine. Also if the report has small/medium data it is property exporting to PDF. It is failing only in case of huge data (we have custom page size of 28" X 14"). Of course the report has lot of expressions we used to customize the colors/text as per our requirements.   Server Error in '/Reports_SQLDEV2008' Application. Parameter is not valid. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Exception: Parameter is not valid. Source Error: An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. Stack Trace:   [Exception: Parameter is not valid.]   [Exception: An error occurred during rendering of the report.]   [Exception: An error occurred during rendering of the report.]    Microsoft.Reporting.WebForms.ServerReport.ServerUrlRequest(Boolean isAbortable, String url, Stream ou

processing measure group : memory error : the operation cannot be completed because the memory quota

Hi, I'm stucked with this problem. Untill last week, the cube processed without any problem. Since last week, I'm getting this error. I have been searching in different forums, and I tried some suggestions, like changing memory limit properties, ... It is getting worse.. So I reset all properties to default again. I am running SQL-Server + MS-AS 2005 SP2 on server with 4GB of memory. This is a dedicated server, nothing else is running on it. The fact table has +/- 14 million records, several dimensions en 2 measure groups. I don't have problems to process the dimensions, but when I try to process the cube or the measure groups of that cube separately , the error persists. I have changed the datasource view, and replaced the fact table by a Named query. Even when I put a 'WHERE datapart( year , fact_date ) >= 2009 ' clause to reduce the number of records to +/- 5 million, I'm still getting the error. I don't understand what is wrong, the cube always processed since +/- 2 years. As I said, I have found a lot of this kind of Issues on different websites, I have been trying to change some properties. But this still does not solve the problem. Could it be that MS-AS settings are corrupt somewhere ? Is it a good idea to re-install MS-AS 2005 + SP1 + SP2 ? Or is there another reason possible ? I really appreciate any kind of help, because I'm

Interesting error message with content organiser: Cannot resolve mailbox (null) to a valid user

Here is a site with content organiser site feature enabled, as well as the email integration feature. Emails are successfully delivered to the "Submitted Email Records" list, but is never routed to the Drop Off Library. (the content organiser web service works fine and the drop off library works as a custom send to destination and happily processes its rules. If I turn up the debug juice I get the error "Cannot resolve mailbox (null) to a valid user" for every item in any "Submitted Email Records" in the site collection. Area: Document managagement Category: Content organiser EventID: 8000 Message: Cannot resolve mailbox (null) to a valid user I have temporarily worked around the problem by email enabling the drop off library but it creates an intermittent race condition (similar to certain workflow and event receiver situations), so its not a real solution (and in fact I assume thats why the Submitted Email Records hidden list exists in the first place). I've run procmon, specifically focusing on OSWTIMER and nothing interesting shows up at all. The error message is intriguing and I can't really think of what it is trying to do. In troubleshooting I noted that this farm had configured inbound email but not outbound email. I have since rectified this and de/reactivated the content organiser features and reset the timer service and IIS, b

StreamWriter Error: Cannot close stream until all bytes are written.

 Hi, I have a testing platform that allows data to be posted to a real time collection system.  It uses the StreamWriter object to send both HTTP and XML formats, It works fine, but there is a new request to submit uploaded files.  This again works fine, unless the files are over 70k (we need to test upto 3MB).  If it is over 70k, the response is the content-length too big.   I have changed it so that the content-length is now set dynamically, dependant on the size of the file uploaded.  However, when the StreamWriter.Close() runs, the execption The request was aborted: The request was canceled. is generated, with the InnerException Cannot close stream until all bytes are written.From what I have found on the web, the solution is use StreamWriter.Flush(), but this code is already in place. Code is as follows:  With WebRequest .Method = "POST" .ContentType = "application/x-www-form-urlencoded" .PreAuthenticate = False .AuthenticationLevel = Security.AuthenticationLevel.None End With If FileSize > 0 Then WebRequest.ContentLength = FileSize End If Try RequestStream = WebRequest.GetRequestStream() StreamWriter = New StreamWriter(RequestStream) StreamWriter.Write(strDataToPost)

Cannot delete external data list column due "Parameter name: combinedEncoded" error

Hello!   I migrated a Sharepoint 2007 to a Sharepoint 2010 by dbattach method. And now I want to delete the BDC list columns, but I'm getting this exception: System.ArgumentException:   Parameter name: combinedEncoded    at Microsoft.SharePoint.BdcClientUtil.SplitStrings(String combinedEncoded) What should I do to delete properly this columns?   Many thanks!

While trying to view a report in integrated mode i see an unsupported RPL stream error

Trying to deploy a report in integrated mode on MOSS 2007. SQL server version is 2008 R2. I see the following:   ??? ?????????? ? ????м???? ?? ??????? ????????? ??????. ?????????? ?????????????м?? ?????? ?????? RPL: 34.62.1836345404. ??????м?? ??????: 10.3.     Yes i know its in russian. Another fail of Microsoft not being able to see the error codes and strings in english language, makes finding solutions even harder, because first you must find HOW is this called in english, then look for solution. Okay so, i found out that it is actually transalted into: unsupported RPL stream version detected 34.62.1836345404 expected version 10.3 Now, everywhere around the webs they say that this is because my Add-in is out of date and i need new RS addin for MOSS 2007.  But the link is dead!    For example, here http://social.msdn.microsoft.com/Forums/en-US/sqlreportingservices/thread/61357765-52aa-4085-9ee0-4cb494a6c3ad   @For SQL 2008 R2 together with WSS 3.0 / MOSS 2007, you need the SQL server 2008 november CTP add in:  http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=44bda62c-0cda-4a99-8d0a-d7fe06b39422 But the link is dead and there is no hint as to what happened.   The only valid link i found is this: http://www.microsoft.com/downloads/en/details.aspx?FamilyID=65606fdd-093f-4c
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend