Now That You Got The Best MSDN Subscription Price

Posted by Msdn Blog on April 20th, 2010

You need to make sure that you know how to use everything in your MSDN Premium Subscription so you can get the most out of it. Determine which features you will use right off the bat.

Determine which systems you want to use once you have the MSDN premium subscription. You will be able to use the tools, systems, servers, and programs you need.

For starters, choose whether you’ll use the developer tools like Visual Studio 2008 or different Visual Studio Tools for office. Check out the various development tools available so you can be sure you are using the best ones for your work.

Make sure you have the right operating system or systems. By using the MSDN premium subscription, we can have a access to the operating systems like windows vista,XP and also to the windows server.

Then, pick out which kind of server you will use; options include Windows, Biztalk, and SQL Server 2008. To decide which server is best for you just think of what you need in a server and read about the different servers to see which one best fills your need. Keep in mind that with MSDN Premium Subscription you will have access to all of them so you don’t need to worry about compatibility with any of them and you can use different ones for different situations.

Then, you’ll want to take a look at the various programs and set them up to your needs. Chances are good that you’ll be using everything that the Microsoft Office Suite has to offer to you – simply because that remains to be one of the best office systems you can have. You will get right down to business and your work will get done quickly because there are so many different programs and tools you can use. By having a MSDN premium subscription, you can allow yourself the freedom to really enjoy all of what the subscription has to offer to you.

UAE Education – List of Computer Training Institute In UAE

Posted by Msdn Blog on September 4th, 2010

Education is necessary to grow. Without education, progress of people would be slow in life. Education also have different levels and well as different ways like based on audio, video or simple one to one and one to many way. It is only, Education that gives way to live life according to your thoughts. People can progress in any way like in technology, sports and other field also. If we think technology, then every person has been aware with computer and its importance in life. MENA (Middle East North Africa) region like Egypt, Oman, UAE, Saudi Arab and moreover countries are now giving importance to education also. Because they already knew and other also found that education would be best way to live life more enjoy full. Now Computer is base for every technology, so it is very important to have knowledge about basic computer. But for advance technology, there is need of also advance courses. There are lots of computer training program, giving several level based offers.

Cybertech Institute: This is UAE based computer training institute. This offer only advance courses based on technology, business program. Courses are offered based on different categories are PRIMAVERA P6 | Project Planner –P3 | SureTrak | Expedition, Microsoft Office Project 2007 | MS EPM 2007, ITES and  BPO based, Pertmaster Risk Analysis and Meridian PROLOG Manager . There are other courses advances PM Competencies, CAD, PRIMAVERA Training, HR organized development and Process Improvement, environmental based also. Anybody can talk for training program consult with http://cybertechme.com

Al Khawarizmi International College: This is other UAE based computer training institute giving courses from beginner to professional persons. It has other education program like associate degrees. This institute offers course in graphics designing, Microsoft, Cisco, CompTIA, Red Hat, Oracle, AutoDesk, Adobe and other general computer courses. It has other category based training program like Project Management Professional, Accounting, ICDL, CIW, language and EC-council also. Anybody can have information related to courses, then he may visit website www.khawarizmi.com.

Areef Computer Institute (ACI): This institute is known for different age group based computer program. Courses are offered by this institute is Microsoft office from basic to advance, certification courses in different language like JAVA, A+ & Network +, MCSE, MCAD, MCTS, CCNA and CCNP, e-commerce, web designing, hardware and Networking, .Net technology, programming and database, computer aided drafting, graphic designing and key board typing. Other categories based programs are planning packages, accounting, secretarial course, language studies. For any help or consultant you may visit website www.areef.co.ae

ComputerBase Institute: This is also one of famous computer training institute offering different categories based courses. Courses are offered like EC-council, compTIA with A+ , Network +, secutiry +, IT project +, Linux +, Microsoft office, Microsft – Technet, Microsoft – MSDN, IBTA – CBP, ICDL, ITSMF, Adobe application training programs, prosoft – CIW and Project Management Professional. Any one can visit website for any further query at www.compubase.ae

There is lots of other UAE computer training institute Or Dubai computer training institute, known famous institutes. Training institutes like Middle East computer training institute

Windows Mobile application development

Posted by Msdn Blog on September 2nd, 2010

Mobile and compact devices become more and more popular in our society. Each of us faces with them every day. Certainly each of us has mobile phone, hand-held computers or other hi-tech devices.

