Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5970279
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T20:21:07+00:00 2026-05-22T20:21:07+00:00

Greetings! So I have a base class that defines a base64Binary property to be

  • 0

Greetings!

So I have a base class that defines a base64Binary property to be returned as an embedded file in XML. I am not getting any errors, however the string being returned is not being encoded as base64. Any ideas? I have included the base class, and also the code where it is being called. Any help would be greatly appreciated!!

'--------------------------------------------------
'BinaryObjectType type
'--------------------------------------------------
<XmlType(TypeName:="BinaryObjectType",Namespace:=Declarations.SchemaVersion),Serializable, _
EditorBrowsable(EditorBrowsableState.Advanced)> _
Public Class BinaryObjectType
    '*********************** format attribute ***********************
    <XmlAttribute(AttributeName:="format", Form:=XmlSchemaForm.Unqualified, DataType:="string", Namespace:=Declarations.SchemaVersion), _
    EditorBrowsable(EditorBrowsableState.Advanced)> _
    Public __format As String

    <XmlIgnore()> _
    Public Property format As String
        Get
            format = __format
        End Get
        Set(ByVal Value As String)
            __format = Value
        End Set
    End Property

    '*********************** mimeCode attribute ***********************
    <XmlAttribute(AttributeName:="mimeCode", Form:=XmlSchemaForm.Unqualified, Namespace:=Declarations.SchemaVersion), _
    EditorBrowsable(EditorBrowsableState.Advanced)> _
    Public __mimeCode As String

    <XmlIgnore()> _
    Public Property mimeCode As String
        Get
            mimeCode = __mimeCode
        End Get
        Set(ByVal Value As String)
            __mimeCode = Value
        End Set
    End Property

    '*********************** encodingCode attribute ***********************
    <XmlAttribute(AttributeName:="encodingCode", Form:=XmlSchemaForm.Unqualified, DataType:="normalizedString", Namespace:=Declarations.SchemaVersion), _
    EditorBrowsable(EditorBrowsableState.Advanced)> _
    Public __encodingCode As String

    <XmlIgnore()> _
    Public Property encodingCode As String
        Get
            encodingCode = __encodingCode
        End Get
        Set(ByVal Value As String)
            __encodingCode = Value
        End Set
    End Property

    '*********************** characterSetCode attribute ***********************
    <XmlAttribute(AttributeName:="characterSetCode", Form:=XmlSchemaForm.Unqualified, DataType:="normalizedString", Namespace:=Declarations.SchemaVersion), _
    EditorBrowsable(EditorBrowsableState.Advanced)> _
    Public __characterSetCode As String

    <XmlIgnore()> _
    Public Property characterSetCode As String
        Get
            characterSetCode = __characterSetCode
        End Get
        Set(ByVal Value As String)
            __characterSetCode = Value
        End Set
    End Property

    '*********************** uri attribute ***********************
    <XmlAttribute(AttributeName:="uri", Form:=XmlSchemaForm.Unqualified, DataType:="anyURI", Namespace:=Declarations.SchemaVersion), _
    EditorBrowsable(EditorBrowsableState.Advanced)> _
    Public __uri As String

    <XmlIgnore()> _
    Public Property uri As String
        Get
            uri = __uri
        End Get
        Set(ByVal Value As String)
            __uri = Value
        End Set
    End Property

    '*********************** filename attribute ***********************
    <XmlAttribute(AttributeName:="filename", Form:=XmlSchemaForm.Unqualified, DataType:="string", Namespace:=Declarations.SchemaVersion), _
    EditorBrowsable(EditorBrowsableState.Advanced)> _
    Public __filename As String

    <XmlIgnore()> _
    Public Property filename As String
        Get
            filename = __filename
        End Get
        Set(ByVal Value As String)
            __filename = Value
        End Set
    End Property

    '*********************** XmlText field ***********************
    <XmlText(DataType:="base64Binary"), _
    EditorBrowsable(EditorBrowsableState.Advanced)> _
    Public __Value As Byte()

    <XmlIgnore()> _
    Public Property Value() As Byte()
        Get
            Value = __Value
        End Get
        Set(ByVal val As Byte())
            __Value = val
        End Set
    End Property

    '*********************** Constructor ***********************
    Public Sub New()
    End Sub
End Class

Here is the snippet where it is being built:

Dim binFile As New BinaryObjectType

