Most of the programmers who uses Visual Studio .NET knows PropertyGrid which is the main control in the Properties Window of the Visual Studio.
If you have written any .NET components you must be familiar with Category and Description attributes. We use Category attribute to identify the property’s category and Description attribute is for the short description of that property. But because of the nature of Attributes in .NET we cannot pass any parameter to these attributes for Multilanguage support.
[Category(Properties.Resources.MyCategory)]
[Description(Properties.Resources.MyDescription)]
public int MyProperty { … }
This kind of usage is not allowed for .NET, because we are only allowed to give constant values to the attributes constructor. So how can we use these attributes as Multilanguage?
If you are using Team Foundation Server with Visual Studio, it will be useful for you to integrate your projects bug system with the TFS Work Items system. You can write a simple module for your program which will handles the exceptions and collects needed information and send them to the TFS.
So how can we do something like that? First you have to write an error management module which will handles exceptions, errors, etc. and generates understandable information from them. After generating this information lastly you have to send this information to the TFS.
When I was newbie in .NET, it was a shocked for me to learn that .NET assemblies can be decompile. But today I know that this is a normal situation for a language which is compiling to an intermediate language. As we know that, after compiling a .NET project the output will be in MSIL (Microsoft Intermediate Language). And during the application lifecycle this codes will be compiled to Native Codes by the JIT (Just-In-Time Compiler) when they first used and cached in that computer for the future usages. Anyway this is another subject for us how JIT works, but here the problem is our assemblies are in MSIL format which has about 229 opcodes and all these opcodes has a standard working procedure. So if we know these opcodes and how they are working, we can produce the .NET codes by reverse engineering. This is simply what decompilers do. But why there are no stable decompilers for the native exes?
Most of the people know that switch works like if-else blocks. The only difference between the switch and if-else is its being for the many conditional states, and also writing switch is more simple than if-else block. This knowledge is really a big mistake because switch has a different algorithm and working-procedure comparing to if-else block. To demonstrate this, I wrote a simple example which indicates the performance differences between switch and if-else in many different situations.
In one of my public projects, I used Xenocode PostBuild to obfuscate my codes. PostBuild is a very popular and common Obfuscation Tool for the .NET assemblies. When I worked for the Xenocode, I saw that the developers of PostBuild are really very good at doing their jobs. Most of them had worked for the Microsoft before. So I can say that if you need an obfuscation tool, you can use Xenocode PostBuild obfuscation tool without thinking a second.
Today I wrote a simple application, which shows what the difference is between initializing a static field in the explicit static constructor and doing the same during the declaration time (inline). I know that even when we initialize our static fields inline, the compiler will add an implicit static constructor to that class and initialize static values in that method. But this example showed me that there is really a long time difference between initializing static fields inline and in explicit static constructor. Here are a screenshot from the example – in this example BeforeFieldInit means that the static fields are initialized inline and NotBeforeFieldInit means that static fields are initialized in the explicit static constructor:
For a very long time ago, in one of my projects, I needed to capture the screenshot which must have to support both full screen capturing and specific regional capturing.
Also I need to paste that captured image back to the screen programmatically. At that moment I solved my problem by using some WinApi methods in the user32.dll and gdi32.dll. Here I want to share that code with you.
If you want to find MS SQL Servers which are available in a network, there are two different ways you can use for searching the network for available Sql Servers.
1 – There is a class in the .NET Framework which name is SqlDataSourceEnumerator in the System.Data.Sql namespace. We can use that class, and get the sql servers easly:
DataTable sqls = SqlDataSourceEnumerator.Instance.GetDataSources();
In this method we can only get the Sql Server machines on a network. There is also another method to get list of SQL Servers on a network. Also this second method can also be used to search for some other type of servers too. Here is the second method;
Everybody knows that Reflection is a really very important topic in .NET. So I won’t repeat the importance of it, it is an unquestionable subject; besides, I have to admit that it saved my life too many times.
But like every good thing Reflection has also some disadvantages, too. One of the important disadvantages of the Reflection is performance.
Search
Categories
- .Net (19)
- C# (12)
- General (13)
- Open Source Projects (4)
- Quantum (1)
- Tools (9)
- Visual Studio (6)