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

  • SEARCH
  • Home
  • 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 7088533
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T07:48:45+00:00 2026-05-28T07:48:45+00:00

I am having a problem in MySql.Data.MySqlClient.MySqlTransaction in a Windows Communication Foundation Server Application.

  • 0

I am having a problem in MySql.Data.MySqlClient.MySqlTransaction in a Windows Communication Foundation Server Application.

I am using the MySqlTransaction inside the method of the class that implements the ServiceContract Interface and it throws this error when I try to run the service:

System.Runtime.Serialization.InvalidDataContractException: Type ‘MySql.Data.MySqlClient.MySqlTransaction’ cannot be serialized. Consider marking it with the DataContractAttribute attribute, and marking all of its members you want serialized with the DataMemberAttribute attribute. If the type is a collection, consider marking it with the CollectionDataContractAttribute.

My code in WCF service was simmilar to this:

[ServiceContract]
public interface IDALService
{
    MySqlCommand Command { [OperationContract] get; [OperationContract] set; }

    [OperationContract]
    void Execute(string cmdText);
}

[ServiceBehavior(IncludeExceptionDetailInFaults = true)]
public class DALService : IDALService
{
    public MySqlCommand Command { get; set; }

    public DALService()
    {
        Command = null;
    }

    public void Execute(string cmdText)
    {
        MySqlCommand SQLCom = this.Command??new MySqlCommand();
        SQLCom.CommandText = cmdText;

        if (this.Command == null)
        {
            SQLCom.CommandType = CommandType.Text;
            SQLCom.Connection = new MySqlConnection(/* ... */);
            SQLCom.Connection.Open();
            SQLCom.Transaction = SQLCom.Connection.BeginTransaction();
        }

        if (this.Command == null)
        {
            try
            {
                SQLCom.ExecuteScalar();
                SQLCom.Transaction.Commit();
            }
            catch { SQLCom.Transaction.Rollback(); throw; }
            finally { SQLCom.Connection.Close(); }
        }
        else SQLCom.ExecuteScalar();
    }
}

The error occur just by typing the http://localhost:1257/DALService.svc in my web browser.

I am using Framework 4, code in C#, in Microsoft 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-28T07:48:46+00:00Added an answer on May 28, 2026 at 7:48 am

    This can’t be the code that’s causing an issue. The error you are getting is coming from an attempt to return or pass in a MySqlTransaction to/from the service. That’s just simply not going to work.

    Also, why on earth are you exposing a Command object to the outside world via a public property? Furthermore, it doesn’t even appear that you use it… Delete that property and keep your command scoped to the method that uses it. If you don’t and you run this service as a singleton, you’ll get lots of crazy bugs.

    Even furthermore… This is an extremely dangerous service to expose. If you were to have someone use it other than yourself, it provides zero encapsulation. Heck, you might as well just open up a port directly to the SQL Server, as dumb as that sounds.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Spent some time troubleshooting a problem whereby a PHP/MySQL web application was having problems
I'm having trouble loading the mysql data to the option box using php. Here's
So im having a problem (obviously). I have the following MySQL table data 7
I am having a problem with PHP from that adds data to MYSQL database
I'm having what seems to be a concurrency problem while using MySQL and PHP
Ive been having some problems with understanding the MySql reader from MySql.Data.MySqlClient This is
I am having a problem retrieveing information from a MySQL Data Base. Could you
I am having problem with $_GET array. More precisely I'm retrieving data from mysql
I am having a problem with a website, connecting to a MySQL database using
I am trying to learn mysql and having some problem with updating/adding data to

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.