All of these devices have different mobile platforms. There are such known platforms as Windows MobileM, iPhone, BlackBerry, Symbian OS, Android, Maemo, OpenMoko etc. All of them have different history and advantages and failings.

Introduction

Such platforms as Windows Mobile, BlackBerry, iPhone are «closed» enough and limited by either their own devices (BlackBerry, iPhone) or development complexity. Among other problems of above mentioned platforms there is limited API. Even Java platform for mobile devices has some failings such as great number of limitations; very different APIs; device dependent code. Symbian and Windows Mobile platforms are better from this point as far as they support wider range of devices and their APIs give more options.

Common problem here is also that there are a lot of platforms. Talking about OpenSource and Cross-Platform solutions we should say that they are still developing at the moment and are not widespread yet.

In this article we’ll pay our attention to the Windows Mobile platform.

Microsoft Company released its first platform for inbuilt devices at the end of the 90th. In 2002 Windows CE.NET platform appeared. And at that time Pocket PC based on Windows CE 3.0 platform and higher were released. Further development of wireless communication technologies managed to combine telephone and personal computer. Thus Pocket PC 2002 Phone Edition appeared which supported the standards of GSM, GPRS, Bluetooth and wireless HS network access. In the same time another device concept was developing that was much similar to the above mentioned but was closer to the telephone then to personal computer. This device was named SmartPhone 2002. Fundamental difference between Smartphone and Pocket PC is that Pocket PC has touch screen while Smartphone has only control buttons. They also had different application scopes and supported different standards and technologies.

Windows Mobile platform more belongs to smartphones, communicators and small personal devices. Windows CE and Windows Embedded platforms are commonly used in different industrial equipment.

Now we have Windows Mobile 5 and Windows Mobile 6 generations and Windows Mobile 7 will be released soon. Modern devices based on Windows Mobile Pocket PC; have 500-600 MHz processors and 64-128 MB RAM that is not little for such devices.

1. Development Tools

There are a few models of development of applications for Windows Mobile:

Win32 API MFC .NET Compact Framework.

Microsoft Co gives developers all necessary tools for development of applications for PDA, Pocket PC; and Smartphone.

Here are some advices about different code type choosing.

Use Native Code for achieving the burst performance, direct work with hardware, and also for minimization of system resource requirements. Use Managed Code for development of GUI-oriented applications which main requirements are development and market deployment terms. Managed Code is also good for the easy work with web-services. Use Server-Side Code for work with different devices through a single code base, and also if wide stable communication channel with a device is present.

Below are the reviews of present development tools for PDAs, Pocket PCs and Smartphones.

eMbedded Visual C++ 4.0

Microsoft eMbedded Visual C++ 4.0 development environment is meant to create applications for devices with Windows CE .NET 4.2 operating system and also (with package of updates SP3) for PDA and Smartphones on the Windows Mobile 2003 Second Edition platform. The development environment eMbedded Visual C++ 4.0 is good for creation of native code for mobile and inbuilt devices with Windows CE .NET 4.2 OS. It allows developer to perform Just-In-Time Debugging for diagnostics of unhandled exceptions, Attach-to the process for the extended debugging of processes, and also interaction with an emulator.

Visual Studio .NET and SDP functions

SDP (Smart Device Programming) functions of the integrated environment of development Visual Studio .NET 2003 (2005, 2008) allow to create applications, that uses possibilities of Microsoft .NET Compact Framework platform. Thus a developer can create the distributed mobile data-processing systems, workings both in scenarios with connection and without permanent connection. Vast class library of .NET Compact Framework platform makes application development much quicker than with traditional development tools.

Visual Studio .NET lets create applications for the Pocket PC 2002 devices and (with proper SDKs) Pocket PC 2003, 2005 and Smartphone 2003, 2005, applying the same tools as those used for the development of applications for desktop PCs. Library .NET Compact Framework is installed together with Visual Studio .NET. This library is specially developed for devices with the limited resources. Developers can also use new languages C# and Visual Basic .NET for applications for mobile and inbuilt devices. They are good in workings with web-services and ADO.NET technologies.

Control elements of ASP .NET Mobile Controls extend SDP functions and .NET Compact Framework platform. They give opportunities to use possibilities of .NET Compact Framework and Visual Studio .NET for development of mobile web-applications due to the data delivery to various mobile devices by means of ASP.NET technology. This approach allows to create single mobile web-application in the Visual Studio .NET environment, that will automatically perform data rendering for displaying on various devices: mobile phones, smartphones, PDA, Pocket PC. The integrated development environment makes it possible to create mobile web-applications simply by dragging control elements on forms.

