Internet Explorer Runtime Error Do you Wish to Debug?

4. February 2008 11:37 by Mrojas in General  //  Tags: ,   //   Comments (0)

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

 

Debugging AJAX

12. December 2007 05:00 by Mrojas in General  //  Tags: , , ,   //   Comments (0)
AJAX applications are great
Their coolness factor is high, and your clients
will be trilled by the new interactivity of your pages
But as a developer when you have a problem with
AJAX it could be hard to track. Because there is
a lot going on behind the scenes
Some of our costumers migrate their ASP applications to
to ASP.NET and it's natural that they want
some AJAX in it.
So I found a GREAT GREAT application for AJAX debugging
It's called fiddler. I cannot describe it all for you so go its site and watch the videos
The tool is just amazing :)
It really can see everything that the browser
receives and sends and more.
A definitive must Fiddler

MSBuild and Visual Studio

9. November 2007 04:50 by Mrojas in General  //  Tags: ,   //   Comments (0)
One of my purposes for this year was to start
using more the MSBuild
Saldly I'm still not as good on it as I expected
This link provided some interetings points MS Build and VS

Case Sensitive SQL Server

26. October 2007 06:29 by Mrojas in General  //  Tags: , , , ,   //   Comments (0)
Recently a friend at work had a problem querying a SQL server that indicated that the column name was wrong.

The only thing wrong was the the case. For example he had COLUMN1 instead of Column1. I had never seen that problem in SQLServer.
I had seed that in Sybase but not in SQLServer. He solved that by changing the database collating sequence to something like this:

alter database database1 collate SQL_Latin1_General_CP1_CI_AI

the CI in the collating indicates Case Insensitive

For more information on SQL Server collations check: http://msdn2.microsoft.com/en-us/library/aa258233(SQL.80).aspx

And you determine your current database collation use a code like this:

USE yourdb>
GO

print 'My database [' + db_name() + '] collation is: ' + cast( DATABASEPROPERTYEX ( db_name(), N'Collation' ) as varchar(128) )

print 'My tempdb database collation is: ' + cast( DATABASEPROPERTYEX ( 'tempdb', N'Collation' ) as varchar(128) )

 

Track Changes in VSS (Visual Source Safe)

24. October 2007 06:18 by Mrojas in General  //  Tags: , , , , ,   //   Comments (0)

MS VSS (Visual SourceSafe) is not really my preferred Source Control application, but
sometimes in your company that is what is available and you need to used it to have
at least some versioning of the code.

But haven't you had a situation where last week everything worked and
now everything is broken. And now is up to you to determine what went
wrong? I have it all the time.
 

VSS have some search tools but I really do not enjoy using them.
The Code Project Site provides an excellent tool called VssReporter

Sample Image - VssReporter.jpg

Do take a look at it, it makes it more easy to track changes. :)

 

Get GUIDs/CLSIDs from Exe, dll, ocx, tlb, etc

23. October 2007 10:08 by Mrojas in General  //  Tags: , ,   //   Comments (0)

A simple way of getting the GUID from an exe, dll, ocx, tlb is using the  TLBINF32.dll

