Thursday, June 9, 2011

ASP.NET 4.0 System.DirectoryServices.DLL

Hi

While trying to use Active Directory from within a web service to authenticate users, I simply could not get the statement

Imports System.DirectoryServices

to work from within my ASMX file.

I would add the reference to the DLL to the project but the Imports statement simply would not work.

I, then, copied the System.DirectoryServices.dll from this path

c:\Program Files\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\

on my laptop - it may be different on your system

and put it into the BIN folder of my project.

And presto, the  Imports statement works!

Wonder why this happens

Let me know if you find an answer

Cheers

Wednesday, April 13, 2011

Titanium, Android, passwordMask does not work

Hi


Titanium Developer SDK version 1.60


I struggled for days with Titanium.UI.createTextField and its passwordMask property.  The passwordMask simply would not work.


Finally, a fluke worked.  I set the autocorrect  : false property and the passwordMask also started working.

The createTextField looks like this now


var tfPassword = Titanium.UI.createTextField({
    color        :'#336699',
    height       :35,
    top          :50,
    left         :100,
    value        : '',
    font         : {fontSize:12,fontFamily:'Helvetica Neue'},
    hintText     :'Enter Password',
    autocorrect  : false,
    passwordMask :true
}) ;


Cheers

Sunday, March 13, 2011

FTP Component For .Net

Hi again

I have been working on converting an old VB6 application using Dart FTP library to manage FTP connections to a server.  Moving this application to VS 2010, VB.Net and .Net Framework 4.0 meant that I had to find a good FTP client all over again as the DART component I had was COM.

A little bit of digging around led me to

http://www.enterprisedt.com/products/edtftpnet/overview.html

Rather good component.  Freeware -  but do read the license agreement to see if you suits you and/or your company.

All my tests so far have been positive.  I have started making the migration of my small application.

Friday, March 11, 2011

Create Screensavers

Hi


As an IT manager, I find using Windows screen-savers a great communication medium.  We can use screen-savers to educate users about security procedures, increase awareness of protecting their identities, educate new users about facilities and policies and even use to announce news and events within our companies.


Creating screen-savers, for me, has always been a chore and a painful one at that.


Till I found


http://www.instantstorm.com/features/


Take a look.  It's free for commercial use, has most features most of us will need.  It is very simple to use


It does require that you know Flash.  Even the most Flash unfriendly amongst us can fire up Flash and make a basic few slides - without animations, maybe to start with - but certainly decent looking!


Cheers

.Net Sockets

Hi


If, like me, you come from the Winsock.dll world of VB6 and are trying to find your way around the new System.Net.Sockets and System.Net.Sockets.TcpClient classes, take a look at 


http://www.gnu.org/projects/dotgnu/pnetlib-doc/System/Net/Sockets/Socket.html


Excellent explanation of how to write both a server and client part of an application.

The sample is in C# but is a cinch to adapt to VB.Net.  Am doing that.  When I finish, will put it up in a follow up post.


The basic steps are these




  1. Create a new class that will hold your socket and the data you want to receive/send - the above link calls it the StateObject class
  2. Create an IP address/port combination object called the IPEndPoint
  3. Create a Socket object - an instance of the System.Net.Socket class 
  4. Call BeginConnect method of the Socket object created in Step 3.  This is an asynchronous call.  This call does NOT wait for the connection to be established.  Execution of your application continues immediately after the statement is executed.  The BeginConnect method requires a "callBack" function.  This is a function that will be called when the BeginConnect method finishes.  The finish of the BeginConnect method could mean either a successful or an unsuccesful connection of the socket.  Within the callback function of the BeginConnect method, you should check the "Connected" property of the object.
  5. Within the callback function of the BeginConnect method, start to receive data using the BeginReceive method.  The BeginReceive method is also asynchronous.  You will need a callback function for this as well.
  6. Similarly, you use the BeginSend method asynchronously to send data to a server.  Using a callback function lets your application know the status of each send cycle.  If your application expects the server to acknowledge the data sent, you start a BeginReceive from within the callback of the BeginSend method and the cycle continues.  
