-
Oct 4th, 2020, 01:32 PM
#1
Thread Starter
Member
[RESOLVED] Visual studio 2008 OPoS development issues
Hi everyone,
I have a slight problem with some software I am working on when i run the application it will get to this line in the GlobalSettings.vb
Code:
Public WithEvents OPoSScanner As New OposScanner_CCO.OPOSScanner
it will jump over this and everything else and then show me a blank form (as nothing else is being
loaded).
If I comment it out the application loads and runs fine, But the strange thing is I have 4 other applications
that is using the same line of code and it works perfectly fine on them.
I have tried the following
> Uninstall / reinstall the OPoS files
> Repair the install of my Visual basic 2008 install
I am not sure how to sort this as with out the OPoSScanner working I can not use the barcode reader at all
for scanning.
Some advice is most welcomed as I am not sure what to do. (if I need to delete a file or something Please can
some one explain what I need to do)
Why would one application work fine when another application that uses the same code base not work?
(is it just me that thinks this is strange or do other people think it is strange)
-
Oct 4th, 2020, 11:57 PM
#2
Re: Visual studio 2008 OPoS development issues
Does the Output window indicate any exceptions are being thrown in compiled code?
-
Oct 5th, 2020, 02:17 PM
#3
Thread Starter
Member
Re: Visual studio 2008 OPoS development issues
The only output I get is from the build output window and this is saying build 1 successful
If I remove the ' from the line the app starts up but things like
Code:
AppVersion = Assembly.GetExecutingAssembly.GetName.Version.ToString
BuildDate = RetrieveLinkerTimestamp(Process.GetCurrentProcess().MainModule.FileName)
BuildDate = FormatDateTime(BuildDate, DateFormat.LongDate)
Are not run I get just the form with no data set on it
if you can tell me where to look to get you more information then will be happy to do this for you
-
Oct 5th, 2020, 02:54 PM
#4
Re: Visual studio 2008 OPoS development issues
This really sounds like the old Form Load bug, but I don't remember enough about that to know whether or not it is even possible. You DID mention VS2008, which is far enough back that the bug was around, and it manifest in this way.
What was happening with that bug was that an exception would be thrown in the Load event of a form, the exception would quietly vanish, and nothing beyond that line in the Load event would happen, because execution of the Load event ended with the line that threw the exception.
The behavior sounds right, but your description doesn't quite match because you never suggested that this was happening as a result of any Load event. If that IS the case, then there's a solution, but if that isn't the case, then here's what I'd be trying: Don't be creating the object on that line. Declare it on the line, but create the object elsewhere and assign it to the variable then. This will do two things. First, it will allow you to further isolate the problem, because you'll have a chunk of code that you can put breakpoints on, wrap in an exception handler, and so forth. Second, it will move the problem to both a more tractable location and simply later.
Moving the creation and assignment later will let you prove that it really IS that line that is causing the problem, because the problem will still occur, it will just occur later, and you'll be able to prove that.
My usual boring signature: Nothing
-
Oct 5th, 2020, 03:39 PM
#5
Thread Starter
Member
Re: Visual studio 2008 OPoS development issues
See what I can not work out is
Code:
Public WithEvents PoSPrinter As New OposPOSPrinter_CCO.OPOSPOSPrinter
Public WithEvents CashDrawer As New OposCashDrawer_CCO.OPOSCashDrawer
Public WithEvents CustomerDisplay As New OposLineDisplay_CCO.OPOSLineDisplay
Public WithEvents MSRSwipe As New OposMSR_CCO.OPOSMSR
Public WithEvents OPoSScale As New OposScale_CCO.OPOSScale
Public OPoSSpeaker As New OposToneIndicator_CCO.OPOSToneIndicator
all works loads as they should do but when it get to to this line
Code:
Public WithEvents OPoSScanner As New OposScanner_CCO.OPOSScanner
this is when it freaks out and misses any other code (stops etc)
I have tried to call the above code from a Public sub but vb.net will not let me call the code (and from what I have read on the
OPoS website the above codes have to be called at the start of the program.
This code is stored in my GlobalSettings.vb file and if i put a break point on it I can step through the code (as this is ran before any forms start)
This is the code that is behind my Startup Form
Code:
Imports System
Imports System.Windows.Forms
Imports System.Reflection
Imports System.IO
Imports System.Runtime.InteropServices
Imports System.Net.Sockets
Public Class frmSplash
Dim ScreenMode As String = ""
Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Integer, ByVal dwExtraInfo As Integer)
Private Const VK_CAPITAL As Integer = &H14
Private Const KEYEVENTF_EXTENDEDKEY As Integer = &H1
Private Const KEYEVENTF_KEYUP As Integer = &H2
Protected Overrides Sub WndProc(ByRef m As Message)
If (m.Msg = &H112) AndAlso (m.WParam.ToInt32() = &HF010) Then Return
If (m.Msg = &HA1) AndAlso (m.WParam.ToInt32() = &H2) Then Return
MyBase.WndProc(m)
End Sub
Private Sub frmSplash_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
With Me
.TopMost = True
.Location = New Point(0, 0)
End With
FileName = Application.StartupPath & "\settings.ini"
'Tender Control Files
PoSTenderValues = Application.StartupPath & "\tender.dat"
CardSummaryFileName = Application.StartupPath & "\cardsummary.dat"
WestonUnionFileName = Application.StartupPath & "\westonunion.dat"
SafeDropFileName = Application.StartupPath & "\safedropvalues.dat"
RecallSaleFileName = Application.StartupPath & "\recall.dat"
TransNumberFileName = Application.StartupPath & "\transnumber.dat"
CurrentSaleFileName = Application.StartupPath & "\currentsale.dat"
For Each s As String In My.Application.CommandLineArgs
Select Case s.ToString
Case "/Fullscreen", "/FULLSCREEN", "/FullScreen"
ScreenMode = "Fullscreen"
Me.WindowState = FormWindowState.Maximized
Case "/Nomouse", "/NOMOUSE", "/NoMouse"
Windows.Forms.Cursor.Hide()
End Select
Next
AppVersion = Assembly.GetExecutingAssembly.GetName.Version.ToString
BuildDate = RetrieveLinkerTimestamp(Process.GetCurrentProcess().MainModule.FileName)
BuildDate = FormatDateTime(BuildDate, DateFormat.LongDate)
Dim d As Date
d = BuildDate
With Me
.labVersion.Text = vbNullString
.labVersion.Text = "Version : " & AppVersion & vbNewLine
.labVersion.Text += "Built : " & Format(d, "dddd") & " " & Format(d, "dd") & " " & Format(d, "MMMM") & " " & Format(d, "yyyy")
End With
Me.Timer1.Interval = 1000
Me.Timer1.Enabled = True
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
If File.Exists(FileName) = False Then
Timer1.Enabled = False
My.Computer.Audio.PlaySystemSound(System.Media.SystemSounds.Asterisk)
Dim Messagefunction As String = MessageBox.Show("Sorry it appears this PoS terminal is missing it's settings.ini file" & vbNewLine & "Click OK to exit the program and then please call algPoS" & vbNewLine & "So they can arrange to get a ini file installed for this terminal", AppName, MessageBoxButtons.OK)
Select Case Messagefunction
Case vbOK
End
End Select
Else
Threading.Thread.Sleep(2000)
Timer1.Enabled = False
Me.Refresh()
ItemCount = 0
TotalDue = 0
ItemQty = 1
AddToStartupList_Done("Completed")
AddToStartupList("Loading Settings File Please Wait...")
Me.Refresh()
LoadPoSSettings_Boot()
LoadTransNumber()
AddToStartupList_Done("Completed")
' Loading PoS Tenders
AddToStartupList("Loading PoS Tender Data Please Wait...")
Me.Refresh()
LoadTenderValues()
LoadCardDataInToDatabase()
AddToStartupList_Done("Completed")
If CustomerDisplayActive = "Yes" Then
If CustomerDisplayInterfaceType = "OPoS" Then
AddToStartupList("Initializing Customer Display Please Wait...")
Me.Refresh()
OpenConnectionToOPoSCustomerDisplay()
TestCustomerDisplay()
AddToStartupList_Done("Completed")
End If
If CustomerDisplayType = "Graphical" Then
client = New TcpClient(CustomerDisplayIPAddress, CustomerDisplayTCPPort)
End If
End If
' Establishing Connection to OPoS Hardware
AddToStartupList("Initializing Receipt Printer Please Wait...")
Me.Refresh()
OPoSConnection()
AddToStartupList_Done("Completed")
If ScannerAttached = 1 Then
AddToStartupList("Initializing Barcode Scanner Please Wait...")
Me.Refresh()
OpenConnectionToOPoSScanner()
AddToStartupList_Done("Completed")
End If
If ScaleAttached = 1 Then
AddToStartupList("Initializing Scale Connection Please Wait...")
Me.Refresh()
OpenConnectionToOPoSScale()
AddToStartupList_Done("Completed")
End If
If MSRActive = 1 Then
AddToStartupList("Initializing MagSwipe Reader Please Wait...")
Me.Refresh()
OpenConnectionToOPoSSwipeCardReader()
AddToStartupList_Done("Completed")
End If
If CashDrawerActive = 1 Then
AddToStartupList("Initializing Cash Drawer Please Wait...")
Me.Refresh()
Threading.Thread.Sleep(1000)
OpenConnectionToOPoSCashDrawer()
AddToStartupList_Done("Completed")
End If
If SoundSettings = 2 Then
AddToStartupList("Initializing Speaker Please Wait...")
Me.Refresh()
Threading.Thread.Sleep(1000)
OpenConnectionToOPoSSpeaker()
AddToStartupList_Done("Completed")
AddToStartupList("Testing Speaker One Moment Please...")
Me.Refresh()
Threading.Thread.Sleep(1000)
MakeNoise()
AddToStartupList_Done("Completed")
End If
AddToStartupList("Initializes the Multisavers component Please Wait...")
'' Initializes the Multisavers component
MSCode_New_Init()
AddToStartupList_Done("Completed")
Threading.Thread.Sleep(1000)
'Sets CapLock so the PoS Keyboard would work
SetFunctionKey("CapsLock", Control.IsKeyLocked(Keys.CapsLock))
SetFunctionKey("NumLock", Control.IsKeyLocked(Keys.NumLock))
AddToStartupList_Done("Completed")
Threading.Thread.Sleep(1000)
Timer1.Enabled = False
SaleMode = "Sale"
ClearMenu()
AddToStartupList("Reprinting store header Please wait...")
PrintStoreHeader("")
AddToStartupList_Done("Completed")
Threading.Thread.Sleep(1000)
If PayPoint_PayzoneName <> "None" Then SaleScreenMoreKeyActive += 1
If WesternUnionActive = 1 Then SaleScreenMoreKeyActive += 1
'put this where you want to turn caps lock on or off
keybd_event(VK_CAPITAL, &H45, KEYEVENTF_EXTENDEDKEY Or 0, 0)
keybd_event(VK_CAPITAL, &H45, KEYEVENTF_EXTENDEDKEY Or KEYEVENTF_KEYUP, 0)
Me.Hide()
With frmBackground
Select Case PrinterOption
Case "RequestOnly"
.picRecipitOff.Visible = True
Case "EndOfSale"
.picRecipitOff.Visible = False
End Select
.Location = New Point(0, 0)
If ScreenMode = "Fullscreen" Then
.FormBorderStyle = Windows.Forms.FormBorderStyle.None
.WindowState = FormWindowState.Maximized
End If
.Show()
.Focus()
End With
End If
End Sub
Private Sub SetFunctionKey(ByVal KeyName As String, ByVal newState As Boolean)
Select Case KeyName
Case "CapsLock"
If newState = False Then
' Simulate the Key Press
keybd_event(VK_CAPITAL, &H45, KEYEVENTF_EXTENDEDKEY Or 0, 0)
' Simulate the Key Release
keybd_event(VK_CAPITAL, &H45, KEYEVENTF_EXTENDEDKEY Or KEYEVENTF_KEYUP, 0)
End If
Case "NumLock"
If newState = False Then
' Simulate the Key Press
keybd_event(VK_CAPITAL, &H90, KEYEVENTF_EXTENDEDKEY Or 0, 0)
' Simulate the Key Release
keybd_event(VK_CAPITAL, &H90, KEYEVENTF_EXTENDEDKEY Or KEYEVENTF_KEYUP, 0)
End If
End Select
End Sub
Private Sub ListStartUp_MeasureItem(ByVal sender As Object, ByVal e As MeasureItemEventArgs) Handles ListStartUp.MeasureItem
e.ItemHeight = e.Graphics.MeasureString(ListStartUp.Items(e.Index).ToString, ListStartUp.Font).Height
End Sub
Private Sub ListStartUp_DrawItem(ByVal sender As Object, ByVal e As DrawItemEventArgs) Handles ListStartUp.DrawItem
e.DrawBackground()
Dim myBrush As Brush
If ListStartUp.SelectedIndices.Contains(e.Index) Then
myBrush = Brushes.White
Else
myBrush = Brushes.Black
End If
If e.Index >= 0 Then
e.Graphics.DrawString(ListStartUp.Items(e.Index).ToString, ListStartUp.Font, myBrush, e.Bounds)
Else
e.Graphics.DrawString(ListStartUp.Items(0).ToString, ListStartUp.Font, myBrush, e.Bounds)
End If
End Sub
End Class
What i can not understand is this code is shared between 3 other programs (same code same method of declaring it and them other 3 work with no problems at all so has something broke with in the npos project?
-
Oct 5th, 2020, 04:43 PM
#6
Re: Visual studio 2008 OPoS development issues
Well, it's throwing an exception, as that's pretty clearly what the 'freaks out' is about. That exception is also being swallowed, or else the whole program would exit, but that's also kind of useless, as you don't know what the error is.
What do you mean when you say that VB won't let you call the code? That doesn't make much sense. I can understand why a device would want to be set up prior to...well, pretty much everything else, based on where you have it, but code is just code. What did you try in that sub?
My usual boring signature: Nothing
-
Oct 16th, 2020, 11:54 PM
#7
Thread Starter
Member
Re: Visual studio 2008 OPoS development issues
Hi Everyone
Thank-you for all your advice and input on this matter I have fixed the issue.
What I did incase anyone wants to know is I deleted the following folders
> obj
> bin
Then I opened the project and rebuilt it and it now works with "Public WithEvents OPoSScanner As New OposScanner_CCO.OPOSScanner" un commented and all the OPoS Scanner code is working as well
Thank-you once again to everyone who put a input into this.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|