So I have a Function that is supposed to convert an image to a byte() and then return a string. However, I am having some issues with this.
Here is the function:
Shared Function saveSknI(ByVal tosave As Image) As String
Dim converter As New ImageConverter
Dim returnValue As String = ""
For Each imageByte As Byte() In converter.ConvertTo(tosave, GetType(Byte()))
returnValue = returnValue & Convert.ToBase64String(imageByte)
Next
Return returnValue
End Function
This Function returns an a System.InvalidCastException exception.
It looks like this:
An unhandled exception of type 'System.InvalidCastException' occurred in ***.exe
Additional information: Unable to cast object of type 'System.Byte' to type 'System.Byte[]'.
I am using vb .net and I don't get why this isn't working, I've scanned the entire project for just byte not byte() and it didn't come up with anything.