Dynamic web service proxies need to be loaded from disk
In our application we generate web service proxies at runtime itself using something similar to this. Initially we were generating the assembly in memory by using ICodeCompiler interface and setting CompilerParameters.GenerateInMemory to true. This works fine but throws an exception when you try to invoke a web service, the message of the exception goes something like “Unable to generate a serializer for type
It turns out that for use with XmlSerializer the assembly needs to be loaded from disk! So now we write the assembly to disk, load it using Assembly.LoadFrom() and invoke the web service using reflection. Works like a charm 🙂