Testing VB6 with NUnit
1. Create your VB6 code in an ActiveX DLL project
2. In Microsoft Visual Studio .Net create a DLL solution and add references to the .Net assembly
3. Write .Net test cases to invoke member functions of classes in Project.
Open source software
1. Software cannot be withheld by some companies just because it decides you shouldn’t be using the software any more unless you meet their demands.
Given a specific field, more software applications are available in OSS. Having a big selection is good; it creates better competitions and much better applications.
In almost all cases, Open Source means you can get it for no money, if you want. Sometimes the company or author may try to get you to upgrade or pay for a service, but mostly the software will be freely available.
2. Open Source software has a reputation for being very high quality, after it has been through the testing and real-world bashing. This is especially true for server-side toolsYou can fix problems or add tweaks according to your needs. This is obviously a huge win over proprietary software, where you are basically at the mercy of the company who owns the code.
OSS forces commercial companies to try harder to make their own offerings more attractive. It raises the bar, effectively
3. Anybody can join and write something, nobody is “running the show” and nobody can tell you what you can or can’t do. The barriers to entry are low; all you need is a computer and internet access.Code is really just an expression of ideas, therefore it is just right somehow to share knowledge.
1. When you have so much software being made available for free, it tends to devalue what programmers do. Although the sentiment is noble and worthwhile, in reality OSS means that stuff is made available for no money.
Companies with existing applications that were previously sold for money cannot compete with a product that is available for free. In the commercial world, this would be called “dumping”, i.e. dumping a whole bunch of product on the market in an effort to drive prices down, thus forcing some competitors out of business
2. Programmers love writing new stuff. They hate fixing other people’s code or even going back over their own code and fixing bugs… New code is exciting, innovative and so much more satisfying. Code always gets more messy the longer it’s around – all the new features, bug fixes etc build up over time until the whole thing just looks bad.
OSS projects are often run by a single developer sometimes personalities can get in the way, and in the case of very
popular and widely used tools, it can end up suffocating progress.
3. Sometimes OSS is simply a rip-off of some commercial package… How is a company supposed to compete with a free, reverse-engineered rip-off? It’s not competition when it’s free.
When something is available for free then it’s kind of hard to make money from it. It seems to do the OSS thing for no money, and make your money doing custom apps for companies. And that’s not making money from OSS.
An enum is a user-defined type consisting of a set of named constants called enumerators.
example :
public enum DAYS
{
Monday,
Tuesday,
Wednesday,
Thursday,
Friday,
Saturday,
Sunday
};
Internally, the compiler will use an int to hold these values
1. For the first literal: if it is unassigned, set its value to 0.
2. For any other literal: if it is unassigned, then set its value to one greater than the value of the preceding literal.
What is the Benefit of an Enum?:
1) The first advantage is that enumerated constants are generated automatically by the compiler. Conversely, symbolic constants must be manually assigned values by the programmer.
2) Another advantage of using the enumeration constant method is that your programs are more readable and thus can be understood better by others who might have to update your program later.
3) A third advantage to using enumeration constants is that some symbolic debuggers can print the value of an enumeration constant. Conversely, most symbolic debuggers cannot print the value of a symbolic constant. This can be an enormous help in debugging your program, because if your program is stopped at a line that uses an enum, you can simply inspect that constant and instantly know its value. On the other hand, because most debuggers cannot print #define values, you would most likely have to search for that value by manually looking it up in a header file.
you can assign your own integer constant to them as shown here.
public enum DAYS
{
Monday = 5,
Tuesday = 12,
Wednesday = 34,
Thursday= 54,
Friday = 3,
Saturday = 23,
Sunday = 11
};
In the two examples given, the values of each literal has been unique within the enumeration. This is usually how you will want things to be, but in fact the values need not be unique. In the following case, the value of DAYS.Thursday is also set to equal 1. The values assigned to the other literals will follow the rules given
previously, so both DAYS.Tuesday and DAYS.Friday will equal 2, etc.
public enum DAYS
{
Monday = 1,
Tuesday,
Wednesday,
Thursday= 1,
Friday ,
Saturday,
Sunday
};
In C# enumerations are type-safe, by which we mean that the compiler will do its best to stop you assigning illicit values to enumeration typed variables. For instance, the following code should not compile:
int i = DAYS.Monday;
DAYS d = i;
In order to get this code to compile, you would have to make explicit casts both ways (even converting from DAYS to int), ie:
int i = (int)DAYS.Monday;
DAYS d = (DAYS)i;
A useful feature of enumerations is that one can retrieve the literal as a string from the numeric constant with which it is associated. In fact, this is given by the default ToString() method, so the following expression comes out as true:
DAYS.Monday.ToString()==”Monday”
The following code prints out both the literal and its constant value for the specified enumeration.
using System;
public class EnumTest
{
public enum DAYS: byte
{Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday}
public static void Main()
{
Array dayArray = Enum.GetValues(typeof(EnumTest.DAYS));
foreach (DAYS day in dayArray)
Console.WriteLine(“Number {1} of EnumTest.DAYS is {0}”, day, day.ToString(“d”));
}
}
What is Safe Mode?
Microsoft Windows can be started in a special diagnostic mode known as “safe mode”. This mode of operation can be entered automatically by Windows following a serious problem, such as a misbehaving hardware driver causing the operating system to crash. It can also be selected manually by the user at start-up if there are known configuration or driver problems that require attention or that are preventing Windows from starting normally.
Safe mode limits the drivers that are loaded to the minimal set required for Windows to operate. This usually means that most peripherals do not function and that the installed video driver is substituted with a simple VGA driver that is supported by all standard graphics cards. This simple configuration makes it possible for the user to remove or replace faulty drivers and reconfigure registry settings that are corrupt or invalid.
If your application requires access to drivers that are not available in safe mode, you should detect the status of Windows before allowing the user to execute your software. If your application requires network access, you should also determine whether the operating system is in normal mode, safe mode or the special safe mode with networking support.
The boot mode of Windows can be determined easily using the SystemInformation class. This class is provided in the System.Windows.Forms namespace of the .NET framework. Within the class is a property called “BootMode” that returns a value of the BootMode enumerated type. This enumeration contains three possible values:
The following code can be added to a Windows application. It detects the current mode and, if it determines that the operating system is not in normal mode, execution is halted.
BootMode mode = SystemInformation.BootMode;
if (mode != BootMode.Normal)
{
MessageBox.Show("This program does not operate in safe mode.");
Application.Exit();
}
In your C# project property make sure ”Assembley Com Visible” and “Register for Com InterOp” are checked
Build the DLL
Create a strong key by running sn k mykey.snk from the command line.
Add the path of this generated file to your AssemblyInfo.vb or .cs file in the following manner:
C#: [assembly: AssemblyKeyFile(@"c:\path\mykey.snk")]After compiling your assembly to a DLL, you must register it for COM Interop from the command line:
regasm c:\path\MyDll.dll /tlb:MyDll.tlb
Finally, you should install the DLL into the Global Assembly Cache by dragging the .DLL file into the c:\windows\assembly folder
1. Create your VB6 code in an ActiveX DLL project
2. In Microsoft Visual Studio .Net create a DLL solution and add references to the .Net assembly
3. Write .Net test cases to invoke member functions of classes in Project.