ASP.NET System sets no components on a client device. For adaptation of formatting under concrete browsers server logic is used. It generates information in the formats of Wireless Markup Language (WML), HTML, and Compact HTML (cHTML).

Microsoft SQL Server

Microsoft SQL Server Compact Edition (SQL Server CE) is a compact DBMS for rapid development of applications that extend possibilities of work with enterprise data due to the mobile devices using. SQL Server CE is a tool facilitating development of mobile applications due to support of SQL syntax and usage of application and API interface model that is compatible with SQL Server.

SQL Server CE provides the basic set of relational database functions, in particular optimized query handler; support of transactions and heterogeneous types of data – with unpretentious requirements to the system resources. Remote access to the data and replication by confluence provide reliable delivery of information from the SQL Server bases, possibility of autonomous work with by information and subsequent synchronization with the server. SQL Server CE is good for the systems with mobile devices and wireless networks.

SQL Server CE DBMS is developed for integration with .NET Compact Framework by means of Visual Studio .NET. It simplifies development of applications for work with databases on mobile and built devices. New data supplier of SQL Server CE for code management in the Common Language Runtime environment helps to develop distensible applications with possibilities of autonomous work with information in scenarios without permanent connection.

Microsoft .NET SqlClient gives API for work of both .NET Framework and .NET Compact Framework applications. For the common Windows systems SqlClient Microsoft with SQL Server are used, and SqlServerCe for Microsoft SQL Server Compact Edition databases for Compact Framework.

Name space of SqlClient is in both versions. So we can interact:

Using .NET Compact Framework SqlClient to have an access to SQL Server from device on Desktop. Using .NET Compact Framework SqlServerCe to have an access to SQL Server Compact Edition directly on a device.

Work with databases on a device is similar to the work on Desktop. To access to SQLServer on Desktop system SQL uses TCP/IP connection thus in this case it is possible not to have SQL Server Compact Edition installed on a device.

All of the mentioned models are implemented on the desktop systems. So the experience of their application can be carried for development of the programs for Windows Mobile. Using Win32 API we rapidly get compact code, and also can use it for development of drivers and system component.  Using MFC we have extensions of API functions, and also designer for development of interface. And using Compact Framework we have at our disposal well developed interface, automatic garbage collection, support of XML and other options. Also there is even more truncated version — Micro Framework, where there are less SDK functions.

After SDK for MS Visual Studio installation new configurations of assembling appear as well as new functions for assembling under these platforms. Suit also contains Emularor for software development and testing without physical connection between device and computer.

As far as many devices that are based on Windows Mobile have ARM processor it is also possible to compile units using other compilers: AVR32, ARM (RealView), GNUARM, IAR Systems.

2. Building Windows Mobile Applications for Windows Mobile devices using MS Visual Studio .NET

Visual Studio development environment together with Compact Framework enable to develop applications using a vast graphic interface, databases, archiving and encrypting tools,  USB, Serial, Bluetooth, and also wireless network connections and telephony. All of these is provided by SDK as well as libraries and heading files from Platform Builder.

2.1 User Interface

Due to the presence of good designer in VS and SDK we can easily develop GUI for mobile applications just the same as for Desktop applications. The only difference is in sets of  graphic components for Desktop systems and for Windows Mobile. There is also difference between components of Smartphone and Pocket PC versions caused by that Pocket PC has a touch screen and SmartPhone has not. Therefore development of interface for SmartPhone is more complex. One should take it into account when developing software for both platforms.

Here we should also mention that software built for Pocket PC won’t start on the SmartPhone platform while the opposite situation is possible – till the moment when some special Smartphone function is called.

It is naturally that many graphic components as well as majority of functions from full-size Framework were taken away from Windows Mobile SDK to reduce the size of the SDK on the device side. Only the most needful elements were left. But the productivity and volumes of memory are increasing so the number of function included in SDK becomes greater. So the difference between Compact Framework 1.0 and 2.0 is enormous. Version 1.0 was very limited.

In general the development of GUI with ?ompact Framework on ?# is similar to the development of the common Win32 application on C#.

