Fix errors for atlbase.h and atlthunk.lib not found in Visual C++ 2010 express

29. June 2011 03:53 by Mrojas in General  //  Tags: , , , , ,   //   Comments (0)

If for some reason you have to use VC++ Express and you have projects that use ATL,
you will get annoying error messages like:

LINK : fatal error LNK1104: cannot open file 'atlthunk.lib'

Just follow the steps in this post and you well be ready to go:

Hyper-V: Failed to create partition: Insufficient system resources exist to complete the requested service. (0x800705AA)

21. June 2011 09:15 by Mrojas in General  //  Tags: , , , , ,   //   Comments (0)

Well I was trying to create a VM Role for Azure and I got this error from my Hyper-V machine.

After some tests I hit my head and got to a clear conclusion: Silly me how could have I missed it.
The problem was I set up the VM with more memory that the available in Hyper-V, so
I changed this setting and my VM just worked!!

If I was not able to transfer any sense of sarcasm, I think that this is really hard to understand error message. Confused smile

Program database manager mismatch

21. June 2011 08:58 by Mrojas in General  //  Tags: , , , , , , ,   //   Comments (0)

I was playing around with dumpbin trying to figure out some problems with a 32-bit dll and in order to make
dumpbin run from the command line I just copied the mspdb100.dll file to
C:\Program Files\Microsoft Visual Studio 10.0\VC\bin>

Something simple right! No harm can be gotten from something like that? WRONG!!!

After that some of my C++ project stop compiling with the annoying message: Program database manager mismatch!!.

Luckily I remembered copying that file, so I just gave it a try, and guest what? Everything works fine now.

Well I’m posting it just a reminder that for VS C++ you must put attention on all the details Smile

VB6 Windows Service

2. June 2011 04:30 by Mrojas in General  //  Tags: , , , , , , , ,   //   Comments (0)

How do you write a Windows Service in VB6?

Althought this is not a recommend practice due to the stability issues and VB6 support, if for
any reason you need to do this I provide a guide of how to do that in VB6 and how do the same thing
in VB.NET and C#.

Using the NTSVC.ocx

This is an OCX implement by Mauricio Ordonez some time ago.
It is very simple to use. You just drop it on a form and add some code to your VB6.

Example: VB6 Form with the NTSVC.ocx control

Private Sub Form_Load()
Me.Visible = False
    Dim strDisplayName As String

On Error GoTo Err_Load

    strDisplayName = NTService1.DisplayName
    If Command = "-install" Then
        ' Enable interaction with desktop.
        NTService1.Interactive = True
        If NTService1.Install Then
MsgBox strDisplayName & " installed successfully"
            MsgBox strDisplayName & " failed to install"
        End If
    ElseIf Command = "-uninstall" Then
        If NTService1.Uninstall Then
            MsgBox strDisplayName & " uninstalled successfully"
            MsgBox strDisplayName & " failed to uninstall"
        End If
    ElseIf Command = "-debug" Then
        NTService1.Debug = True
    ElseIf Command <> "" Then
        MsgBox "Invalid command option"
    End If
    ' Connect service to Win32 services controller.
    ' Error starting service
End Sub

Private Sub Timer1_Timer()
MsgBox "hola"
End Sub


NOTE: Remember that VB6 is not a supported platform and that even if it is true
that you can still run VB6 code in Windows Vista and Windows 7 MS does not support this
platform anymore.

How can I convert my VB6 service to .NET?

To create a Windows Service in VB.NET follow this steps.

1. First you need to create a Windows Service Project:

a. Open Visual Studio 2010

b. Go to the File\New\Project….

c. Select the Windows Service Template

d. And you just put your code in the OnStart method:

Public Class Service1

    Protected Overrides Sub OnStart(ByVal args() As String)
        ' Add code here to start your service. This method should set things
        ' in motion so your service can do its work.
    End Sub

    Protected Overrides Sub OnStop()
        ' Add code here to perform any tear-down necessary to stop your service.
    End Sub

    Private Sub ExecuteWindowsServiceCode()
        'TODO Add Some Code
    End Sub

End Class

e. Another typical thing to do in Windows Service is to add a Timer Control, you you can have
your windows service performs some actions every number of seconds. To do that, drag a
Timer Control on your Service component, execute the Start method of the timer control on the OnStart method and
handle the Tick event:




Public Class Service1

    Protected Overrides Sub OnStart(ByVal args() As String)
        ' Add code here to start your service. This method should set things
        ' in motion so your service can do its work.
    End Sub

    Protected Overrides Sub OnStop()
        ' Add code here to perform any tear-down necessary to stop your service.
    End Sub

    Private Sub ExecuteWindowsServiceCode()
        'TODO Add Some Code
    End Sub

    Private Sub Timer1_Tick(sender As System.Object, e As System.EventArgs) Handles Timer1.Tick
        MsgBox("Viva la vida Loca!")
    End Sub
End Class

If you need to recover some of your code from your VB6 project, download our Visual Basic Conversion Tool VBUC tool.


How do I Install my Windows Service?

In general you just need to use the command line utility installutil.exe for more details see this other post.

From VB6 to WP7: App Config for WP7 Applications

27. May 2011 04:33 by Mrojas in General  //  Tags:   //   Comments (0)


When you start moving applications to the Silverlight and the Cloud
it wont belong for you to start wondering if you can move your applications
to be able to work on mobile devices, and it is a natural thing to wonder.

One of the best features of Artinsoft conversion tools from VB6 and other languages
to .NET is that we generate very clean code, it is not a runtime as much as possible
it is plain vanilla .NET code. And that allows us to easily move to other .NET platforms
using our evolution framework.

Moving a VB6 or Winforms applications will require some libraries not currently present in WP7,
one of those libraries are the one to read from a Config file. If you are in need of this functionaly
Alex Yakhnin has provided a good port of the Mobility Configuration block that will allow you to do something as simple as:

/ Get section
ApplicationSettingsSection section = (ApplicationSettingsSection)ConfigurationManager.GetSection("ApplicationSettings");
// Display values
this.textBlock1.Text = section.AppSettings["localServer"].Value;
this.textBlock2.Text = section.AppSettings["remoteServer"].Value;

The Mango is close!!!

24. May 2011 03:04 by Mrojas in General  //  Tags: , , , , , ,   //   Comments (0)

Jejeje. Well if you are a phone developer, either an iOS guy who is thinking on offering
his/her apps in the MS Marketplace or just someone with a great interest in Windows Phone
then you should know what mango is.

Mango is a new update for the Windows Phone, and it will mean a lot for developers,
because if you already liked WP7 you will love MANGO.




Mango means HTML5 yes!
Mango means Multitasking!
Mango means Hands-free messaging, did you ever
wanted to send SMS without using your fingers, now you can!

I don’t think is mentioned in this video but Mango is also SQLCE a great alternative
for Android and iPhone developers who were using sqllite.

Convert iOS to Windows Phone 7; SQLite

23. May 2011 05:00 by Mrojas in General  //  Tags: , , , , , , , ,   //   Comments (0)

In iOS SQLite is part of the Core Services and you can easily integrate it in your applications.
Even in Android you have access to this platform.

If you don’t know what SQ Lite this is a quote from

“SQLite is a software library that implements a self-contained, serverless, zero-configuration,transactional SQL database engine. SQLite is the most widely deployed SQL database engine in the world. The source code for SQLite is in the public domain.“

So what is your equivalent in WP7. Well if you want to wait the Mango Release of Windows Phone 7
will include Sql Server Compact Edition, so that will provide a fairly good and supported platform, but
in the meantime I recommend that you check

Interop Structures to UnManaged Dlls

For VB6 applications it is common to rely on OS or Kernel API Calls. Some of those APIs might
need you to send data back and for the native API.

Marshalling in .NET can be complicated and bothersome. I have published several posts about
interop. But it usually depends on adding several marshalling attributes and even tricks specially for
fixed strings.

So I decided to provide a more a simpler approach for conversion. In this approach you just need to things:

1. Your VB6 types or structs will be mapped to .NET classes
2. All VB6 type or struct fields will be mapped to public fields
3. An attribute must be used on those fields to indicate the field length, for arrays or strings.
4. Extension methods .AsString() .SetFromString and .GetClassLength will handle all the complexities of setting the struct fields.

Let’s see an example:

Type EmployeeRecord
    FirstName As String * 5
    LastName As String * 5
End Type

That vb6 type will be mapped in .NET following this approach to:

    public class EmployeeRecord 
        public string FirstName = "Mau";
        public string LastName = "Rojas";


You can then simple use that class in .NET

var emp = new EmployeeRecord {FirstName="Mauricio",LastName="Rojas"} ;
var str = emp.AsString();
//This str value will be "MauriRojas" the helper extension methods
// .AsString and .SetFromString will handle setting the internal class fields

All that is very good but how is this used in Marshalling?? Well very simple. Let’s say you have a Dll called foo.dll
with a function foo that receives an EmployeeRecord:

        public static extern int foo(IntPtr Struct);

Then if you want to call that function you will do something like:

            var emp = new EmployeeRecord { FirstName="Ann",LastName="Smith"};
            string str = emp.AsString();
            var ptr = IntPtr.Zero;
            ptr = Marshal.StringToBSTR(str);
            ptr = Marshal.StringToHGlobalAnsi(str);
            ptr = Marshal.StringToHGlobalAuto(str);
            ptr = Marshal.StringToHGlobalUni(str);

            //And call the native function

If the function modifies the structure and you want to reflect those changes then you will do something like:

str = Marshal.PtrToStringAnsi(ptr,typeof(EmployeeRecord).GetClassLength())

This solution can also be applied for more complex structures. For example:

    public class EmployeeRecord 
        public string FirstName = "Mau";
        public string LastName = "Rojas";


    public class Record1
        public int field1;
        public string field2 = "";
        public EmployeeRecord rec = new EmployeeRecord();

    public class GeneralInfo
        public int field1;
        public String[] countrycodes = { "cr","es","mx","pa","ni"};
        public EmployeeRecord[] employees;

If you want to try it out this is the link to the CODE

Windows Azure Connect Endpoint Software versions supported

17. May 2011 08:55 by Mrojas in General  //  Tags: , , , , , , , , , , , , ,   //   Comments (0)

A common doubt when using you want to use Azure Connect is which platforms does it support.
Remember that in order to establish a VPN between your On-Premises computer and a Web/Worker Role
you need to install a client pieces of software.
But which are the supported platforms.
Normally what you can do is just download it and then if you get something like
”Not a valid Win32 application” it means that it is not supported.

From the MSDN site ( in the Prerequisites section ) it is stated that:

Windows Azure Connect supported platforms:

Windows 2003 and Windows XP are not supported.

It is supported in Windows Vista, Windows 7, Windows 2008 and Windows 2008 R2

Getting the IP Address of the client in a Windows Azure Role

Are que getting null or empty with some Request.ServerVariables

When you convert your ASP application to run on Windows Azure it is a good
to put attention to the methods that are used to get the user IP Address.
Normally the recommendation will be to use Request.UserHostAddress however
our friend Alex has found that this property can return null or empty.

After some research Alex found that there are several scenarios under which
you must check both the REMOTE_ADDR and the HTTP_X_FORWARD_FOR server variables:

More info: and

A possible code snipped that can provide a value for the client address can be:

public static string ReturnIP()
            var request = System.Web.HttpContext.Current.Request;
            var ServerVariables_HTTP_X_FORWARDED_FOR = (String)request.ServerVariables["HTTP_X_FORWARDED_FOR"];
            var ServerVariables_REMOTE_ADDR = (String)request.ServerVariables["REMOTE_ADDR"];
            string ip = "";
            if (!string.IsNullOrEmpty(ServerVariables_HTTP_X_FORWARDED_FOR) && 
                ServerVariables_HTTP_X_FORWARDED_FOR = ServerVariables_HTTP_X_FORWARDED_FOR.Trim();
                string[] ipRange = ServerVariables_HTTP_X_FORWARDED_FOR.Split(',');
                ip = ipRange[0];
            else if (!string.IsNullOrEmpty(ServerVariables_REMOTE_ADDR))
                ServerVariables_REMOTE_ADDR = ServerVariables_REMOTE_ADDR.Trim();
                ip = ServerVariables_REMOTE_ADDR;
            return ip;

In the previous code the HTTP_X_FORWARDED_FOR value is examined first and if it is not null or unknown then ip address of the client
is gotten from there.