Hi I tried to convert this using the web free tool conversion. My problem is the raisevent and below is the script that I converted from c# to vb. Tried to run it the error is below first string of code...
GoogleMapForASPNet1.PushpinDrag += New GoogleMapForASPNet.PushpinDragHandler(AddressOf OnPushpinDrag)
'Heres the event handler for PushpinDrag event
Private Sub OnPushpinDrag(pID As String)
lblPushpin1.Text =
"(" + GoogleMapForASPNet1.GoogleMapObject.Points(pID).Latitude.ToString() + ","
+ GoogleMapForASPNet1.GoogleMapObject.Points(pID).Longitude.ToString() + ")"
End Sub
Hoping for anyone to help me with this scenario
Convert it to this:
AddHandler GoogleMapForASPNet1.PushpinDrag, AddressOf OnPushpinDrag
Documentation
Related
I'm tasked with converting some older VB.net code to C#. Been slowly chipping away at the errors -went from about 100, down now to ~10. The first vb.net code that needs to be converted is:
Try
My.Computer.FileSystem.CopyFile(strFile, strExportPath + "\" + strFileName(0), FileIO.UIOption.OnlyErrorDialogs, FileIO.UICancelOption.DoNothing)
intFilesCopied += 1
My.Computer.FileSystem.MoveFile(strFile, _strPath + "Data\Backup\" + strFileName(0), FileIO.UIOption.OnlyErrorDialogs, FileIO.UICancelOption.DoNothing)
intFilesMoved += 1
Catch ex As Exception
My.Application.Log.WriteException(ex, TraceEventType.Error, "ExportDataToolStripMenuItem_Click")
End Try
My C# attempt is as follows:
try
{
File.Copy(strFile, strExportPath + #"\" + strFileName[0], UIOption.OnlyErrorDialogs,
FileIO.UICancelOption.DoNothing);
intFilesCopied += 1;
File.Move(strFile, _strPath + #"Data\Backup\" + strFileName[0],
UIOption.OnlyErrorDialogs, UICancelOption.DoNothing);
intFilesMoved += 1;
}
catch (Exception ex)
{
Application.Log.WriteException(ex, TraceEventType.Error, "ExportDataToolStripMenuItem_Click");
}
The next piece of VB.NET is the catch portion of the try-catch clauses.
My.Application.Log.WriteException(ex, TraceEventType.Error, "Could not write record to data file " + _strActiveFileName + Environment.NewLine + "Record Data: " + strRecordText);
And for the life of me, cannot find the C#-equivalent for this.
I've tried adding the Microsoft.VisualBasic dll/reference/namespace, but that doesn't work either. Tried to google the C#-equivalent, but couldn't find anything.
The next piece of VB.NET is the catch portion of the try-catch
clauses.
My.Application.Log.WriteException(ex, TraceEventType.Error, "Could not
write record to data file " + _strActiveFileName + Environment.NewLine
+ "Record Data: " + strRecordText);
And for the life of me, cannot find the C#-equivalent for this.
This can be converted by (with reference to Microsoft.VisualBasic.dll):
Microsoft.VisualBasic.ApplicationServices.ApplicationBase MyApplication = new Microsoft.VisualBasic.ApplicationServices.ApplicationBase();
then :
MyApplication.Log.WriteException(ex, TraceEventType.Error, "ExportDataToolStripMenuItem_Click");
And you can check the log file with :
System.Windows.Forms.MessageBox.Show(MyApplication.Log.DefaultFileLogWriter.FullLogFileName);
(just tested on Windows 10)
When I use Console functions such as SetCursorPosition or Clear, I get an error saying the handle is invalid.
Example:
> Write("aaa");SetCursorPosition(0, 0);Write("b")
aaaThe handle is invalid.
+ System.IO.__Error.WinIOError(int, string)
+ System.Console.GetBufferInfo(bool, out bool)
+ System.Console.GetBufferInfo()
+ System.Console.SetCursorPosition(int, int)
+ <Initialize>.MoveNext()
> Write("bbb");Clear();
bbbThe handle is invalid.
+ System.IO.__Error.WinIOError(int, string)
+ System.Console.GetBufferInfo(bool, out bool)
+ System.Console.Clear()
How do I fix this and be able to use these functions in the C# Interactive window?
I'm using ReportViewer and I'm looking to listen to the result of the exports. I would like to get a callback on the export details (filename and filepath). I googled around and was only able to find the reportviewer.export event but that's an event that is triggered before the export. I'm looking for something afterwards. Any tips would be greatly appreciated.
You could implement your own ReportExport event in order to add functionality after the export.
This is an example in VB.NET:
Private Sub ReportViewer1_ReportExport(sender As Object, e As Microsoft.Reporting.WinForms.ReportExportEventArgs) Handles ReportViewer1.ReportExport
e.Cancel = True 'stop the default ReportExport event
Dim strExtension As String = ""
Select Case UCase(e.Extension.Name)
Case "PDF"
strExtension = ".pdf"
Case "EXCEL"
strExtension = ".xls"
Case "WORD"
strExtension = ".doc"
End Select
Dim dlgSaveFile As New System.Windows.Forms.SaveFileDialog
dlgSaveFile.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)
dlgSaveFile.Filter = e.Extension.LocalizedName + " (*" + strExtension + ")|*" + strExtension + "|All files(*.*)|*.*"
If dlgSaveFile.ShowDialog(Me) = Windows.Forms.DialogResult.OK Then
Me.ReportViewer1.ExportDialog(e.Extension, e.DeviceInfo, dlgSaveFile.FileName)
'add here your functionality, for example a simple MsgBox that display where file is saved
MsgBox("File saved in: " & dlgSaveFile.FileName)
End If
End Sub
I had a website created using Asp.Net framework 3.5 and And now I'm upgrading it to Visualstudio 2015 (framework 4.6)..
When click on any link it throws an error- Cannot use a leading .. to exit above the top directory
string mslinepath = ResolveUrl("~/" + dt_submenu.Rows[i].ItemArray[1].ToString().Trim());
string pagenamesub = mslinepath + "?Session=" + dt_submenu.Rows[i].ItemArray[2].ToString().Trim(); //"Framework.aspx?name=" +
// nav.InnerHtml += "<li> " + UppercaseFirstEach(dt_submenu.Rows[i].ItemArray[0].ToString().Trim()) + " ";
str += "<li> " + UppercaseFirstEach(dt_submenu.Rows[i].ItemArray[0].ToString().Trim()) + " ";
submenu(dt_submenu.Rows[i].ItemArray[3].ToString().Trim());
// nav.InnerHtml += "</li>";
If anyone knows the solution please let me know.. Thanks in advance
I had this problem and the answer was actually quite simple:
Open your master page and review all your include files, css, js, etc..
Replace:
href="../"
with
href="/"
In other words, the master page must use absolute path and not relative.
I am trying to make to create a .cmd file with this code into it: call .\CopyToTarget.cmd w60 glb "C:\Users\oma\me\trunk-r664\USB-map". I am creating this code ~5 times.
But since \trunk-r664\ is already in use it seems like I cannot write: #"\trunk-r664\USB-map" into the .cmd file for some reason. Does anyone know how to fix it? It keeps getting me the error: UnauthorizedAccesExpection was unhandled, ccess to the path 'C:\Users\me\Desktop\trunk-r664\USB-map' is denied.
using (StreamWriter sw = File.CreateText(Environment.GetFolderPath(Environment.SpecialFolder.Desktop)
+ "\\trunk-r664\\trunk\\cmd\\custom\\RunAll.cmd"))
{
for (int j=0;j<installeerlijst64.Count;j++)
{
sw.WriteLine("call .\\CopyToTarget.cmd " + installeerlijst64[j] + " glb" +
File.CreateText(Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + #"\trunk-r664\USB-map"));
}
}
I tried this too, but it tells me I am using an illegal character:
"\""+File.CreateText(Environment.GetFolderPath(Environment.SpecialFolder.Desktop)
+ #"\trunk-r664\USB-map" + "\""));
File.CreateText will create a new file. First time when for loop execute, it will create and open the file USB-map and hold the handle of that file. During second iteration of for loop, it will try to do the same thing. Hence, already in use error.
Remove File.CreateText and you will get the desired result.
sw.WriteLine("call .\\CopyToTarget.cmd " + installeerlijst64[j] + " glb " + "\"" +
Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + #"\trunk-r664\USB-map" + "\"");