It is also possible to develop a graphic interface using assembling of the 3D rendering-engines. They are such as GAPI (Game API), OPENGL ES (Embedded System), OPENVG (Vector Graphics), and other projects. Certainly it is rather labor intensive process as far as it is very important to write an optimal code because of the relatively low  productivity of mobile devices.

2.2 Communications

To date mobile devices have a wide range of communicational options. They have an access to the wireless high-speed network using 802.11 WiFi Connection standard. They also use IrDa, Bluetooth, and USB host/client functionality. While the usage of Irda is gradually getting less protocols and standards of Bluetooth, WiFi, Edge, GSM, and also USB are used quit often.

Microsoft Company provides such APIs:

ActiveSync API provides functionality for work with services of synchronization, file filters, etc. Bluetooth API provides functionality for wireless access to mobile and peripheral devices. Connection Manager API serves for the automation of connection process, network connection management. Devices are using Connection Manager to establish connection and also to inform about the supposed connection (for example Internet). Object Exchange (OBEX) API provides functionality for work with effective, compact binary protocol just suitable for devices with the limited possibilities. Remote API (RAPI) provides functions for management and remote call of methods on the device side. Such functions are available: access to the register, files, databases and different configurations of device from the Desktop-system. The most important option is Remote Procedure Call when we simply call the method «CeRapiInvoke()» on the Desktop side, transmit the name of DLL on the device side and the name of function in this DLL and then just call this method. Pocket Outlook Object Model API provides functions for work with the objects of Pocket Outlook. It provides interfaces for synchronization and access to the objects: Task, Calendar, Contacts. Telephony API (TAPI) includes: Assisted API Extended API Phone API SIM Manager API Short Messages Service (SMS) API Telephony Service Provider (TSP) API Wireless Application Protocol (WAP)  API.

Also mobile devices have possibility to work with Serial (USB) ports. There are a few COM-ports in many devices. Usually the first 3-5 of them are reserved for IrDa, Bluetooth, SerialPort and others. Other ports are available to for user. Some devices have USB-Host functionality in other words they are USB On-The-Go (OTG) devices which can serve both as USB Client and USB Host. For this purpose device should have necessary Hardware and Software (Device Driver).

Device Driver is a driver which is an intermediate layer between the driver of HOST and  level of applications. Such driver provides «Stream Interface Driver» and must contain such functions as:

XXX_Init XXX_Open XXX_Close XXX_Write XXX_Read XXX_IOControl

Here “XXX” is replaced with «prefix» (for example «COM», «DSK»).

This prefix registers in the registry when a driver registers in the system. More detailed information about Device Driver Interface can be obtained from MSDN.

Also a developer can use such APIs not concerning communicational ones:

Device Configuration API File and Application Management API Game API Home Screen API HTML Control API MIDI API Shell API Speech Recognizer API Vibrate API Voice Recorder Control API. 2.3 P/Invoke and Native Interop

As far as Compact Framework contains basic functions and methods from complete

Framework we have such functionality as:

XML Serialization Cryptography Security Reflection Interop Services et al.

Certainly Platform Invoke calls are accessible. For this purpose – as well as in complete Framework – we use functions and attributes from namespace System.Runtime.InteropServices and DllImport attribute for description of functions which will be called from non-managed code.

However the functionality of these methods is limited. So Marshal class has PtrToStructure, GetComInterfaceForObject, Copy() and Read() functions but, for example, there is no such function as GetDelegateForFunctionPointer() in it. So it is impossible to make Marshaling just with Delegate. The GetFunctionPointerForDelegate function is available only. If we want to transmit a pointer to the function from Managed code we should get its FunctionPointer and only after that transmit it to the unmanaged code for subsequent call of it from there. Also we can not transmit some objects because Compact Framework can not count SizeOf() for some objects. Therefore frequently we have to transmit  data of Blitable types only and arrays of these types (Int, byte, char, but not bool),  and transmit and receive  classes and structures by means of IntPtr. Certainly it is explained by aspiration to increase the performance. It is therefore recommended to use primary types for Marshaling and «GCHandle» class for storing an object in the process memory and to make this memory «visible» for unmanaged code

Certainly the performance of P/Invoke calls from C# application in C++ DLL is almost twice less than the performance of method calls between C++ DLLs. However the performance of devices grows and it becomes possible to use such calls.

2.4 Debugging

MS Visual Studio enables to make debugging of applications under

