Getting all types in a namespace via reflection

Following code prints names of classes in specified namespace defined in current assembly. As other guys pointed out, a namespace can be scattered between different modules, so you need to get a list of assemblies first. string nspace = “…”; var q = from t in Assembly.GetExecutingAssembly().GetTypes() where t.IsClass && t.Namespace == nspace select t; … Read more

How can I make the cursor turn to the wait cursor?

You can use Cursor.Current. // Set cursor as hourglass Cursor.Current = Cursors.WaitCursor; // Execute your time-intensive hashing code here… // Set cursor as default arrow Cursor.Current = Cursors.Default; However, if the hashing operation is really lengthy (MSDN defines this as more than 2-7 seconds), you should probably use a visual feedback indicator other than the … Read more

.NET 4.0 has a new GAC, why?

Yes since there are 2 distinct Global Assembly Cache (GAC), you will have to manage each of them individually. In .NET Framework 4.0, the GAC went through a few changes. The GAC was split into two, one for each CLR. The CLR version used for both .NET Framework 2.0 and .NET Framework 3.5 is CLR … Read more

Release generating .pdb files, why?

Because without the PDB files, it would be impossible to debug a “Release” build by anything other than address-level debugging. Optimizations really do a number on your code, making it very difficult to find the culprit if something goes wrong (say, an exception is thrown). Even setting breakpoints is extremely difficult, because lines of source … Read more

LINQ: Not Any vs All Don’t

Implementation of All according to ILSpy (as in I actually went and looked, rather than the “well, that method works a bit like …” I might do if we were discussing the theory rather than the impact). public static bool All<TSource>(this IEnumerable<TSource> source, Func<TSource, bool> predicate) { if (source == null) { throw Error.ArgumentNull(“source”); } … Read more

Gmail Error :The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required

When you try to send mail from code and you find the error “The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required”, than the error might occur due to following cases. case 1: when the password is wrong case 2: when you try to … Read more

Get URL parameters from a string in .NET

Use static ParseQueryString method of System.Web.HttpUtility class that returns NameValueCollection. Uri myUri = new Uri(“http://www.example.com?param1=good&param2=bad”); string param1 = HttpUtility.ParseQueryString(myUri.Query).Get(“param1”); Check documentation at http://msdn.microsoft.com/en-us/library/ms150046.aspx

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)