Notice (2018-05-24): bugzilla.xamarin.com is now in
Please join us on
Visual Studio Developer Community and in the
Mono organizations on
GitHub to continue tracking issues. Bugzilla will remain
available for reference in read-only mode. We will continue to work
on open Bugzilla bugs, copy them to the new locations
as needed for follow-up, and add the new items under Related
Our sincere thanks to everyone who has contributed on this bug
tracker over the years. Thanks also for your understanding as we
make these adjustments and improvements for the future.
Please create a new report on
Developer Community or GitHub with
your current version information, steps to reproduce, and relevant error
messages or log files if you are hitting an issue that looks similar to
this resolved bug and you do not yet see a matching new report.
I'm currently encountering an odd problem where code is either executed once, or not at all. I am using a PCL (VB.net) with my iOS application. This piece of code works perfectly on our test desktop application (via the same PCL) yet whilst running this on the mobile device I encounter the following error.
#Region "INITIALISATION / TERMINATION"
Public Sub New(ByVal ApplicationLogPath As String, _
ByVal ApplicationFileName As String, _
ByVal ApplicationLogType As LogType, _
ByVal MaxApplicationLogSize As Long)
Dim sb As StringBuilder
' Hold the path and the file name for use throughout the rest of the class. These
' must be passed in rather than using the settings class from within the class
m_filePath = ApplicationLogPath
m_fileName = ApplicationFileName
m_logType = ApplicationLogType
m_maxLogFileSize = MaxApplicationLogSize
' Ensure the application log path has a trailing backslash
'If m_filePath.EndsWith(“\”) = False Then
' m_filePath += "\"
The line of code m_filePath += “\” is executing twice as the variable is seen as “Logs\\” when it is passed in as “Logs”.
If I move the check to above the lines of code where I set the member variables for m_filePath… (etc) to the passed in variable (ApplicationLogPath). While debugging through It steps into the line m_filePath += “\” yet the “\” character is not appended.
This is in the constructor of an Application Log object in the PCL, It is only created once and I cannot see how It can be executing this line more than once.
Removing the If m_filePath.EndsWith(“\”) = False Then makes no difference, the code m_filePath += "\" still executes twice.
Created attachment 6636 [details]
I do not use VS but (in general) the `\` character needs to be escaped since it represent special characters, e.g. `\n` (newline) or `\t` (tab). Both are (in memory) single characters.
To represent a singe '\' character you need to escape it like `\\` - but, in reality (memory), there's only one.
You can confirm this by looking at your string's Length property.
Also note that this represent Windows path and will likely not work on mobile device (where a different separator is used `/`). Your code should be used `Path.Combine` to be cross-platform.