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 7192585
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T19:58:15+00:00 2026-05-28T19:58:15+00:00

I have this code in my WCF Service: public class MyImage { public Image

  • 0

I have this code in my WCF Service:

public class MyImage
{
    public Image Image { get; set; }
    public string FullPath { get; set; }
}

[ServiceContract]
public interface IMyService
{
    [OperationContract] void SaveImage(MyImage myImg);
}

public class MyService : IMyService
{
    public void SaveImage(MyImage myImg)
    {
        // ...
    }
}

But this error occur when I run the SaveImage() method:

There was an error while trying to serialize parameter http://tempuri.org/:e. The InnerException message was ‘Type ‘System.Drawing.Bitmap’ with data contract name ‘Bitmap:http://schemas.datacontract.org/2004/07/System.Drawing’ is not expected. Consider using a DataContractResolver or add any types not known statically to the list of known types – for example, by using the KnownTypeAttribute attribute or by adding them to the list of known types passed to DataContractSerializer.’

My code is in C#, Framework 4.0, build in Visual Studio 2010 Pro.

Please help, 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-28T19:58:16+00:00Added an answer on May 28, 2026 at 7:58 pm

    The data-contract expected Image, but it got a Bitmap : Image instance. WCF likes to know about inheritance in advance, so you would need to tell it. But! I honestly don’t think that is a good approach; you should really just throw the raw binary around instead – which probably means saving the Image to a MemoryStream first. You should also formally decorate your contract type. I would be sending:

    [DataContract]
    public class MyImage
    {
        [DataMember]
        public byte[] Image { get; set; }
        [DataMember]
        public string FullPath { get; set; }
    }
    

    An example of getting the byte[]:

    using(var ms = new MemoryStream()) {
        image.Save(ms, ImageFormat.Bmp);
        return ms.ToArray();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a WCF-REST service with one method which returns a string: [ServiceContract] public
I have the following code in a WCF Service that returns a string, and
My AJAX-enabled WCF service returns JSON using this contract, [DataContract] public class JQGridContract {
I have A WCF service that has a class that inherits System.Web.Security.RoleProvider. In this
I have a WCF service which has one method returning a stream. [ServiceContract] public
I have an Interface for a WCF service public interface IAuthenticationService { void Authenticate(Action<bool,
I have a WCF service that I consume in my code and generated as
I've been tasked with writing a WCF service. (have not done this before.) I've
I have the following code in WCF service to throw a custom fault based
I currently have a WCF service that exposes a SOAP enpoint. In this webservice

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.