What is difference between VB and VB.NET? Diff between VB & VB.NET • VB6 targets the COM infrastructure: a way to communicate with reusable components in Windows. • VB6 is simple to use because it contains many powerful functions and features in a runtime library that must be shipped(dispatch) with the programs you compile in VB6. • You can create Window applications or reusable ActiveX libraries with VB6. Diff between VB & VB.NET • VB.NET is the next generation of VB. • It targets the .NET Runtime and Framework. – The .NET Runtime manages the execution of the program and memory, and the .NET Framework represents reusable components, but incorporates a much broader set of Windows features than the VB6 runtime. • Additionally, .NET allows you to have a framework that is usable by many languages, including C#, C++, and Ruby, etc. Diff between VB & VB.NET • VB.NET gives you a number of new project choices, including ASP.NET web sites, WPF(windows Presentation foundation) applications, and console applications, and Windows services (VB Express just supplies the following project types: Windows Form application, Console, WPF application, Class library and WPF Browser application). • VB.NET compiles the code to IL, an intermediate byte code used by the .NET Runtime, but .NET will execute this code in native format by running it through a Just- In-Time compiler. Diff between VB & VB.NET • The .NET supports all OOP’s features – Encapsulation – Inheritance – Polymorphism What is .NET Framework? • .NET framework is platform independent and language independent . • It allows you to use different programming languages such as VB.net, C#, vbscript, Jscript and managed C++ and executes applications on different platforms such as LINUX, UNIX, and MACINTOSH. • It enables user to use various libraries that help the development of applications cheaper, faster and easier. What is .NET • By using .NET we can develop, internet enabled application. • Also we can develop windows based application. – .NET is Microsoft’s new Internet & web technology/Strategy – .NET is a new Internet and Web based Infrastructure – .NET is a framework for universal services – .NET will run in any browser on any platform .NET Framework? • The most important component of the .net framework is CLR(Common Language Runtime),which provides the environment in which the programs are executed. • The CLR includes a virtual machine, which is similar in many ways to the Java virtual machine (JVM). .NET Framework? • In the above figure the layer on top of the CLR is a set of framework base classes, followed by an additional layer of data and XML classes, another layer of classes intended for web services, web forms and windows forms. • Collectively these classes are known as Framework Class Library (FCL). • The set of framework base classes, is similar to the set of classes in JAVA. .NET Framework? • Above this FCL layer the ADO.net and XML layer supports data management and XML(Extensible Markup Language) manipulation. • The ADO.net supports persistent management of data that is maintained on backend database which include Structured Query Language (SOL) classes to let you manipulate data stores through a standard SQL interface. .NET Framework? • Extending the framework base classes and the ADO.net and XML classes is a layer of classes geared toward building applications using three different technologies: • Windows Forms • Web Forms • Web Services .NET Framework? • Web services are the software components that expose a service over the web. • Web forms and windows forms allow you to apply rapid application development techniques and web applications. • Simply drag and drop controls on to your form, double-click a control, and write the code to respond to the appropriate event. .NET Framework? • The CLS (or Common Language Specification) is a simply a contract between programming language designers and class library authors. The CLS is basically just a subset of the entire set of features supported by the CLR. CLR(Common Language Runtime)
• The CLR is the heart of the .NET framework.
• The most important component of the .NET framework is the Common Language Runtime i. e. CLR. It manages and executes code written in .NET languages and is the basic of the .NET architecture, it is similar to the Java Virtual Machine. • It provides the environment within which the program runs. The software version of .Net is actually a CLR version. The CLR architecture: The components of architecture include:
• Class loader, which loads classes into the
runtime. • MSIL to native code compiler, which converts MSIL code to native code. • Code manager, which manages the code during execution. • Security engine, which enforces security restrictions. The components of architecture include:
• Type checker, which enforces strict type
checking. • Thread support, which provides multithreading support to applications. • Exception manager, which provides a mechanism to handle the run-time exceptions. The components of architecture include:
• Debug engine, which allows you to debug
different types of applications. • COM marshaler, which allows .NET applications to exchange data with COM applications. • Base class library support, which provides the types that the applications need at run time. .NET compilation process • The code running under the control of the CLR is often termed as managed code. Before execution of the source code it needs to be compiled which occurs in 2 steps in .NET – Compilation of source code to managed code/Intermediate Language (IL). – Compilation of IL to platform-specific code by CLR. • When the .NET program is compiled, the output of the compiler is not an executable file but a file that contains a special type of code called the Managed code/Inter mediate Language/Microsoft Intermediate Language (MSIL). • This MSIL defines set of portable instructions that are independent of any specific CPU. • It is the job of CLR to translate this IL code into a executable code when the program is executed making the program to run in any environment for which the CLR is implemented. • The MSIL code is turned into executable code using a JIT (Just In Time) compiler. The process goes like this, when .net programs are executed the CLR activates the JIT compiler. The JIT compiler converts MSIL to native code on a demand basis as each part of the program is needed. CTS (Common Type System) • CTS is a subset of CLS(Common Language Specification). • The .NET considers all languages as equal, a variable defined in c# should be equivalent to variable defined in VB.net. • In order to make this possible Microsoft has specified a common type system to which every .NET language must follow. CTS (Common Type System)…. • For e.g. visual basic 2005’s integer is actually a 32-bit signed integer, which maps exactly to the IL type known as Int32. • So when a variable defined in vb.NET as integer and a variable defined in C# as int IL considers it as a int with the help of CTS. The following figure shows hierarchical structure of CTS. AND MSIL • MSIL stands for Microsoft Intermediate Language, • Similar to that of Java Byte code that is formed when you compile a Source Code • The main purpose of this Intermediate code formation is to have a platform independent code...that is once MSIL/Java Byte Code is available you can run code on any platform provided appropriate run time environments are installed on the specific platform you wish to run...JVM in case of Java and CLR in case of .NET Compiling to MSIL • When compiling to managed code, the compiler translates your source code into Microsoft intermediate language (MSIL), which is a CPU- independent set of instructions that can be efficiently converted to native code. • MSIL includes instructions for loading, storing, initializing, and calling methods on objects, as well as instructions for arithmetic and logical operations, control flow, direct memory access, exception handling, and other operations. • Before code can be run, MSIL must be converted to CPU-specific code, usually by a just-in-time (JIT) compiler. • Because the Common Language Runtime supplies one or more JIT compilers for each computer architecture it supports, the same set of MSIL can be JIT-compiled and run on any supported architecture. AND Garbage collection • The garbage collection is .NET’s answer to memory management. • The .NET framework’s Garbage collection manages the allocation and release of the memory for your application. Garbage collection… • Every time the user uses the ’new’ operator to create an object, the runtime allocates memory for the object; it continues to allocate space for new object until it get the same. • However the memory is not infinite so its garbage collectors job to check and release the memory which is not being used. Garbage collection… • The .NET Framework's garbage collector manages the allocation and release of memory for your application. As long as address space is available in the managed heap, the runtime continues to allocate space for new objects. Garbage collection… • Eventually the garbage collector must perform a collection in order to free some memory, since memory is not unlimited. • The garbage collector's optimizing engine determines the best time to perform a collection, based upon the allocations being made. Garbage collection… • When the garbage collector performs a collection, it checks for objects in the managed heap that are no longer being used by the application and performs the necessary operations to reclaim their memory. • Methods which are used by garbage collector: – Finalize. – Dispose. Assemblies • In the normal windows application we have the concept ActiveX EXE and ActiveX DLL, but that is not used in the .NET application. Instead of that type is called as Assemblies. • Assemblies are the building blocks of .NET Framework applications; they form the fundamental unit of deployment, version control, reuse and security permissions. Assemblies…. • An assembly is a collection of types and resources that are built to work together and form a logical unit of functionality. • An assembly provides the common language runtime with the information it needs to be aware of type implementations. To the runtime, a type does not exist outside the context of an assembly. Assemblies…. • Assemblies take the form of an executable (.exe) file or dynamic link library (.dll) file, and are the building blocks of the .NET Framework. • They provide the common language runtime with the information it needs to be aware of type implementations. • You can think of an assembly as a collection of types and resources that form a logical unit of functionality and are built to work together. Assemblies…. • With Visual Basic, you use the contents of assemblies, and add references to them, in much the same way as you use type libraries with previous versions of Visual Basic. Assembly Manifest • Within every assembly is an assembly manifest. Similar to a table of contents, the assembly manifest contains the following: • The assembly's identity (its name and version). • A file table describing all the other files that make up the assembly, for example, any other assemblies you created that your .exe or .dll file relies on, or even bitmap or Readme files. Assembly Manifest…. • An assembly reference list, which is a list of all external dependencies—.dlls or other files your application needs that may have been created by someone else. • Assembly references contain references to both global and private objects. • Global objects reside in the global assembly cache, an area available to other applications, somewhat like the System32 directory. Assembly Contents • An assembly can be viewed by firing command on command prompt by using following steps • Start -> Run -> Cmd ->cd\ • cd C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin> • ILDASM • (The figure contains the Manifest, Meta Information etc.) Assembly Types • Assemblies can be private or shared. • Private assemblies are available only to clients in the same directory structure as the assembly; • Shared assemblies are available to any local COM application. All assemblies and type libraries must be registered in the Windows registry so COM clients can use the managed types transparently. Assembly Types Private Assemblies • Assemblies are private by default. • This means that, when you use it in any of the .NET application, a physical copy of it get created in application folder, i.e bin folder of .NET application. • So, when you change the path of the output file of the .NET application, the program will give an error. • This situation of execution is very irritating. To solve this we must have shared assembly by installing that assembly in Global Assembly Cache (GAC). Assembly Types Shared Assemblies • When the private assembly is installed in Global Assembly cache, it is called as shared assembly. • For this purpose, as assembly must have identification. Once the assembly is installed in GAC, it can be referred in any .NET application, now it will not create any physical copy in application folder of .NET application. Even you change the path of the output file. Global Assembly Cache ActiveX DLL & ActiveX EXE • An ActiveX Dll runs is an in process server running in the same memory space as the client process.
An ActiveX Exe is an out of process server
which runs in it's own separate memory space. What is COM? • Microsoft COM (Component Object Model) technology in the Microsoft Windows-family of Operating Systems enables software components to communicate. • COM is used by developers to create re-usable software components, link components together to build applications, and take advantage of Windows services. • COM objects can be created with a variety of programming languages. Object-oriented languages, such as C++, provide programming mechanisms that simplify the implementation of COM objects.