1

I have some vb.net code which should print out labels using Teklynx LabelView software (which I've had working before.)

Problem is, it runs fine on Dev machine, but when I run it on the end user's PC, I don't get any error messages until it completely dies with the "Send error report to Microsoft" message.

How can I troubleshoot this???

Relevant code:

Shared Function PrintLabels(ByVal itemDescription As String, ByVal starting As String, ByVal ending As String, ByVal qty As Integer) As Boolean
        'Create "Document" (Label) object

        'Close all open lv.exe processes
        Dim pProcess() As Process = System.Diagnostics.Process.GetProcessesByName("lv")

        For Each p As Process In pProcess
            p.Kill()
        Next

        Dim Lbl As Object
        Lbl = CreateObject("Lblvw.Document")

        Lbl.Open(labelFileName)

        Dim barcodeVal As String
        Dim labelText As String

        Try

            Dim infoArray As String()
            infoArray = itemDescription.Split(New Char() {","c})

            labelText = infoArray(1).ToString().Trim()
            barcodeVal = infoArray(2).Trim() & starting & ending

            'Load label in ReadOnly mode
            Lbl.Open(labelFileName, True)

            'Get field information
            Dim Flds As Object

            Flds = Lbl.LabelFields

            Flds.Item("TEXT1").Value = labelText
            Flds.Item("BARCODE1").Value = barcodeVal

            Lbl.PrintLabel(qty)

            Lbl = Nothing
            barcodeVal = Nothing
            labelText = Nothing

            Return True

        Catch ex As Exception

            If printStatements Then
                MsgBox("Error Message: " & ex.Message.ToString())
            End If

            Using writer As New StreamWriter(errorLog, True)
                writer.AutoFlush = True
                writer.WriteLine()
                writer.WriteLine(DateTime.Now.ToString() & ": " & ex.Message)
            End Using

            Lbl = Nothing
            barcodeVal = Nothing
            labelText = Nothing
            Return False

        End Try
    End Function
MAW74656
  • 3,449
  • 21
  • 71
  • 118
  • what kind of effort you did for deployment ? – Felice Pollano Mar 28 '11 at 14:43
  • Copied the \bin\Release\ folder and ran the exe. – MAW74656 Mar 28 '11 at 15:00
  • ok, it is possibly not enought since you are using 3rdparty components that are probably installed on the GAC. See reply down + ensure you deployed the redistributables of your controls (Teklinx ) – Felice Pollano Mar 28 '11 at 15:02
  • Looks like its a different version of the Teklynx LabelView software. This code worked previously on v7 Gold edition, but at some point it was upgraded to v8.5 Pro edition, which does not support OLE Automation. Looking at upgrading to Gold to confirm that this is indeed the problem. – MAW74656 Mar 28 '11 at 18:21

5 Answers5

2

Check what version of .NET you are building to and what version of .NET the client has on their machine.

Something you are using might not be back compatible with the user if the user has a lesser version of .NET.

Jack
  • 8,851
  • 3
  • 21
  • 26
  • How do I check the target platform? Option is in different place within VS then with C# (which I'm used to). – MAW74656 Mar 28 '11 at 15:10
  • On the toolbar...project>(your project) properties>compile>advanced compile options>target framework(last option) – Jack Mar 28 '11 at 15:14
  • Changed target to client-only subset .net version 2.0. No effect. – MAW74656 Mar 28 '11 at 15:33
  • check your references and make sure they are still compatible – Jack Mar 28 '11 at 15:37
  • I have a feeling the Teklynx LabelView software you are using might not be compatible with the clients .NET framework. Go back to your project properties and look under references and see if anything is complaining. Might want to check what your clients .NET version is as well because if it is the same as the version you are deploying to then @Felice Pollano is probably right about the third party software being the issue. – Jack Mar 28 '11 at 15:48
  • None of the references are flagged. @Felice Pallano's point doesn't feel right, as before I never deployed anything special, Teklynx Labelview is a software installed for the end user, and this code is supposed to tap into that. – MAW74656 Mar 28 '11 at 17:46
1

Don't guess at this. Implement the AppDomain.CurrentDomain.UnhandledException event and log or display the value of e.ExceptionObject.ToString(). It tells you exactly what went wrong, with a stack trace to show you how to wrongness came to be.

Hans Passant
  • 922,412
  • 146
  • 1,693
  • 2,536
  • Sounds great! How do I implement this event? Can you explain or point me to an article? I've never used this before. – MAW74656 Mar 28 '11 at 15:43
  • Use AddHandler in, say, your main form's Load event or Application.Startup – Hans Passant Mar 28 '11 at 15:49
  • How did you look this up in the MSDN Library or your programming book in only 5 minutes? Try not to be helpless, you can't be a real programmer if you can't figure out how to do this by yourself. This was the first hit when I used the Search box: http://stackoverflow.com/questions/58280/unhandledexception-handler-in-a-net-windows-service/58419#58419 – Hans Passant Mar 28 '11 at 16:07
  • 1
    @MAW74656 & for those others that stumble across this -- you might, in following Hans' advice, check out the Jeff Atwood's [recent blog about this](http://www.codinghorror.com/blog/2011/07/nobodys-going-to-help-you-and-thats-awesome.html) – M. Tibbits Aug 31 '11 at 01:49
0

In addition to the .NET version as @Jack mentions, be aware of 32-bit vs 64-bit. If the label software is built for 32-bit only, your program won't run if you're targeting "Any CPU" in Visual Studio and you're running it on a 64-bit machine. In this case, the CLR will compile to 64-bit and then won't be able to link to the 32-bit library. (But without knowing the software, I don't know if this is affecting you.)

Gnat
  • 2,861
  • 1
  • 21
  • 30
0

Sounds like you have to properly install the Teklynx LabelView component. If it's a COM component (you did tag this question with "OLE" and you are using CreateObject), it'll require a registry entry. Copying and pasting the bin\ won't work. What does the Teklynx documentation say about redistributing the component? I've never had to register a COM component in .NET ... only back in VB6 which the Setup & Deployment Wizard handled. For testing, find a clean client PC and use regsrv32.exe to manually register the Teklynx .DLL(s).

HardCode
  • 6,497
  • 4
  • 31
  • 54
0

Looks like its a different version of the Teklynx LabelView software. This code worked previously on v7 Gold edition, but at some point it was upgraded to v8.5 Pro edition, which does not support OLE Automation. Looking at upgrading to Gold to confirm that this is indeed the problem.

UPDATE: Yes, this was the problem. Thanks all!

MAW74656
  • 3,449
  • 21
  • 71
  • 118