Windows Mobile just the same as for Desktop applications. We have Emulator, Device Emulator Manager and other to functionality such as Breakpoints, Threads, Watches panel etc.

However to make Debug using Native and Managed code simultaneously is impossible. Therefore it is possible to start either C++ projects or Managed ones. It’s also so for «Attach to process». There is a possibility of attaching to the processes on the device side (or emulator side). ActiveSync is required to provide communication between a device and the system, it is installed with SDK. An emulator also can be connected to the computer by means of ActiveSync. We obtain almost complete emulation of Windows Mobile devices. Here are both SmartPhone and Pocket PC (or Pocket PC Phone Edition) emulators. However only one Windows Mobile device can be connected to the computer at one time moment. Therefore Debug on two devices simultaneously which for example interact in some way is rather difficult. Certainly we talk only about Debug of applications developed by us but not about applications and services of the system. For such debugging we need the complete built of the system created by means of Platform Builder (in the last versions of Platform Builder it’s included in Visual Studio). We can also create our own SDK for Visual Studio and Windows CE platform.

An emulator also enables to emulate connection with the GSM network and GPS support. It makes possible to test and develop large spectrum of applications without having a physical device in hands.

Talking about Debug with IDA we should mention that version 5.1 already has the possibility to perform Debug by means of this interactive disassembler with the use of their plugin which is installed on a device.

With SDK appearance such option as «Deploy» appears in Visual Studio environment. Now there is «Deploy» item in project context menu additionally to “Build”, “Clean”, “Debug”. After you choose this item DLL or EXE file built by current configuration is transmitted to the device. Also new column appears in Configuration Manager where not only «Build» in some configuration option is available but also «Deploy». Deployment of .NET projects transmits not only the unit but also those builds that are depended on it (Dependencies).

3. Deployment and installation

Development of applications for Windows Mobile supposes also their assembling and creation of installation package. For this purpose there is such concept as ?abinet (.cab) file in Windows Mobile. It is a common archive but it is a installation package also (a sort of MSI package). It is assembled by means of Cab Wizard (cabwiz.exe) from MS VisualStudio (or from a command line). This utility creates processor dependent «.cab» file. WinCEApplicationManager transmits and starts CAB on a device, so user can install the application using instructions appearing on device screen. It is also possible to create the project of MSI Installation which includes CAB file by means of Visual Studio. This built package will be started on user computer and then transmit ?AB installation on a device to continue installation process.

There is special Uninstall Manager on the device side. One should attach configuration INI-file to CAB file. This INI file includes settings to manage installation process such as path, shortcut name to create, minimal OS version to install the application and others written in special syntax. It is also possible to include your own DLL into CAB-file to widen installation options. This DLL contains such functions as «Installer_AfterInstall», «Installer_BeforeInstall», «Installer_AfterUnInstall», «Installer_BeforeUnInstall», code in these functions will be executed on the device side in the certain moments of installation or uninstallation process.

When developing CAB installation it is possible to attach files, different resources, built units, add information to the registry. They are designated as «Project Output. That’s why there is no need to reset anything after CAB-file creation: it will collect all included projects and files and assemble in an archive.

4. Security Model for Windows Mobile 5 and Windows Mobile 6

Devices based on Windows Mobile receive, send and analyze potentially important information which should be protected from unsafe applications. To protect device the starting of unknown applications is disabled, the access to some API is restricted and some registry parts changing is forbidden. Units can be marked as Trusted and Untrusted and system uses this information to prevent starting of unauthorized applications and limit their access to the system. Also the access to the system by means of RAPI (Remote API) through ActiveSync can be restricted. Security Certificates Security Rights are used for the executable units (EXE, DLL) and for CAB-files.

Protection Against Threats and Risks

The followings options help to protect devices:

Strict password protection. PIN code protection. Devices corrupt deleted information to prevent access to it (WM 6). Devices corrupt deleted information on memory cards to prevent access to it (WM 6). Storages encryption and Advanced Encryption Standard for SSL (WM 6). Own certificates usage. Detecting a device via Bluetooth can be protected (WM 6 Smartphone). 2 layer system of application starting (One-tier and Two-tier access). No support of macros, therefore viruses can make much harm.

The start of applications is based on Permissions. Windows Mobile devices use such models:

Privileged Normal Blocked

Privileged applications have the widest access. They can access any API, write in the protected areas of registry and have the complete access to the system.

Most applications have Normal model. They do not have access to the trusted API and do not have the complete control of the system.