Select Case Trim(UCase(objFromDB.FileFormat))
    Case "PDF"
        binFile.mimeCode = "application/pdf"
    Case "DOC"
        binFile.mimeCode = "application/ms-word"
    Case "DOCX"
        binFile.mimeCode = "application/ms-word"
    Case "GIF"
        binFile.mimeCode = "image/gif"
    Case "JPG"
        binFile.mimeCode = "image/jpeg"
    Case "JPEG"
        binFile.mimeCode = "image/jpeg"
    Case "PNG"
        binFile.mimeCode = "image/png"
    Case Else
        binFile.mimeCode = "text/html"
    End Select

    binFile.Value = objFile
    attachmentArea.EmbeddedData = binFile
    attachmentAreaList.Add(attachmentArea)
    candidateProfile.AttachmentCollection = attachmentAreaList        
    candidateProfileList.Add(candidateProfile)        
    candidateArea.CandidateProfileCollection = candidateProfileList        
    candidateAreaList.Add(candidateArea)        
    dataArea.Show = showArea        
    dataArea.CandidateCollection = candidateAreaList        
    showResponse.DataArea = dataArea

    Return showResponse

I am not getting errors, and I am getting a result for the binFile.Value, but it isn’t being base64 encoded.

Any ideas?
Thanks in advance!!!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T20:21:08+00:00Added an answer on May 22, 2026 at 8:21 pm

    How do you see that the string is not base64-encoded? I tried a similar scenario (see below), and the Byte() was properly encoded in base-64.

    Public Class StackOverflow_6186859_751090
    
        Public Class Declarations
            Public Const SchemaVersion As String = "http://my.namespace"
        End Class
    
        'BinaryObjectType type 
        '-------------------------------------------------- 
        <XmlType(TypeName:="BinaryObjectType", Namespace:=Declarations.SchemaVersion), Serializable(), _
         EditorBrowsable(EditorBrowsableState.Advanced)> _
         Public Class BinaryObjectType
            <XmlAttribute(AttributeName:="format", Form:=XmlSchemaForm.Unqualified, DataType:="string", Namespace:=Declarations.SchemaVersion), _
                 EditorBrowsable(EditorBrowsableState.Advanced)> _
                 Public __format As String
            <XmlIgnore()> _
            Public Property format() As String
                Get
                    format = __format
                End Get
                Set(ByVal Value As String)
                    __format = Value
                End Set
            End Property
    
            <XmlAttribute(AttributeName:="mimeCode", Form:=XmlSchemaForm.Unqualified, Namespace:=Declarations.SchemaVersion), _
             EditorBrowsable(EditorBrowsableState.Advanced)> _
            Public __mimeCode As String
            <XmlIgnore()> _
            Public Property mimeCode() As String
                Get
                    mimeCode = __mimeCode
                End Get
                Set(ByVal Value As String)
                    __mimeCode = Value
                End Set
            End Property
    
            <XmlText(DataType:="base64Binary"), _
             EditorBrowsable(EditorBrowsableState.Advanced)> _
            Public __Value As Byte()
            <XmlIgnore()> _
            Public Property Value() As Byte()
                Get
                    Value = __Value
                End Get
                Set(ByVal val As Byte())
                    __Value = val
                End Set
            End Property
    
        End Class
    
        Public Shared Sub Test()
            Dim ms As MemoryStream = New MemoryStream()
            Dim ser As XmlSerializer = New XmlSerializer(GetType(BinaryObjectType))
            Dim obj As BinaryObjectType = New BinaryObjectType()
            obj.format = "PNG"
            obj.mimeCode = "image/png"
            obj.Value = Encoding.UTF8.GetBytes("Some random text which will be encoded as bytes")
            ser.Serialize(ms, obj)
            Console.WriteLine(Encoding.UTF8.GetString(ms.ToArray()))
        End Sub
    End Class
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Greetings! I have an XML value that I'd like to use as a boolean
Greetings, Apologies in advance that I have not researched this toughly enough to answer
Greetings! I have an issue here that i can't find. I am getting a
Greetings: I have put together a RESTful web service in .NET 3.5 that takes
Greetings, I have a particular object which can be constructed from a file, as
Greetings! If I have XML such as this: <Root> <AlphaSection> . . . </AlphaSection>
Greetings! I have some XML like this: <Root> <AlphaSection> . . . </AlphaSection> <BetaSection>
Greetings! I have some XML like this: <Root> <MainSection> <SomeNode>Some Node Value</SomeNode> <SomeOtherNode>Some Other
Greetings I have this structure: <ul id=list class=tabs> <li class=list><a href=#tab1>Dados do Responsável</font></a></li> <li
Greetings All, I have a SQLite database that I'm trying to add a new

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.