This file is in the system path and it must be registered
(Remember to use regsvr32 if you haven't registered).

            TLI.TLIApplicationClass a = new TLI.TLIApplicationClass();
            try
            {

                TLI.TypeLibInfo inf = a.TypeLibInfoFromFile(@"c:\windows\system32\MSHFLXGD.OCX");
                MessageBox.Show(
                "TypeLibrary Name " +  inf.Name + "\r\n" + //name of (Type Library)
                "Tlb ID " +  inf.GUID + "\r\n" + // GUID for Library
                "LCID "  + inf.LCID + "\r\n" + // Language / Country
                "Major Version "+ inf.MajorVersion + "\r\n" + // Major Version
                "Minor Version "+ inf.MinorVersion); // Minor Version
                for (short i = 1; i < inf.TypeInfoCount; i++)
                {

                    TLI.TypeInfo inf2 = inf.TypeInfos[i];
                    MessageBox.Show("CLSID " + inf2.Name + " - " + inf2.GUID,i + " of " +
inf.TypeInfoCount);

                }
            }
            catch (Exception ee)
            {
                MessageBox.Show("No guid");
            }

 

 

cfgrid or ext grid change column align

23. October 2007 05:42 by Mrojas in General  //  Tags:   //   Comments (0)

If you are using Coldfusion MX 8 cfgrid or the excelent Ext library and
you want to change the aligment for the column then a simple way
to do that is:

Add an style block like

 .x-grid-col-0 {text-align:center}
 .x-grid-col-1 {text-align:left}
 .x-grid-col-2 {text-align:right}

And that's all just remember to change  .x-grid-col-n change the n for the column you want to modify.

Clean Up your Coldfusion application

22. October 2007 09:56 by Mrojas in General  //  Tags: ,   //   Comments (0)
Currently I'm working in some tools to clean
your code, whether it is VB, ASP or Coldfusion.

Mostly simple tools, but for now if you are a
ColdFusion Developer I want to recommend a nice
application called CF Project Cleaner
This tools lends you a hand so you can
get rid of unused files. The tool is not perfect. But it is always handy
to review your code.

MAN for .NET

5. October 2007 03:32 by Mrojas in General  //  Tags: , , , ,   //   Comments (0)
Microsoft recently published the MTPS Content Service

In brief, the MTPS Content Services are a set of
web services for exposing the content in
Microsoft/TechNet Publishing System (MTPS).


And Craig Andera, has develop a swift nice tool
called msdnman that you use from the command line to
get information from the MSDN

Also I recommend you to see this cool video of a Human LCD that Hugo sent me

Comparison Tool for Windows

4. October 2007 11:53 by Mrojas in General  //  Tags:   //   Comments (0)
If you need a good and FREE comparison tool
I recommend WinMerge

Input Line Too Long

3. October 2007 09:35 by Mrojas in General  //  Tags: ,   //   Comments (0)
I was trying to compile a C++ Project in Visual Studio
and this project has a post-build step that executes
some batch statements.

And succendly from one day to the other the project failed
and the only message I had was
The input line is too long


After some googling I found that this error is displayed
when the command line in the command prompt
exceeds the maximum number of characters.
(Something quite obvious jeje)

The bottom line was that recenlty I had installed
some software and my PATH variable became TOO long
I fixed it by creating a new environment variable
called EXTRA_PATH where I put some references to
Some big paths and then changed my PATH variable
replacing all those long variables for %EXTRA_PATH%.

And problem solved!

VB6 References Explorer

1. October 2007 11:22 by Mrojas in General  //  Tags:   //   Comments (0)
I recently found this decent tool called VB6 Reference Explorer.
It even comes with source code.

This tool will show a list of the references for a set of projects in your path.




Here at Artinsoft, some colleagues have develop
some tools that perform even more exhaustive
project analisys like CreateObject dependencies
and others. Maybe I'll post something about those
tools in the future

VB6 Printer Object and PrintForm migration

1. October 2007 10:55 by Mrojas in General  //  Tags: , , ,   //   Comments (0)

If you ever had any problems while migrating from VB6 Printer Object or the PrintForm functionality
we have goods news for you the Microsoft Visual Basic 2005 Power Pack 2.0.
Our version of the Visual Basic Companion already provides and extended migration of the Printer Object,
and we're now updating it to use this new implementation. This Printer Compatibility Library makes it a
breeze to migrate Printer Functionality.

This is the description of the PowerPack:

"The new Line and Shape controls included in this version of the Visual Basic 2005 Power Packs are
a set of three graphical controls that enable you to draw lines, ovals, and rectangles on forms and
containers at design time making it much easier to enhance the look of your user interface.
These new shape controls also provide events such as click and double-click allowing developers
to respond and interact with end users.

The Printer Compatibility Library allows projects that used the Printer and Printers Collection in Visual Basic 6.0
 to be upgraded without having to re-write your printing logic. By simply adding a reference to the library, declaring a
Printer and making a few minor syntax changes, your project will be able to print using the Printers collection
and Printer object as it did in Visual Basic 6.0. This version adds a new Write method to the Printer object which
allows you to print text without a forced carriage return similar to the semicolon syntax used by Print method in Visual Basic 6.0.

The PrintForm component is designed to bring back the ability to easily print a Windows Form.
With this the new PrintForm component you can once again layout the Windows Form exactly as
you want it and allow your users to print the form as a quick report."

You can download the PowerPack from here

NOTE: there's is another link that only includes the Printer Library but MS recommends to download the PowerPack
because minor upgrades and fixes will be done on the PowerPack distribution

 

IE7 Print shrink to fit problem

29. September 2007 17:22 by Mrojas in General  //  Tags: , , ,   //   Comments (0)
IE7 has an interesting bug...
Someone decided to change the printing default
to "Shrink to Fit".This is supposed to be good
because it will make printing of web pages better
but it affects several applications develop for
IE, for example if you are using the Web Access
to your Exchange server, or if you have an application
that prints on a page that is not a letter size page


Well a guy from a forum found an excellent solution.

The only problem is that he refers a hot fix,
but if you have problems with that hotfix, then
do the following:

1. Go to windowsupdate.microsoft.com

2. Make sure you have the following updates:

** Security Update for Internet Explorer 7 for Windows XP (KB938127)
** Cumulative Security Update for Internet Explorer 7 for Windows XP (KB937143)

And then run the following in the command prompt:
reg add "HKLM\SOFTWARE\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_STF_Scale_Min" /v iexplore.exe /t REG_DWORD /d 100 /f

Remove unused references VB6

28. September 2007 11:33 by Mrojas in General  //  Tags: , , , , , , , ,   //   Comments (0)

As part of the VB Companion Development group, my day to day includes
migrating several project from different clients, to develop custom mappings
and custom functionality for their migration needs or to add new features
for the next VB Companion version.

A long part of the initialization in the migration process consists of the load and
analysis of the COM references indicated in the .VBP project file.

Sometimes I have notice that there are several references that are never used.
Removing these references will provide a great save in time because the migration will
not have to incur in any time for TypeLib and TypeInfo extraction.

I look for a tool that let me get rid of the VB6 unused referencences but I found none.
So I decided to create one myself. And I created the VB6 Project References Cleaner Addin

The concept of the tool is simple, someone from a group posted the idea I just implemented.
The addin goes thru all the references and one by one tries to remove it.
And then compiles the project. It the project compiles,then the reference was not neccesary.
If you mark the remove option the tool will remove the references for you.

This tool will NOT SAVE the project file. You decide if you what to save it.

I'm attaching the source code and the dll. To used it just take the VB6References.dll and run:

  regsvr32 VB6References.dll
After that the tool will appear in the Addins menu in VB6 SOURCE CODE and BINARIES

 

 

 

VB6 API calls to .NET

27. September 2007 10:06 by Mrojas in General  //  Tags: , , , ,   //   Comments (0)
Every SERIOUS VB6 application, ended up requiring
that you import some functionality from the windows API or another DLL.
However if you were looking for a .NET equivalent and
google did not take you to the right page,
there is a document (a little old I might say) called
Microsoft Win32 to Microsoft .NET Framework API Map

I remember a couple of other pages that were even more complete,
but right know I can only remember http://pinvoke.net that gives some info about APIs

Coldfusion8 html cfgrid problem

26. September 2007 09:21 by Mrojas in General  //  Tags:   //   Comments (0)
We had a problem with a cfgrid
Coldfusion8 introduces an HTML cfgrid that is AWESOME!!!
It is something you should use.
It is based in the also excellent library Ext But recently we were extruglying with it because when we tried to capture exceptions in the update functions nothing happened and it was terrible because a real life application NEEDS exception handling. My code was something like this:
First file was places.cfc

<cfcomponent output="false">


<cffunction name="getData" access="remote" output="false">
<cfargument name="page">
<cfargument name="pageSize">
<cfargument name="gridsortcolumn">
<cfargument name="gridsortdirection">
<cfquery name="team" datasource="cfdocexamples">
SELECT Emp_ID, FirstName, EMail
FROM Employees
<cfif gridsortcolumn neq "" or gridsortdirection neq "">
order by #gridsortcolumn# #gridsortdirection#
</cfif>
</cfquery>
<cfreturn QueryConvertForGrid(team, page, pageSize)>
</cffunction>

<cffunction name="editData" access="remote" output="false">
<cfargument name="gridaction">
<cfargument name="gridrow">
<cfargument name="gridchanged">

<cfif isStruct(gridrow) and isStruct(gridchanged)>
<cfif gridaction eq "U">
<cfset colname=structkeylist(gridchanged)>
<cfset value=structfind(gridchanged,#colname#)>
<cfquery name="team" datasource="cfdocexamples">
update employees set aaa<cfoutput>#colname#</cfoutput> =
'<cfoutput>#value#</cfoutput>'
where Emp_ID = <cfoutput>#gridrow.Emp_ID#</cfoutput>
</cfquery>
<cfelse>
<cfquery name="team" datasource="cfdocexamples">
delete from employees where emp_id = <cfoutput>#gridrow.Emp_ID#
</cfoutput>
</cfquery>
</cfif>
</cfif>
</cffunction>

</cfcomponent>
 

and the second file was grid2.cfm:

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script type="text/javascript">
function errorhandler(id,message) {
alert("Error while updating\n Error code: "+id+"\n Message: "+message);
}
</script>
</head>

<body>
<cfform name="form01">
<cfgrid format="html" name="grid01" pagesize=11
stripeRows=true stripeRowColor="gray"
bind="cfc:places.getData({cfgridpage},{cfgridpagesize},
{cfgridsortcolumn},{cfgridsortdirection})"
onerror="errorhandler"
delete="yes" selectmode="edit"
onchange="cfc:places.editData({cfgridaction},{cfgridrow},{cfgridchanged})">
<cfgridcolumn name="Emp_ID" display=true header="Employee ID"/>
<cfgridcolumn name="FirstName" display=true header="Name"/>
<cfgridcolumn name="Email" display=true header="Email"/>
</cfgrid>
</cfform>
</body>
</html>

And the problem where was it!!
It was not in any of those files it was in the application.cfm There was an onError handler. So it was commented out and everything work perfect! Well I just like to write down these little details so I don't make this silly things twice. I hope this can be of any help

SVN get files without the .svn directories

24. September 2007 16:19 by Mrojas in General  //  Tags: , ,   //   Comments (0)
I felt so stupid today. Because when for a couple of months,
every now and then, when someone asked me for a copy of the source code
I just made a copy of my src directory and then searched for the .svn* folder
and then I erased them,
until by mistake i found the EXPORT function.
I use SmartSVN and I was creating a new project
and then the light came to me :S
Well if it happens to you just remember there is a
svn export
command. This will get the code from the repository without all the nasty files.

Twips and .NET

20. September 2007 04:46 by Mrojas in General  //  Tags: , , ,   //   Comments (0)

In the VB world previous to .NET a concept you probably had to deal with was TWIPS.

What were Twips? Well if you do not remember those happy VB6 times, let me refresh your memory:

Twips are screen-independent units to ensure that the proportion of screen elements are the same on all display systems.
A twip is defined as being 1/1440 of an inch.


A Pixel is a screen-dependent unit, standing for 'picture element'.
A pixel is a dot that represents the smallest graphical measurement on a screen.

In .NET everything is pixels. So if you migrated something from VB6 using the Upgrade Wizard you might found several expressions like:

VB6.TwipsToPixelsX(ctrl.Left)

or VB6.PixelsToTwipsY(ctrl.Height)

There is an X and a Y version of this function, because the conversion factor is not the same for both axis.

Sadly you can even found some expressions like:

VB6.TwipsToPixelsX(VB6.PixelsToTwipsX(ctrl.Left))

In a strict sense there could be minor differences because of the conversion factors. But in it seams that things like that can be removed because all controls Bound properties like Left, Top, Bottom, Right are in pixels. So why will you convert your pixels units to Twips units to then convert them back to Pixels if they where already in Pixels????

Also you can find something like:

VB6.TwipsToPixelsX(ctrl.Left + ctrl.Width + 30) which should be something like:

ctrl.Left + ctrl.Width  + VB6.TwipsToPixelsX(30)

If you have an application migrated with the Upgrade Wizard you can use some regular expressions to improve those expressions. If the conversion is something like:

VB6.TwipsToPixelsY(VB6.PixelsToTwipsX(ctrl.Left)) then be careful because conversion factor might produce a different value, due to the change of axis.

 

 

jeje Or you can uset the VBCompanion, the extensible version of the Upgrade Wizard!!!

 

Casting in .NET

13. September 2007 04:20 by Mrojas in General  //  Tags: , , ,   //   Comments (0)

.NET has a more strict typing than VB6
So you must check in some circumstances if your object implements an interface or not.

So I had used the as and is operators in C# but I did not know how to do that.
I did I little research and I discovered some things about casting operators for VB.NET

 

Operator Example Observations
CType Dim testNumber As Long = 1000
' The following line of code sets testNewType to 1000.0.
Dim testNewType As Single = CType(testNumber, Single)
 
Throws InvalidCastException or OverflowException

It could be less eficient due to VB.Net helper routines.

This is a Narrowing and Widening operator.

It can be overloaded

Public Structure digit
Private dig As Byte
    Public Sub New(ByVal b As Byte)
        If (b OrElse b > 9) Then Throw New _
            System.ArgumentException("Argument outside range for Byte")
        Me.dig = b
    End Sub
    Public Shared Widening Operator CType(ByVal d As digit) As Byte
        Return d.dig
    End Operator
    Public Shared Narrowing Operator CType(ByVal b As Byte) As digit
        Return New digit(b)
    End Operator
End Structure
 

 

DirectCast Dim f As New System.Windows.Forms.Form
Dim c As System.Windows.Forms.Control
' The following conversion succeeds.
c = DirectCast(f, System.Windows.Forms.Control)
 
Throws InvalidCastException. Is more efficient than CType because it does not depend on the Visual Basic helper runtime functions. It can even detect some errors as invalid casts during compile time
 

However it requires a relationship of inheritance of implementation
For example:

Dim q As Object = 2.37
Dim i As Integer = CType(q, Integer)
' The following conversion fails at run time
Dim j As Integer = DirectCast(q, Integer)
 

The run-time type of q is Double. CType succeeds because Double can be converted to Integer. However, the first DirectCast fails at run time because the run-time type of Double has no inheritance relationship with Integer, even though a conversion exists
 

TryCast     Dim obj As MyType = TryCast(obj, MyType)
    If obj Is Nothing Then
      ' Object could not be cast
 
  Else
     ' Object was casted

   End If
Throws no exceptions.


All this information has been taken from the MSDN site. This is just a quick summary. For more information see:

Type Conversion Functions
Conversion Functions (Visual Basic)

Widening and Narrowing Conversions
Implicit and Explicit Conversions
 

Categories