Application can not be started at all if it has “Blocked” status. It means that it’s not signed with the proper certificate or user forbade the start by the proper warning of the system.

Analogical situation is with Cab-files. The executable units with Normal status can start Privileged DLL but then they will work as Normal. However Privileged executable units can not start the units having Normal status.

Written by Eugene Kordin, Apriorit specialist.

Learn more about development process of Apriorit here.

Ethernet Testing ? For Efficient Network Performance

Posted by Msdn Blog on August 31st, 2010

Ethernet routers and switches are among the fastest-growing devices in routing and switching market segment. Carrier Ethernet is being deployed in many networks to deliver enhanced services to customers. Testing this carrier Ethernet becomes vital for service providers because they need to ensure that the network infrastructure meets industry standards and other functional criteria.

According to MSDN library, a traditional Ethernet testing requires two computers. One of them holds the device to be tested, while the other receives and sends data to the testing device. There will separate lines of communication between the two computers that is used to derive data about the ongoing tests.

The Metro Ethernet Forum has defined conformance requirements that need to be cross checked during performance testing. Each phase of carrier Ethernet has its own testing requirements; and as network size increases it becomes important to test new and legacy devices that are added to the network, for interoperability.

Ethernet testing also encompasses performance testing of network subsystems and finally the entire network. Network testing has to be conducted to derive the break even points that are eventually used to analyze the capacity of the network.

Networks also need to be guarded from external threats and thefts. Security is a major cause of concern because the network carries high volumes of parallel data. Security testing must ensure that there is no leakage between VLAN, MAC-in-MAC and VPN traffic.

Testing tools that are available in the market not only combine multiple protocols, but enable network emulations that simultaneously include Q-in-Q, MAC-in-MAC, and PBB-TE/PBT – at line speeds up to 10 GBPS. These tools enable efficient testing of conformance, interoperability, function, performance, service and scalability of the network.

Because organizations are expanding at a faster rate, it becomes imperative for them to implement robust network infrastructures; and Ethernet testing with efficient tools can definitely aid in deployment of efficient network systems.

Looking For Help With VoIP Online Communications Can Help

Posted by Msdn Blog on August 29th, 2010

Welcome to Online Communications Blog!

Are you looking for complete one stop solution! We can help you. Are you small business and you have got a old phone system! Is it anouloge! Here at Online Communications we can help with Panasonic solutions and Mitel.

Looking for VoIP solution or you just want to know whats the benefits of this solution! We can guide you through from start to finish.

Panasonic phone systems are great for small to medium size companies they offer great value for money and they are very user friendly. Panasonic have launched the new range of IP digital systems, for further information please see our site www.onlinevoicecoms.co.uk

Mitel 5000 IP Telephone Systems is an IP-centric communications server built on an advanced hardware architecture that optimises the latest in IP technology. Combining your voice system and your data network affords you the cost-effective and competitive edge your business needs to succeed. This solution is ideal for clients with up to 250 handsets. You can also network up to sixty sites with this application.

Mitel also offer the 3300cx IP server based solution. 

The Mitel 3300 IP Communications Platform provides enterprises with a highly scalable, feature-rich communications system designed to support businesses from 10-65,000 users. The 3300 ICP provides enterprise IP-PBX capability plus a range of embedded applications including standard unified messaging, auto-attendant, ACD and wireless.

Operating across virtually any LAN/WAN infrastructure, the 3300 ICP provides seamless IP networking allowing for full feature transparency within distributed environments by supporting networking standards such as Q.SIG, DPNSS, and MSDN. The 3300 ICP provides organizations with the opportunity to IP enable their legacy PBX’s, protecting existing investments while delivering all the advantages of a converged infrastructure. Mitel offers in my view one of the best ranges of handsets from basic to the very latest in cutting edge technology.

 

Panasonic IP phone systems Please click here for further information!

Mitel IP phone systems Please click here for further information!

What is Voice over IP!

Its a means of communicate over the Internet for example you have your main office in London and you have another office in Scotland! What you can do set up a VPN Virtual private network between both sites via broadband you would need a router at each end! This bit you must get it right. It all depends on how Manny users you will have lets say 10 users in Scotland they all need to have contact with London. The Mitel solution uses about 22-45k bandwidth per call so if all handsets were being used you would need to the capacity of 250k aprox so I feel 2 meg connection would be fine! Try and get managed network and also 20-1 contention is a must for reliability and stability. The router must have QOS quality of service.

