CodeWrapper.com RSS - Errors and Exceptions http://www.CodeWrapper/Exceptions Presenting 20 latest Errors and Exceptions. en-US CodeWrapper.com RSS Feed InvalidOperationException - Cannot close stream until all bytes are written http://www.CodeWrapper.com/Exceptions/View/16/invalidoperationexception-cannot-close-stream-until-all-bytes-are-written 129283761167913286 Kobo_t This exception is thrown when you use WebResponse.OutputStream and call to Close() before all bytes are written to stream. Possible Solution: Write all bytes to WebResponse.OutputStream before you close the stream. If you use encoding like UTF-16, make sure you get the length by encoding.GetBytes(myString).Length ServiceHost.Open throws ArgumentException while using certificate in secured WCF service. http://www.CodeWrapper.com/Exceptions/View/15/servicehost-open-throws-argumentexception-while-using-certificate-in-secured-wcf-service 129283761167991406 JimiR After creating self signed certificate with MakeCert.exe and using the certificate in WCF service, I am getting System.ArgumentException with message: "The certificate CN=localhost' must have a private key that is capable of key exchange. The process must have access rights for the private key." Possible Solution: Find the private key file using FindPrivateKey.exe and then set the access right for the process that the service is running under. You can find more details in the following link Character constant too long in GCC compiler. http://www.CodeWrapper.com/Exceptions/View/14/character-constant-too-long-in-gcc-compiler 129283761168059761 Kobo_t When compiling my code: char cNewLine = '/n'; int i = 0; I am getting this compilation error: character constant too long Possible Solution: Replace the '/n' with '\n'. HttpListener.Start() throws "Access denied" exception. http://www.CodeWrapper.com/Exceptions/View/13/httplistener-start-throws-access-denied-exception 129283761168118351 JimiR "Access denied" exception is thrown when starting HttpListener class. The following code will throw "Access Denied" exception.Dim listener As HttpListener = New HttpListener()listener.Prefixes.Add(andquot;http://localhost:8080/andquot;)' throws access denied.listener.Start() Possible Solution: Run the application with administrator privileges. undefined reference to 'foo' http://www.CodeWrapper.com/Exceptions/View/12/undefined-reference-to-foo 129283761168225766 JimiR Linker error when compiling C++ program in GCC. For example, the code below will cause the undefined reference to 'foo' link error. int foo(void); int main (void) { foo(); return 0; } Possible Solution: This linker error is caused when foo is not included in lib or any other objects supplied to linker. XmlWriter throws exception - The ':' character, hexadecimal value 0x3A, cannot be included in a name. http://www.CodeWrapper.com/Exceptions/View/11/xmlwriter-throws-exception-the-character-hexadecimal-value-0x3a-cannot-be-included-in-a-name 129283761168313651 Davido When trying to write element attribute: writer.WriteAttributeString(andquot;xmlns:xsiandquot;, andquot;http://www.w3.org/2001/XMLSchema-instanceandquot;); I am getting the following exception: Invalid name character in 'xmlns:xsi'. The ':' character, hexadecimal value 0x3A, cannot be included in a name. Possible Solution: Change the above line to: writer.WriteAttributeString(andquot;xmlnsandquot;, andquot;xsiandquot;, null, andquot;http://www.w3.org/2001/XMLSchema-instanceandquot;); It works :-) The type or namespace name 'FilterExecutingContext' could not be found http://www.CodeWrapper.com/Exceptions/View/10/the-type-or-namespace-name-filterexecutingcontext-could-not-be-found 129283761168382006 Unknown(Yahoo) When trying to compile ASP.NET MVC preview 2 method: override void OnActionExecuting(FilterExecutingContext filterContext) I am getting the following error: The type or namespace name 'FilterExecutingContext' could not be found Possible Solution: Replace FilterExecutingContext with ActionExecutingContextwith. InvalidOperationException : Cross-thread operation not valid: Control in C# BackgroundThread. http://www.CodeWrapper.com/Exceptions/View/9/invalidoperationexception-cross-thread-operation-not-valid-control-in-c-sharp-backgroundthread 129283761168450361 Davido I am getting InvalidOperationException: Cross-thread operation not valid: Control accessed from a thread other than the thread it was created on in a BackgroundThread DoWork event. Possible Solution: Do not use any of the controls in the DoWork event of the BackgroundThread. I wanted to read text from a text box inside the BackgroundThread.DoWork event. In order to get values from the controls you can set an object that contains all relevant values and pass it as argument to RunWorkerAsync method. In the DoWork you can get this object from e.Arguments. Error - Whitespace is not allowed at this location. http://www.CodeWrapper.com/Exceptions/View/8/error-whitespace-is-not-allowed-at-this-location 129283761168508951 Davido When trying to display XML in Internet Explorer, I am getting the error: Whitespace is not allowed at this location. Possible Solution: This error can be shown because of 'and' in the content of the XML. Try to remove/replace the 'and' in the XML content. Floating Exception - when dividing by zero. http://www.CodeWrapper.com/Exceptions/View/7/floating-exception-when-dividing-by-zero 129283761168577306 Unknown(Yahoo) In the following code example, a Floating Exception will be thrown. int some_value = 6; int zero_value = 0; int result = 0; result = some_value / zero_value; Possible Solution: Do not divide a number by zero. Using a variable as table name in FROM clause. http://www.CodeWrapper.com/Exceptions/View/6/using-a-variable-as-table-name-in-from-clause 129283761168635896 Unknown(Google) I wanted to use table name as a variable in a select from clause. For example: DECLARE @tableNameSET @tableName = "MyTable" SELECT * FROM @tableName When I run this SQL query, i got the following error: Must declare the table variable @tableName Possible Solution: Use Dynamic SQL. For the above example: DECLARE @sql = 'SELECT * FROM ' + @tableName EXEC(@sql) Error in C++ GCC compilation - "parse error at end of input." http://www.CodeWrapper.com/Exceptions/View/5/error-in-cpp-gcc-compilation-parse-error-at-end-of-input 129283761168743311 Unknown(Yahoo) I got the following error while trying to compile a C++ code using GCC: parse error at end of input. Possible Solution: There was a no closing brace (}). InvalidOperationException when creating a MultiInstance Performance Counter. http://www.CodeWrapper.com/Exceptions/View/4/invalidoperationexception-when-creating-a-multiinstance-performance-counter 129283761168889786 Joe L. When I am creating Performance Counter with a MultiInstance type, I am getting InvalidOperationException while trying to get NextValue(). The following error is received: Counter is not single instance, an instance name needs to be specified. PerformanceCounter myCounter = new PerformanceCounter("MyCatgeory", "Counter"); Console.WriteLine(myCounter.NextValue()); Possible Solution: The problem is that I was trying to create MultiInstance PerformanceCounter as a SingleInstance. I must specify an instance name (there might be more then one counter instance on the same machine).