Cannot get inner content error - vb.net

I'm in the process of migrating a website from one of my clients staging servers to a hosted server for one of their clients.
Everything else is working fine except the media gallery section of the website. When trying to open a gallery page I'm getting the error:
Cannot get inner content of ulGallerySlides because the contents are not literal.
I'm more of a techie than a programmer so I'm a bit stumped as to what is causing this and how to fix it. It works perfectly on the staging server.
The staging server is an IIS 7 server which I have full control over and the new server is hosted at an ISP on IIS 8 and I have very little control of it (just through WebSitePanel)
The code behind it is:
Public Sub BuildGalleryView()
Dim objDA As New clsDataAccess
Dim dtResults As New DataTable
Dim iCounter As Integer = 0
Dim intGalleryID As Integer = CInt(Request.QueryString("g"))
Dim strGalleryTitle As String = ""
Dim strGalleryDescription As String = "Test Gallery Description"
Dim strMediaTitle As String = "Test Media Title"
Dim strMediaDescription As String = "Test Media Description"
Dim strMediaURL As String = "./assets/images/placeholder.jpg"
dtResults = objDA.ODSGetGalleryMedia(intGalleryID).Tables(0)
'Set the gallery info first
strGalleryTitle = dtResults(0)("Gallery_Title").ToString
strGalleryDescription = dtResults(0)("Gallery_Description").ToString
lblGalleryTitle.InnerText = strGalleryTitle.ToString
lblGalleryDescription.InnerText = strGalleryDescription.ToString
lblGalleryMainTitle.InnerText = strGalleryTitle.ToString
If Not dtResults Is Nothing Then
'Loop through all the images and build the slider"
For i As Integer = 1 To dtResults.Rows.Count
strMediaTitle = dtResults(iCounter)("Media_Title").ToString
strMediaDescription = dtResults(iCounter)("Media_Description").ToString
strMediaURL = "./assets/" & dtResults(iCounter)("Media_URL").ToString
ulGallerySlides.InnerHtml = ulGallerySlides.InnerHtml & _
"<li>" & _
"<img src='" & strMediaURL & "' align='Slider'/>" & _
"<div class='flex-caption'>" & _
"<h2>" & strMediaTitle & "</h2>" & _
"<p>" & strMediaDescription & "</p>" & _
"</div>" & _
"</li>"
iCounter = iCounter + 1
Next
End If
End Sub
What do I need to change to fix this?

Related

Datagridview - Insert an image into a cell in a specific row

I have a vb.net project where I have a DataGridView (called "dgvRevisiones") to record information about vehicle damage records.
Through an SFTP that I have previously configured, I have the photos of each damage record, my program downloads them in a temporary folder and that works perfect.
The problem is when I need to insert each image of each record in the corresponding cell.
Currently I have a code that only inserts the last image it collects and repeats it throughout the column.
Here I leave my code:
Public Sub ExtraerImagenRegistrosDaño()
Dim img As Image
Dim imagecol As New DataGridViewImageColumn
imagecol.ImageLayout = DataGridViewImageCellLayout.Zoom
FormPrincipal.dgvRevisiones.Columns.Insert(0, imagecol)
Dim rutaTmp = Application.StartupPath & "/tmp"
If (Not System.IO.Directory.Exists(rutaTmp)) Then
System.IO.Directory.CreateDirectory(rutaTmp)
End If
For rowIndex = 0 To FormPrincipal.dgvRevisiones.RowCount - 1
Dim idreg = FormPrincipal.dgvRevisiones.Rows(rowIndex).Cells("idreg").Value.ToString
Dim descripcion = FormPrincipal.dgvRevisiones.Rows(rowIndex).Cells("descripcion").Value.ToString
ConexionBD.conectar()
Dim recoleccionidins As New DataTable
comandoquery = "SELECT idins FROM registro_dano WHERE descripcion='" & descripcion & "' AND idreg='" & idreg & "'"
comando.Connection = ConexionBD.conexion
comando.CommandText = comandoquery
recoleccionidins.Load(comando.ExecuteReader)
Dim idinsExtraido = recoleccionidins.Rows(0).Item(0).ToString().Trim()
ConexionBD.cerrar()
Dim sessionOptions As New SessionOptions
With sessionOptions
.Protocol = Protocol.Sftp
.HostName = "HOST"
.UserName = "USER"
.Password = "PASSWORD"
.GiveUpSecurityAndAcceptAnySshHostKey = True
End With
Using session As New Session
session.Open(sessionOptions)
Try
session.GetFiles("/home/sislota/database-registros-dano/Registro-" & idinsExtraido & "-" & idreg & ".png", rutaTmp & "\Registro-" & idinsExtraido & "-" & idreg & ".png").Check()
Catch ex As Exception
End Try
End Using
And here start the issue:
Try
img = Image.FromFile(rutaTmp & "\Registro-" & idinsExtraido & "-" & idreg & ".png")
Catch ex As Exception
End Try
imagecol.Image = img
Next
End Sub