Now the good news the benefits are FREE CALLS between your sites known as virtual private network! Also another benefit is breakout calls this is quite simple but very cool lets say you are in London and you make the call to Scotland the system will think why put it through the BT network and pay for the call you just send the call through your network and then it leaves the system in Scotland to your destination and you will only be charged a local call rate.

Marshalling data in Compact Framework

Posted by Msdn Blog on August 27th, 2010

In many situations when we create applications for different embedded systems or mobile platforms we can’t develop all parts of the product using managed code only.

For example we need several modules written in native language which perform some low level operations or we already have these libraries written on C++. So we have to use more that one programming language in our product and also use data marshaling in it.

Making your interop calls more efficient

Marshaling is the act of taking data from one environment to another. In the context of .NET marshalling refers to transferring data from the app-domain you are in to somewhere else, outside.

You should remember that such Platform Invoke calls are slower than direct native calls and than regular managed calls. The speed depends on types marshaled between managed and native code, but nevertheless you should avoid using Platform Invoke calls if you have a chance to do this. Also it is recommended to use calls with some amount of transferred data than several “small” Platform Invoke calls.

Blittable types

It is recommended to use simple data types (int, byte, boolean, characters and strings). It makes the call more efficient and helps to avoid any convertions and copying. These blittable types have identical representation in both managed and unmanaged memory. But you should remember that in Compact Framework during marshaling boolean type is represented as 1-byte integer value (instead of 4-byte integer value in the full .NET Framework), character type (char) is always represented as 2-bytes Unicode character and String type is always treated as a Unicode array (in full .NET Framework it may be treated as a Unicode or ANSI array, or a BSTR).

Method Inlining

The JIT compiler can inline some methods in order to make the calls more efficient. You can not force a method to be inlined by the compiler, but you can make it NOT to be inlined. In order to avoid inlining you can:

make the method virtual; add branching to the method’s body; define local variables in the method; use 2-bit floating point arguments (or return value).

Disabling method inlining can help to detect a problem during Platform Invoke calls.

Sequential layout

In the Compact Framework all structures and classes always have sequential layout (the managed value type has the same memory layout as the unmanaged structure). This behavior can be specified by setting attribute LayoutKind.Sequential. You don’t need to specify this attribute in Compact Framework, but if you use these pieces of code in both full .NET  Framework and Compact Framework you have to set it to avoid different behavior on two platforms.

The following sample shows how to send some pointers from C# code for storing them in the native module.

Code C#:

[StructLayout(LayoutKind.Sequential)]
public class BasePointers // you can use the struct too
{
public IntPtr pointer1;
public IntPtr pointer2;
}

[DllImport("NativeDLL.dll", CallingConvention = CallingConvention.Winapi)]
// Cdecl
public static extern int TransferStruct(BasePointers pointers);

Code C++:

struct BasePointers
{
unsigned int pointer1;
unsigned int pointer2;
}

extern “C” __declspec(dllexport) int CDECL TransferArray(BasePointers*
pointers);

One Calling Convention

The Calling Convention determines the order in which parameters are passed to the function, and who is responsible for the stack cleaning. The .NET Compact Framework supports only the Winapi value (Cdecl on this platform) of Calling Convention. It defines the calling convention for C and C++ (instead of the  full .NET Framework which supports three different calling conventions). To avoid crashes of your application you should make sure that your calling conventions in both managed and native declarations are same.

If you specify the attribute to preserve signature of functions ([PreserveSig]) then the returned value will contain 32-bit HRESULT value that will give you more data to analyze errors during the native function execution. The Calling Convention can be specified by adding the attribute CallingConvention to the declaration of your function. As it was mentioned the .NET Compact Framework supports only “Winapi” Calling Convention that corresponds to Cdecl:

Code C#:

[UnmanagedFunctionPointer(CallingConvention.Winapi)]
public delegate int ProgressEventHandler(int progressValue);

Code C++:

typedef void (CDECL *ProgressEventHandler)(int progressValue);

Data Alignment

In some situations we need to transfer data between the managed and unmanaged code in the structures. As it’s written above all structures have sequential layout in the Compact Framework, but you should remember about representation of structs in the managed in unmanaged code. The way of packing structures depends on a platform and on a way how the members of structure are aligned. On ARM platform this value for alignment is four (all values in structures are aligned to 4 bytes).

