Я скомпилировал Exe-файл, используя Visual Studio Express, и он работает совершенно нормально, когда открывается из папки, однако, когда я пытаюсь получить к нему доступ через путь UNC (\ Server \ Folder \ Ticker.exe), это не удается и выдает ошибку: тикер перестал работать.
Подробнее:
Описание:
Перестал работать
Подпись проблемы:
Название проблемного события: CLR20r3
Проблема Подпись 01: cchticker.exe
Проблема Подпись 02: 1.2.0.2
Проблема Подпись 03: 509134ad
Проблема Подпись 04: CCHTicker
Проблема Подпись 05: 1.2.0.2
Проблема Подпись 06: 509134ad
Проблема Подпись 07: d
Проблема Подпись 08: с6
Проблема Подпись 09: System.InvalidOperationException
Версия ОС: 6.1.7601.2.1.0.256.48
ID локали: 2057
Вот мой код:
Imports System.Xml
Imports System.Text
Imports System.IO
Public Class Form1
Dim txtTicker As String = "Ticker"
Dim widthX As Single
Dim heightY As Single = 0
Dim g As Graphics
Dim xmlst As String 'string from the xml file
Dim fo As Font
Dim str As String
Dim strwidth As SizeF 'gets the xml string's width and height
Dim douX As Double 'stores the xmlstring's width
Dim newImage As Image = Image.FromFile(Directory.GetCurrentDirectory & "\BHLogo.bmp")
Dim myArray As New ArrayList
Dim counter As Integer
Dim firstloop As Boolean = True
Protected Overrides Sub OnKeyDown(ByVal e As KeyEventArgs)
MyBase.OnKeyDown(e)
' Disable the event if it was an Alt-F4 keypress.
If (e.Alt AndAlso e.KeyCode = Keys.F4) Then
e.Handled = True
End If
End Sub
Private Sub Form1_MouseDoubleClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseDoubleClick
System.Diagnostics.Process.Start("IExplore.exe", "http://intranet")
End Sub
Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint
Dim mybrush As New SolidBrush(Color.Red)
mybrush.Color = Color.FromArgb(99, 101, 107)
SetStyle(ControlStyles.AllPaintingInWmPaint Or _
ControlStyles.OptimizedDoubleBuffer Or _
ControlStyles.UserPaint, True)
e.Graphics.Clear(Me.BackColor)
e.Graphics.DrawString(str, fo, mybrush, widthX, heightY + 5)
Dim ulCorner As New Point(widthX - 75, heightY)
Dim ulCorner2 As New Point(widthX + douX - 75, heightY)
e.Graphics.DrawImage(newImage, ulCorner)
e.Graphics.DrawImage(newImage, ulCorner2)
Dim i As Integer
For i = 0 To myArray.Count - 1 Step i + 1
'Debug.Write(myArray(i) - counter)
e.Graphics.DrawImage(newImage, New Point(myArray(i) - counter, heightY))
Next
i = 0
e.Graphics.SmoothingMode = Drawing2D.SmoothingMode.AntiAlias
' e.Graphics.SmoothingMode = Drawing2D.SmoothingMode.HighQuality()
e.Graphics.SmoothingMode = Drawing2D.SmoothingMode.HighSpeed
' Debug.Write(String.Format("the string width is {0}", CStr(strwidth.Width)))
If widthX <= (0 - douX) Then
widthX = Me.Width + 125
counter = 0
Else
widthX -= 1
counter += 1
End If
e.Dispose()
End Sub
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) 'Handles Me.Load
driver()
End Sub
Private Sub driver() Handles Me.Load
Me.Width = Screen.PrimaryScreen.WorkingArea.Width
Me.Location = New Point(0, Screen.PrimaryScreen.WorkingArea.Height - 40)
Me.MaximumSize = New Point(Screen.PrimaryScreen.WorkingArea.Width, 40)
Me.Height = 40
Me.MaximizeBox = False
Me.MinimizeBox = False
Me.Text = ""
Me.Icon = Nothing
Me.ShowInTaskbar = False
counter = 0
g = Me.CreateGraphics() 'get the graphics object of the form
widthX = Me.Width + 125 ' x co- ordinate or width
' Debug.Write(String.Format("The width is {0}",
'CStr(Me.Width)))
Me.loadthenews()
' Dim gr As Graphics
Timer1.Interval = 1
Timer1.Start()
'fo = New Font("ARIAL", 18, FontStyle.Bold, GraphicsUnit.Point)
'strwidth = g.MeasureString(str, fo)
'douX = strwidth.Width
End Sub
Private Sub loadthenews()
str = ""
myArray.Clear()
fo = New Font("CALIBRI", 18, FontStyle.Bold, GraphicsUnit.Point)
Dim readXML As New XmlTextReader(Directory.GetCurrentDirectory & "\news.xml")
Try
While readXML.Read()
If readXML.NodeType = XmlNodeType.Text Then
If firstloop = True Then
str += " " & readXML.Value
If str = " closeme" Then
Application.Exit()
End If
Else
str += " " & readXML.Value
End If
firstloop = False
Dim a = g.MeasureString(str, fo)
myArray.Add(Me.Width + 125 + a.Width)
End If
End While
strwidth = g.MeasureString(str, fo)
douX = strwidth.Width + 75
Catch
str = " Ticker"
Dim a = g.MeasureString(str, fo)
'myArray.Add(Me.Width + 125 + a.Width)
End Try
End Sub
Private Sub form1_hover(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.MouseHover
Timer1.Stop()
'Debug.Write("In hover!")
End Sub
Private Sub form1_leave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.MouseLeave
Timer1.Start()
'Debug.Write("In leave!")
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Me.Refresh()
End Sub
Private Sub timer3_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer3.Tick
'Label1.Visible = True
'Label1.Text = System.DateTime.Now.ToString("HH:mm:ss")
If System.DateTime.Now.ToString("mm:ss") = "00:00" Then
firstloop = True
Me.loadthenews()
End If
End Sub
End Class
Я надеюсь, что кто-то может пролить некоторый свет на этот, так как я понятия не имею, будет ли он открываться из папки, но не используя UNC-путь.
Приветствия