Question: Base class

```
class Base
{
public:
    Base()=default;
    virtual void f(){cout << "base class\n";}
    virtual ~Base(){}
};

```

Derived class

```
class Derive : public Base
{
public:
    Derive()=default;
    void f() override {cout << "derived class\n";}
};

```

main function

```
int main()
{
    Base* bsd = new Base;
    Derive* dru = new Derive;

    if(Derive* drd=dynamic_cast<Derive*>(bsd)){
        drd->f();
        cout << "downcast successful\n";
    }else{
        cout << "downcast failed\n";
    }

    if(Base* bsu=dynamic_cast<Base*>(dru)){
        bsu->f();
        cout << "upcast successful\n";
    }else{
        cout << "upcast failed\n";
    }

    delete bsd;
    delete dru;
}

```

It turns out upcast works fine, while downcast failed. It seems makes sense that way. If the derived class contain member objects that are not declared in the base class and do not have default constructors, what gonna happen during downcast? 

Besides, the target pointer `*drd(*bsd)` created through `dynamic_cast` points to the same object with the pointer `*bsu(*dru)` to be cast. So delete once will be enough. We will not have a dangling pointer, right?

Answer: 
`WSHttpBinding x = new WSHttpBinding();` creates a new instance of `WSHttpBinding` with the framework default values. Even though you have a default binding configuration defined in the configuration file, it is not being used by your code (See [WSHttpBinding.cs](http://referencesource.microsoft.com/#System.ServiceModel/System/ServiceModel/WSHttpBinding.cs,f7fc87f3e3324962) for the source code). In other words, calling the parameterless constructor of `WSHttpBinding` does not apply the default binding from any associated config files, at least that I could see.

You have a couple of options here. First, give a name for the binding configuration in your config file and reference that. Second, assign the values to the `XmlDictionaryReaderQuotas` when you create the binding programatically.

Option 1

```
<bindings>
  <wsHttpBinding>
    <binding name="MyBinding">
      <readerQuotas maxNameTableCharCount="2147483647" />
    </binding>
  </wsHttpBinding>
</bindings>

WSHttpBinding x = new WSHttpBinding("MyBinding");

```

Option 2

```
WSHttpBinding x = new WSHttpBinding();
x.ReaderQuotas rq = new XmlDictionaryReaderQuotas();
rq.MaxNameTableCharCount = Int32.MaxValue;

```
Did you try this link <https://social.msdn.microsoft.com/Forums/vstudio/en-US/17592561-c470-452a-a52c-2a5a2839582c/metadataexchangeclient-and-nametable-character-count-quota?forum=wcf>

> 
> this is a bug in our code (the binding you pass is ignored for
>  HTTP-GET). There are a few workarounds
> 
> 
> can you see if any of them will work for you?
> 
> 
> * Is the service a WCF service? If so, can you enable a mex endpoint on the service? The binding will be used work for the mex endpoint.
>  Can
> * you use the Discovery protocol(<http://msdn2.microsoft.com/en-us/library/system.web.services.discovery.discoveryclientprotocol.aspx>)
>  to get the metadata from your service? The XML readers used by this  
> 
>  class don’t have any quotas.
> 
> 
>