typedef struct OurStruct
{
unsigned char valueChar;
usingned int valueInt;
} ourStruct_;

This structure could be perfectly acceptable in desktop code, but if you use such structure on the Windows Mobile platform then you might receive valueInt at the offset 4. If you use such structures in both desktop and device’s side code you have to use them carefully during marshaling.

During marshaling data you might receive such errors as “Datatype misalignment” (0×80000002) or “Access violation” (0×80000005). It indicates that you are using wrong pointers or try to access to the wrong offset of data. For example, you transfer array of bytes from C# code to the native module and define you functions as:

C# code:

[DllImport("NativeDLL.dll", CallingConvention = CallingConvention.Winapi)]
// Cdecl
public static extern int TransferArray(IntPtr src, int srcSize);

C++ Native Module code:

extern “C” __declspec(dllexport) int CDECL TransferArray(byte* srcArr,
int srcSize);

If you try to use the pointer “srcArr” as the pointer on integer (int*) and then try to use the corresponding value you will receive an error :

int value = *(int*)srcArr; // Datatype misalignment

The simple way to avoid this problem is to change declaration of C++ function and change the pointer on array of bytes to the pointer on array of integer and use it without any problems:

extern “C” __declspec(dllexport) int CDECL TransferArray(int* srcArr,
int srcSize);

Marshal class

You can use methods in the class Marshal to manually convert managed objects and perform conversions between IntPtrs. These methods are PtrToStructure, GetComInterfaceForObject, PtrToStringBSTR, GetFunctionPointerForDelegate and others. It allows you to control marshaling. These methods are also useful for debugging issues with marshaling parameters where the runtime is not able to convert a particular argument.

You cannot pass delegate directly to the native module as parameter of you function because the .NET Compact Framework does not support marshaling of delegates. Instead you should use method Marshal.GetFunctionPointerForDelegate for getting function pointer which you can pass to the native code and call it.

Code:

class MainClass
{
[UnmanagedFunctionPointer(CallingConvention.Winapi)]
public delegate int ProgressEventHandler(int progressValue);


void OnProgressChanged(int progressValue)
{

}

[DllImport("NativeDLL.dll", CallingConvention = CallingConvention.Winapi)]
// Cdecl
public static extern int SetCallbackFunction(IntPtr functionPointer);
}

// Passing function pointer

Delegate d = new ProgressEventHandler(OnProgressChanged);

IntPtr progressChanged = Marshal.GetFunctionPointerForDelegate(d);

int result = SetCallbackFunction(progressChanged);

But you should be aware of Garbage Collector (GC) in such situation. The GC might collect you delegates and your function pointers will become invalid. It may happen when you passed the function pointer to the native code as callback method in order to call it later – GC might think that there are no references to it in the managed code. To avoid this situation you should keep reference to this delegate. For example, you can store it in the classes variable or create some delegates pool, in which you can keep references to the several delegates.

GCHandle

Since we’re passing a pointer to some data we need to allocate memory for that data and make sure that the GC will not remove that memory. One of the possible ways to manage this situation is to use GCHandle.

If you want to pass some class (or array of bytes) to the unmanaged code and you need to pin memory for the proper work with it in the unmanaged code you can write:

class SampleClass
{

}

SampleClass classSample = new SampleClass();

GCHandle classHandle = GCHandle.Alloc(classSample, GCHandleType.Pinned);
IntPtr ptrToClass = classHandle.AddrOfPinnedObject();

int result = PassPtrToUnmanagedCode(ptrToClass); // our function

You can also make an instance of  GCHandle as a member of the class to avoid deleting them by GC. Also you should remember that the structure is value-type. And pinning it to the memory will cause a problem, because structure will be copied and  GCHandle will handle a reference to created “boxed” copy of the object. It will be hard to find such problem in the future.

Conclusion

During marshaling data you may face with the problems described above. Very often you may get “NotSupportedException” and other exceptions. To find a problem you can enable logging of setting the registry keys. One of the logging components is “Interop ”. The log provides information about Platform Invoke calls and marshaling. You can read MSDN for more information about Creating Log Files.

With the .NET Compact Framework 2.0 you can use Platform Invoke calls in managed application, even though there are a few limitations. You should remember all differences and limitations between full .NET Framework and the Compact Framework to avoid problems in your applications.

Resources:

See on the Apriorit site


Copyright © 2010 Msdn Blog. Public records.