KnownType Not sufficient for Inclusion

Posted by Kate at LittleCollie on Programmers See other posts from Programmers or by Kate at LittleCollie
Published on 2013-10-30T14:53:54Z Indexed on 2013/10/30 16:11 UTC
Read the original article Hit count: 454

Why isn't the use of KnownType attribute in C# sufficient for inclusion of a DLL? Working with Visual Studio 2012 with TFS responsible for builds, I am on a project in which a service required use of this attribute as in the following:

using Project.That.Contains.RequiredClassName;

[ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall, Namespace="SomeNamespace")]
[KnownType(typeof(RequiredClassName))]
public class Service : IService { }

But to get the required DLL to be included in the bin output and therefore the installer from our production build, I had to add the follow to the constructor for Service:

public Service() { 
    // Exists only to force inclusion
    var ignore = new RequiredClassName();
}

So, given that the project that contains RequiredClassName is itself referenced by the project that contains Service, why isn't the use of the KnownType attribute sufficient for inclusion of DLL in the output?

© Programmers or respective owner

Related posts about c#

Related posts about .NET