Показаны сообщения с ярлыком c#. Показать все сообщения
Показаны сообщения с ярлыком c#. Показать все сообщения

четверг, 1 июля 2010 г.

(Exception from HRESULT: 0x80070057 (E_INVALIDARG))

Server Error in '...' Application.

Could not load file or assembly '...' or one of its dependencies. The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))

В один прекрасный момент одно из приложений перестало работать выдавая вот такую ошибку, якобы ругаясь на стороннюю библиотеку в Reference-ах, дак вот как оказалось библиотека тут не причем, все в дело в конфликте между новой версией скомпилированного кода и его временной копией в папке C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\
Все что нужно - это вручную почистить временную папку "Temporary ASP.NET Files" и все.

линки:
http://social.msdn.microsoft.com/forums/en/csharpide/thread/352c58ec-65d8-4d77-ac7b-d2338c621ef3/
http://www.solutioncottage.com/ShowSolution.aspx?solID=59

четверг, 18 марта 2010 г.

Random in C#

This code is wrong example of using Random class. Each element of the arr will be the same.
And don't trust the Debug mode! Because in Debug mode with breakpoints you will see different values each time.

  1. int[] arr = new int[count];
  2.  
  3. for (int j = 0; j < count; j++)
  4. {
  5.   Random rnd = new Random();
  6.  
  7.   arr[j] = rnd.Next(int.MaxValue);
  8. }
* This source code was highlighted with Source Code Highlighter.

Use this one! good Example below:

  1. int[] arr = new int[count];
  2. Random rnd = new Random();
  3.  
  4. for (int j = 0; j < count; j++)
  5. {
  6.   arr[j] = rnd.Next(int.MaxValue);
  7. }
* This source code was highlighted with Source Code Highlighter.

пятница, 19 февраля 2010 г.

How to convert Stream to byte array

It's pretty easy!

Code on C#:
  1. int length = Convert.ToInt32(inputStream.Length); // get strem length
  2. byte[] byteArr = new byte[length]; // create a byte array
  3. inputStream.Read(byteArr, 0, length);
  4. inputStream.Close();
* This source code was highlighted with Source Code Highlighter.

Code on VB you can find here: http://snipplr.com/view/2012/stream-to-byte-array/