Archive

Archive for January, 2012

Could not load file or assembly. Operation is not supported. (HRESULT: 0280131515) in SGEN

January 25th, 2012 No comments

Today, I tried to make a Release Build of a rather large solution and I got this exception:

Could not load file or assembly ‘file:///C:\some.dll’ or one of its dependencies. Operation is not supported. (Exception from HRESULT: 0×80131515) C:\somepath\SGEN

The solution is simpler than it looks like:
The DLL was downloaded from the web and somehow, Windows “blocked”. To unblock it, just right-click the DLL in your explorer and click the “Unblock” button (make sure, you have write access to the file).
That’s all what is needed to fix this problem (at least in my case).

Ad
Categories: General, Programming, Tools, VisualStudio Tags:

Pretty Format File Size

January 12th, 2012 No comments
static string FormatBytes(long bytes)
{
	const int scale = 1024;
	string[] orders = new string[] { "GB", "MB", "KB", "Bytes" };
	long max = (long)Math.Pow(scale, orders.Length - 1);

	foreach (string order in orders)
	{
		if (bytes > max)
			return string.Format("{0:##.##} {1}", decimal.Divide(bytes, max), order);

		max /= scale;
	}
	return "0 Bytes";
}

Source: http://sharpertutorials.com/pretty-format-bytes-kb-mb-gb/

Ad
Categories: C#, Programming Tags: