views:

846

answers:

2

I am developing WCF service hosted by IIS. I need to add KnownType attribute to my base class. One way of adding KnownType attribute is to add a section into the Web.config file like this:

<system.runtime.serialization>
<dataContractSerializer>
  <declaredTypes>
    <add type="MyBase, MyBaseDll">
      <knownType type="MyDerived, MyDerivedDll"/>
    </add>
  </declaredTypes>
</dataContractSerializer>
</system.runtime.serialization>

But I got error message when my mouse is over the MyBase. The Error message is “Invalid Module Qualification: Failed to resolving assembly MyBaseDll”. Same error message for MyDerivedDll.

Additional information:
Both MyBaseDLL.dll and MyDerivedDLL.dll are in the IIS /bin folder. Both DLLs reference no other assembly other than .net system assemblies

A: 

What happens when you run the service? The error message could be bogus. For instance, ReSharper sometimes gets confused about assembly references in config files.

OTOH, other times, it's correct.

John Saunders
Thanks for the reply. The original design of the solution for the WCF server hosted by IIS is to keep the /bin folder light, and most of the dlls are in the extended dll folder, which is specified in the web.config file. I copied the required dll to the /bin folder when I see the error message. Instead I should reference the required dll from project setting. My immediate issue is solved, but how do I reference a dll that is in the extended dll folder if the original design has to be kept.
What extended bin folder? How did you do this?
John Saunders
+1  A: 

Have you tried giving the full name of the assemblies and full name of the types (namespaces and all) ...

<add type="MyNamespace.MyBase, 
           MyBaseDLL, Version=v.v.v.v, Culture=neutral,
           PublicKeyToken=XXXXXX">
           <knownType type="MyNamespace.MyDerived, 
                      MyDerivedDLL, Version=v.v.v.v, Culture=neutral,
                      PublicKeyToken=XXXXXX"/>
</add>
JP Alioto