ArtinSoft's Blogs

Software Migration Experts
Welcome to ArtinSoft's Blogs Sign in | Join | Help
in Search

Mauricio Rojas Blog

February 2008 - Posts

  • ActiveX exceptions when running in .NET

    During migration to C# or .NET it is easier to keep the same ActiveX.
    The VBCompanion does a great work in migrating the ActiveX control using the .NET ActiveX wrappings and fixing all method calls. 
    Sadly sometimes those ActiveX do not work properly in .NET.

    Well we have good news.
    Recently my friend Jose David (who we keep bothering because he is now 
    a Project Manager and now he only programs in MS Excel and MS Project, I added the MS by his request :P) fixed a curious bug
    we had with an aplication we migrated from VB6 to C#.

    The thing is that the aplication had an ActiveX control with a strange runtime behaviour.
    We migrated the application keeping the ActiveX control and in most ocasions it worked ok.

    But randomly it started throwing exceptions.

    During the testing he discovered that if he repeated the steps slowly the bug did not reproduced.

    So his idea was that it was due a garbage collection issue. And SURPRINSINLY he was right :P

    He added this:

    System.GC.Collect();

    System.GC.WaitForPendingFinalizers();

     And the application started to work.

    It seems like some of the COM objects needed a little more time for releasing all references :)

     

  • IsMissing migration in VB.NET or C#

    Recently  we added some support for migrating the IsMissing function to VB.NEt or C#

    The thing is. In VB6 the IsMissing Function is TRUE only if you have something like:

    Public Sub Foo(Optional str)

     

    Where you dont specify the variable type, or if you have

     

    Public Sub Foo(Optional str as Variant)

     

    And is IsMissing is FALSE for any other case. Including Optional variables whose definition type is not Variant.

     

    So let's see some examples to illustrate the idea:

     Example 1:

    Public Sub Foo(str, a As Integer, b As Integer, Optional c As Integer)
        MsgBox (str & "Foo Is missing a " & IsMissing(a))
        MsgBox (str & "Foo Is missing b " & IsMissing(b))
        MsgBox (str & "Foo Is missing c " & IsMissing(c))
    End Sub

     

    It occurs that IsMissing is really FALSE in all cases. So it is equivalent to:

     

    Public Sub Foo(str, a As Integer, b As Integer, Optional c As Integer)
        MsgBox (str & "Foo Is missing a " & false)
        MsgBox (str & "Foo Is missing b " & false)
        MsgBox (str & "Foo Is missing c " & false)
    End Sub

     

     

    Example 2:

     

    Public Sub Goo(str, a As Integer, b As Integer, Optional c As Object, Optional d As Byte, Optional e)
        MsgBox (str & "Goo Is missing a" & IsMissing(a))
        MsgBox (str & "Goo Is missing b" & IsMissing(b))
        MsgBox (str & "Goo Is missing c" & IsMissing(c))
        MsgBox (str & "Goo Is missing d" & IsMissing(d))
        MsgBox (str & "Goo Is missing e" & IsMissing(e))
    End Sub

     

    All cases EXCEPT "e" are equivalent to FALSE

     

    Public Sub Goo(str, a As Integer, b As Integer, Optional c As Object, Optional d As Byte, Optional e)
        MsgBox (str & "Goo Is missing a" & false)
        MsgBox (str & "Goo Is missing b" & false)
        MsgBox (str & "Goo Is missing c" & false)
        MsgBox (str & "Goo Is missing d" & false)
        MsgBox (str & "Goo Is missing e" & IsMissing(e))
    End Sub

     

    So if you are migrating your VB6 Code to C# put attention to these little details it can save you a lot of time.And remember that this is just one feature of VBCompanion tool ;)

     

  • Internet Explorer Runtime Error Do you Wish to Debug?

    Hi, for several months I lived with an extremely unconfortable bug.
    On some pages IE will display an alert dialog indicating 

    Error
    A Runtime Error has occurred.
    Do you wish to Debug?
    Line: blablabla
    Error: blablalba

     Well finally I looked in google and found this: http://support.microsoft.com/kb/822521

    So if anybody had to live with this bug like me, I hope this helps him

    Here is a valuable comment I received. So I'm adding it so it will help somebody else.

    I was plagued by the "Runtime error - do you wish to debug?" problem for months and finally resolved it last night, after testing everything else in the MS knowledgeBase to no avail (http://support.microsoft.com/kb/308260/ln/).The problem disappeared instantly after a tip-off elsewhere to install & run SpyBot. (Looks like my SpywareBlaster 4.1 failed me there.) - So it wasn't my IE 7 settings (Disable script debugging), operating system (XP Pro SP3), firewall (Comodo Pro), antivirus (Avast!) or scripting engine (WindowsScript 5.7) - just Spyware

This Blog

Syndication

Powered by Community Server (Non-Commercial Edition), by Telligent Systems