Overall, I think the new Socket class is a simpler, much more logical way of handling socket events.  

Very elegant.

Look up the site above.  Very helpful.

Hope this helps




Titanium Developer And Android SDK On Windows

Hi


OS : Windows XP SP3


I spent a few hours trying to get Titanium Developer working to recognise my installation of the Android SDK.  On selection of Android SDK's default platform directory, C:\Program Files\Android\android-sdk, for example, Titanium would report that it could not find "adb" and required to be pointed to the folder that contained the folders "add-ons", "platforms" and "tools" folders.




On looking a little further inside folders, I found that the Android SDK had changed things around.  In the folder, C:\Program Files\Android\android-sdk\tools, there is a file "adb_has_moved.txt".  This file reads



The adb tool has moved to platform-tools/


If you don't see this directory in your SDK,
launch the SDK and AVD Manager (execute the android tool)
and install "Android SDK Platform-tools"


Please also update your PATH environment variable to
include the platform-tools/ directory, so you can
execute adb from any location.

Titanium expects to find adb.exe in C:\Program Files\Android\android-sdk\tools folder.

This is what my Titanium config screen looks like



Without adb.exe in C:\Program Files\Android\android-sdk\tools, Titanium refuses to work and reports this error




This is what my Android SDK folder structure looks like





SOLUTION



One of the solutions I had found was to add  c:\Program Files\Android\android-sdk\platform-tools to the computer's PATH.  That did not work for me.


I had to take adb.exe from c:\Program Files\Android\android-sdk\platform-tools and copy it to c:\Program Files\Android\android-sdk\tools folder.


Post this, Titanium happily found adb.exe and I could get a zero line Android app running in the emulator in under 10 minutes.


It seems like Titanium tries to execute a fixed path c:\Program Files\Android\android-sdk\tools\adb.exe - instead of using Windows PATH settings.  


That does not sound right or possible, though.


Hope this saves someone some time.




http://nini.sourceforge.net

Hi


At work, we have a lot of small applications that I like to call software glue.  These are applications that basically take data or inputs from one system, massage the data and send it to other systems/applications.


Most of these applications were written in the old VB6 language.  


Last week, I started to migrate one of the applications written in VB6 and then in VB.Net using .Net framework 1.1 to Visual Studio 2010 in VB.Net using .Net Framework 3.5.


One of the first bottlenecks I came up against are application and user settings.  


Application settings, by default are read-only in the new scheme of things.  It seems like we have to go through a few hoops to change application settings from within the executing application.  In addition, there are very few samples online in VB.Net.  Almost everyone seems to be programming in C#.  msdn has not been of great help.


User settings are modifiable by end-users.  I need to store a very simple set of configuration.  But the numbers are dynamic. For example, I want to store a list of attendance readers and their IP addresses.  My INI looks like this


[Main]
NoOfReaders=2
ReaderIP1=xxx.xx.xx.xx
ReaderPort1=xxxx


ReaderIP2=xxx.xxx.xxx.xxx
ReaderPort2=xxxx


The application is not restricted to any number of readers.  It runs as a service and reads configuration files on service startup.  Any time I want to add a reader or remove one, I remove the appropriate entry from the INI and reduce the NoOfReaders counter.  I know there're are other ways, but this suits me best.


Anyway, all this was very complicated for our new application to store as application/user . settings. The old applications used the simpler :-) INI format.


Re-writing all the INI management modules from the old software seemed like a lot of work that would take my time away from updating  the core functionality of the software. 

After a little digging around, I found this excellent library http://nini.sourceforge.net



Look it up.  Solves all troubles with application settings, allows me to easily migrate the INI files from the older application to the new ones.


Once my new application is running fine, I can move over "legacy" INI file to the new app.config way of doing things.

Look up nini.  Looks excellent.



Best

Thursday, March 10, 2011

Hi again

Hi


I am back with my blog.  Have been working on multiple projects these past few months.  


In the past week, I have finally managed to get a simple application running on an Android emulator using Titanium Developer on Windows.


Will post my experiences and some code so that it can help someone.


See you around