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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T20:06:15+00:00 2026-05-13T20:06:15+00:00

When I try to run the following code (two separated assemblies) ClassLibrary.cs public interface

  • 0

When I try to run the following code (two separated assemblies)

ClassLibrary.cs

public interface ITest
{
}

Program.cs

using System;

public class TestClass
{
    public void Test<T>(T x) where T : ITest { }
}

static class Program
{ 
    static void Main(string[] args)         
    {
        new System.Xml.Serialization.XmlSerializer(typeof(TestClass));
    }
}

Compiled in Windows 7 64-Bit using the following commands:

c:\Windows\Microsoft.NET\Framework\v2.0.50727\csc /target:library ClassLibrary.cs

c:\Windows\Microsoft.NET\Framework\v2.0.50727\csc /reference:ClassLibrary.dll Program.cs

I’m getting the this exception:

System.InvalidOperationException: Unable to generate a temporary class
(result=1). error CS0012: The type
ITest is defined in an assembly that
is not referenced. You must add a
reference to assembly ClassLibrary,
Version=0.0.0.0, Culture=neutral,
PublicKeyToken=null hinzu.

at
System.Xml.Serialization.Compiler.Compile(Assembly
parent, String ns,
XmlSerializerCompilerParameters
xmlParameters, Evidence evidence)
at
System.Xml.Serialization.TempAssembly.GenerateAssembly(XmlMapping[]
xmlMappings, Type[] types, String
defaultNamespace, Evidence evidence,
XmlSerializerCompilerParameters
parameters, Assembly assembly,
Hashtable assemblies) at
System.Xml.Serialization.TempAssembly..ctor(XmlMapping[]
xmlMappings, Type[] types, String
defaultNamespace, String location,
Evidence evidence) at
System.Xml.Serialization.XmlSerializer.GenerateTempAssembly(XmlMapping
xmlMapping, Type type, String
defaultNamespace) at
System.Xml.Serialization.XmlSerializer..ctor(Type
type, String defaultNamespace) at
Program.Main(String[] args)

Removing the where T : ITest from TestClass or not using generics at all (e.g. using public void Test(ITest x)) will prevent the exception from being thrown but I need this construct in my real application.

Do anybody understand why the XmlSerializer is unable to handle the where constraint?

  • 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-13T20:06:15+00:00Added an answer on May 13, 2026 at 8:06 pm

    I think you are out of luck. Here’s the response from Microsoft about this issue:

    Thank you for submitting this issue.
    Unfortunately, we have decided that it
    will not be addressed because the risk
    of the fix outweighs its benefit. By
    the time the next opportunity to make
    this change comes about, the hope is
    that the new serialization
    technologies in a future version of
    the Windows Communication Foundation
    will address your scenario. If this
    issue is causing significant negative
    business impact, please contact
    Microsoft Product Support Services. I
    regret that we could not provide a
    better resolution. Rest assured that
    we seriously considered this issue – a
    Won’t Fix decision is never easy to
    make.

    This basically says the you should use DataContractSerializer instead of XmlSerializer or change your object structure.

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

Sidebar

Ask A Question

Stats

  • Questions 323k
  • Answers 323k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer A critical section is a section of code that needs… May 14, 2026 at 1:06 am
  • Editorial Team
    Editorial Team added an answer There is GitPython. Haven’t heard of it before and internally,… May 14, 2026 at 1:06 am
  • Editorial Team
    Editorial Team added an answer Not for the Collection interface, but if you use a… May 14, 2026 at 1:06 am

Related Questions

I'm having an issue with a WCF application that I've written. When both the
In a single script, I need to do the following: create a zip out
I have a set of unit test cases that depend on a test.properties file.
I have a problem when using Jython, but I can't seem to find a
I have a web app where I am calling a SELECT DISTINCT query on

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.