vb.net WPF application combobox not waiting for user to choose

I have a wpf vb.net application (written in VS 2019 community) containing two website searches. The first search is a string search and that either produces one result, which I then load into the second search, or it produces more than one result, which I load into a combobox to let the user choose. My problem is getting the application to stop and allow the user to choose from the combobox. I have implemented a workaround that uses a modal form containing a combobox and this allows the user to choose from the combobox and supply the value to the second search. I have been advised to use the 'change' event for the combobox but there isn't one available, I have also been advised to use the selectedindexchanged but the control doesn't let the dropdown list occur to select anything. I have also tried using various forms of addhandler (commented out in the code below).
' Build the 'Search API' URL.
Dim uri = New Uri("https://api.themoviedb.org/3/search/tv?" _
& "api_key=" & TMDBAPIKey _
& "&language=en-US" _
& "&query=" & sLvl1NodeName _
& "&page=1" _
& "&first_air_date_year=" & sFirstXmitYear)
' Retrieve the IMDB ID with an API Search function using the series title
Try
Dim Site = New WebClient()
Answer = Site.DownloadString(uri)
Catch ex As NullReferenceException
Dim messagetext As String = "The 'Search API' from GetDetails popup failed with : " _
& ex.Message & " for: Title=" & sLvl1NodeName
Me.txtErrorMessageBox.Text = messagetext
Exit Sub
End Try
' Deserialise the answer
Dim JsonElem As TMDBtitle = JsonConvert.DeserializeObject(Of TMDBtitle)(Answer)
' If the websearch finds only one result this is the TV series we want, if more than
' one result is found load the results into a combobox and get the user to choose.
If JsonElem.results.Length = 1 Then
TVSeriesID = JsonElem.results(0).id
Else
Me.cmbChooseSeries.BeginUpdate()
Me.lblChooseSeries.Text = Me.lblChooseSeries.Text & "( " & JsonElem.results.Length & " )"
Me.cmbChooseSeries.Items.Clear()
For Each titleresult In JsonElem.results
ComboSeriesChoice = titleresult.name & " | " &
titleresult.id & " | " &
titleresult.first_air_date & " | " &
titleresult.overview
Me.cmbChooseSeries.Items.Add(ComboSeriesChoice)
Next
cmbChooseSeries.DroppedDown = True
Me.cmbChooseSeries.EndUpdate()
If cmbChooseSeries.SelectedIndex <> -1 Then
Dim var1 = cmbChooseSeries.SelectedText
Else
Threading.Thread.Sleep(3000)
End If
'AddHandler cmbChooseSeries.MouseDoubleClick,
'Sub()
'Threading.Thread.Sleep(3000)
'End Sub
TVSeriesID = cmbChooseSeries.SelectedItem
End If
' Build the 'TV Search API' call URL.
Dim urix = New Uri("https://api.themoviedb.org/3/tv/" _
& TVSeriesID & "?" _
& "api_key=" & TMDBAPIKey _
& "&language=en-US")
Try
Dim site = New WebClient()
Answer = site.DownloadString(urix) ' download the JSON from the server.
Catch ex As NullReferenceException
Dim MessageText As String = "The 'TV Search API' from GetDetails popup failed with : " _
& ex.Message & " for: Title=" & sLvl1NodeName & " ID=" & popupid
Me.txtErrorMessageBox.Text = MessageText
Exit Sub
End Try
Dim jsonelemx = JsonConvert.DeserializeObject(Of TVResult)(Answer)
lstDetailItems(0) = "Name"
lstDetailItems(1) = jsonelemx.name
lstDetailItems(2) = (String.Empty)
Dim DelItems = New ListViewItem(lstDetailItems)
Me.lstSeriesDetails.Items.Add(DelItems)
lstDetailItems(0) = "Status"
lstDetailItems(1) = jsonelemx.status
lstDetailItems(2) = (String.Empty)
DelItems = New ListViewItem(lstDetailItems)
Me.lstSeriesDetails.Items.Add(DelItems)
lstDetailItems(0) = "Episode run time"
lstDetailItems(1) = Convert.ToString(jsonelemx.episode_run_time(0))
lstDetailItems(2) = (String.Empty)
DelItems = New ListViewItem(lstDetailItems)
Me.lstSeriesDetails.Items.Add(DelItems)

VB.net get bitlocker Password ID from Active Directory

I have a VB.net program that I am trying to add a bitlocker lookup tool that will search active directory for the machine name, and display the "Password ID" as well as the "Recovery Password"
So far my script/code works flawlessly for the lookup and displaying the Recovery Password, but I cannot get it to display the Password ID.
I've tried:
Item.Properties("msFVE-RecoveryGuid")(0)
Which returns the error "System.InvalidCastException: Conversion from type 'Byte()' to type 'String' is not valid."
Item.Properties("msFVE-RecoveryGuid")(0).ToString
Which returns "System.Byte[]"
Item.Properties("msFVE-RecoveryGuid").ToString
Which returns "System.DirectoryServices.ResultPropertyValueCollection"
So far in my searching I've only seen C# examples, and I haven't been able to translate.
The same for Recovery Password works however:
(Item.Properties("msFVE-RecoveryPassword")(0))
Here is the larger snippet of what I have for context:
Dim RootDSE As New DirectoryEntry("LDAP://RootDSE")
Dim DomainDN As String = RootDSE.Properties("DefaultNamingContext").Value
Dim ADsearch As New DirectorySearcher("LDAP://" & DomainDN)
ADsearch.Filter = ("(&(objectClass=computer)(name=" & MachineName & "))")
Dim ADresult As SearchResult = ADsearch.FindOne
Dim ADpath As String = ADresult.Path
Dim BTsearch As New DirectorySearcher()
BTsearch.SearchRoot = New DirectoryEntry(ADpath)
BTsearch.Filter = "(&(objectClass=msFVE-RecoveryInformation))"
Dim BitLockers As SearchResultCollection = BTsearch.FindAll()
Dim Item As SearchResult
Dim longTempstring As String = ""
For Each Item In BitLockers
If Item.Properties.Contains("msFVE-RecoveryGuid") Then
Dim tempstring As String = Item.Properties("msFVE-RecoveryGuid")(0).ToString
longTempstring = longTempstring & tempstring & vbNewLine
'ListBox2.Items.Add(Item.Properties("msFVE-RecoveryGuid")(0))
End If
If Item.Properties.Contains("msFVE-RecoveryPassword") Then
ListBox1.Items.Add(Item.Properties("msFVE-RecoveryPassword")(0))
End If
Next
MsgBox(longTempstring)
So I figured out that I needed to convert the bytes to hex in order to get them to match what is viewed in the Microsoft Management Console. Once I began doing that the only problem I ran into is that I discovered the indexing of the byte arrays are not in the same order as they are in Active Directory. -- so instead of looping I had to list out each index of the Byte array and sort them to their proper positions so that they match how they show up in AD.
My end function is:
Function bitread(ByVal GUID As Byte())
Dim tempVar As String
tempVar = GUID(3).ToString("X02") & GUID(2).ToString("X02") _
& GUID(1).ToString("X02") & GUID(0).ToString("X02") & "-" _
& GUID(5).ToString("X02") & GUID(4).ToString("X02") & "-" _
& GUID(7).ToString("X02") & GUID(6).ToString("X02") & "-" _
& GUID(8).ToString("X02") & GUID(9).ToString("X02") & "-" _
& GUID(10).ToString("X02") & GUID(11).ToString("X02") _
& GUID(12).ToString("X02") & GUID(13).ToString("X02") _
& GUID(14).ToString("X02") & GUID(15).ToString("X02")
Return tempVar
End Function
Called with:
bitread(Item.Properties("msFVE-RecoveryGUID")(0))

File not getting created - Visual Basic

I'm making a skype tool, and I'm creating the config file automatically, or at least that's what I think I am doing. The problem is just that for some reason the FileNotFoundException is fired because of some of my code is refering to the file which doesn't exist yet. So is visual basic checking for exceptions before firing code, or am I doing something wrong?
Here's my file creation code:
If My.Computer.FileSystem.DirectoryExists("C:\BaconSkypeTool") Then
Else
My.Computer.FileSystem.CreateDirectory("C:\BaconSkypeTool")
End If
If My.Computer.FileSystem.FileExists(Path) Then
Else
Dim fs As FileStream = File.Create(Path)
Dim line1 As Byte() = New UTF8Encoding(True).GetBytes("This is the configuration file for BaconSkypeTool" & vbCrLf & "Please do not change anything in here if you don't know what you're doing." & vbCrLf & vbCrLf & "Values below" & vbCrLf & "ChangeStatusInCall = True" & vbCrLf & "Status = Online" & vbCrLf & "Enable .cancel command = True")
fs.Write(line1, 0, line1.Length)
fs.Close()
End If
And here's the code that fires the exception:
skype.CurrentUserStatus = SKYPE4COMLib.TOnlineStatus.olsOnline
Dim text = My.Computer.FileSystem.ReadAllText("C:\BaconSkypeTool\config.cfg")
Dim textAfterStatus As String = Nothing
Dim indexOfStatus = text.IndexOf("Status = ")
Dim text1 As String = Nothing
If indexOfStatus >= 0 Then
textAfterStatus = text.Substring(indexOfStatus + "Status = ".Length)
text1 = textAfterStatus.Split("Blacklist").First().Trim()
End If
The file creation is at the top of my file and therefore should be the first thing to be fired, but maybe that's just something I think.

Crystal Reports Missing Parameter Values

I am running the version of crystal that comes with Visual Studio 2010. I have a report that has three sub reports. There are parameters that are passed from the main report to the sub-reports. I am able to run the report in the development environment by clicking on Main Report Preview.
The problem is when I try to execute it at run time. I get the error “Missing parameter values”. I need some hints as to how to debug this problem. The error doesn’t tell you which parameter is the problem or which sub-report is involved.
Any hint will be appreciated.
I am editing this to respond to some of the questions. I am using subreports links which is where I think the problem might be. In the pass by fiddling with the settings I was able to get it to work. It seems like it was just trial and error.
I am posting a portion of the code here based on the request in the comments
Public Function GetReportOutput(iDatabaseIndicator As eDatabaseIndicatorEnum, ReportName As String, ReportOutputtype As eReportOutputtype, ReportParameters As System.Collections.Generic.List(Of clsReportParam)) As clsReturn Implements IsvcEDReports.GetReportOutput
Dim l_crRep As New CrystalDecisions.CrystalReports.Engine.ReportDocument
Dim l_clsReturn As clsReturn = New clsReturn
Dim l_ExportFormatType As ExportFormatType
Dim l_strReport As String = ""
Dim l_strReportName As String = ""
Dim l_strOutputFile As String = ""
Dim l_strFullPathName As String = ""
Dim l_strReportOutputPath As String = ConfigurationManager.AppSettings.Get(IIf(ConfigurationManager.AppSettings.Get("Environment") = 1, "ReportOutputPath_Dev", "ReportOutputPath_Prod"))
Dim l_strReportPath As String = ConfigurationManager.AppSettings.Get(IIf(ConfigurationManager.AppSettings.Get("Environment") = 1, "ReportPath_Dev", "ReportPath_Prod"))
Dim l_udtReport As CrystalDecisions.CrystalReports.Engine.ReportDocument = Nothing
Dim l_intCount As Integer = 0
Dim l_fsReturn As FileStream = Nothing
Dim l_binFilestream As BinaryReader = Nothing
Dim l_bytFile As Byte() = Nothing
Dim l_expOptions As New CrystalDecisions.Shared.ExportOptions
Dim l_expExcFmtOptions As New CrystalDecisions.Shared.ExcelFormatOptions
Dim l_tblParameters As New DataTable("Parameters")
Dim l_aryParams(1)
Dim udtSubReport As ReportDocument
Dim udtSubReportOpened As ReportDocument
Try
iDatabaseIndicator = iDatabaseIndicator
InitDataController(iDatabaseIndicator)
m_strReport = (l_strReportPath & "\" & ReportName)
l_strReportName = ReportName
l_strReport = m_strReport
l_strOutputFile = Regex.Replace(ReportName, " ", "_") & "_" & Format(Now(), "MMddyyyy_hhmmss")
m_strOutputFilename = l_strOutputFile
With l_crRep
.Load(l_strReport, CrystalDecisions.Shared.OpenReportMethod.OpenReportByDefault)
If .IsLoaded Then
For Each udtSubReport In .Subreports
udtSubReportOpened = .OpenSubreport(udtSubReport.Name)
SetDatabase(udtSubReportOpened, False)
SetParameters(udtSubReportOpened, ReportParameters, False)
Next
SetDatabase(l_crRep)
SetParameters(l_crRep, ReportParameters)
Select Case ReportOutputtype
'Case eReportOutputtype.rptOutputType_RPT
' l_strOutputFile = l_strOutputFile & ".rpt"
' l_ExportFormatType = ExportFormatType.CrystalReport
Case eReportOutputtype.rptOutputType_XLS
l_strOutputFile = l_strOutputFile & ".xls"
'ReportOutputFile = ReportOutputFile & ".xls"
With l_expExcFmtOptions
.ExcelConstantColumnWidth = 125
.ExcelUseConstantColumnWidth = True
End With
With l_expOptions
.ExportFormatOptions = l_expExcFmtOptions
End With
l_ExportFormatType = ExportFormatType.Excel
Case eReportOutputtype.rptOutputType_PDF
l_strOutputFile = l_strOutputFile & ".pdf"
' ReportOutputFile = ReportOutputFile & ".pdf"
l_ExportFormatType = ExportFormatType.PortableDocFormat
Case eReportOutputtype.rptOutputType_DOC
l_strOutputFile = l_strOutputFile & ".doc"
' ReportOutputFile = ReportOutputFile & ".doc"
l_ExportFormatType = ExportFormatType.WordForWindows
Case eReportOutputtype.rptOutputType_CSV
l_strOutputFile = l_strOutputFile & ".csv"
' ReportOutputFile = ReportOutputFile & ".csv"
l_ExportFormatType = ExportFormatType.CharacterSeparatedValues
Case eReportOutputtype.rptOutputType_TXT
l_strOutputFile = l_strOutputFile & ".txt"
' ReportOutputFile = ReportOutputFile & ".txt"
l_ExportFormatType = ExportFormatType.Text
Case eReportOutputtype.rptOutputType_XML
l_strOutputFile = l_strOutputFile & ".xml"
' ReportOutputFile = ReportOutputFile & ".xml"
l_ExportFormatType = ExportFormatType.Xml
End Select
.ExportToDisk(l_ExportFormatType, l_strReportOutputPath & "\" & l_strOutputFile)
It crashes on the last line .ExportToDisk ...
I solved this problem, It was the hint from heringer that gave me the clue. I am passing 6 parameters to the main report but two of them are only used by the a sub-report not the main reports itself. I was defining these without the leading "#". I figured this out by display the parameters as I passed them in my code.
I was also able to look at an old report that was working and saw that I needed the at signs.
Bob