I am trying to interoperate between legacy Visual C code and a brand-new .NIET-DONT-ASK API. The legacy calls API using COM (it should use SOAP, but SOAP got poison pill and died - I mentioned it in Programming forum).
So, I have a C# stub file generated for me from the Web interface. Attempt to export it to COM - no luck. Apparently, you have to specify an "attribute" to make it exportable. Of course, the "attributes" are syntactical constructs. If the writer of WSDL-to-C# translator did not think to add the frigging attribute to the generated classes, I am outta luck.
Round 2. Wrap the main API class in my own C# interface, this one marked with proper "attribute". In addition to the main class, I have a struct that gets passed to one of the methods. Like this:
\n\n/// <remarks/>\n[System.Xml.Serialization.XmlTypeAttribute(Namespace="[link|http://tempuri.org/|http://tempuri.org/]")]\n public class ForwardeeInfo {\n \n /// <remarks/>\n public string ForwardeeName;\n }\n
Note the stuff in [] - this is an attribute that tells SOAP marshaler how to marshal it.
So, to make this available to COM, I derive from the structure, like this:
\n [ClassInterfaceAttribute(ClassInterfaceType.AutoDual)]\n public class ForwardeeInfoExported : ForwardeeInfo {\n };\n
The attribute above tells the COM exporter to include this class.
And then I make a call to method that wants this structure:
\n\n public System.Guid Setup(ForwardeeInfoExported forwardeeInfo) {\n return connector.Setup(forwardeeInfo);\n }\n\n\n
I get an exception telling me that SOAP marshaller can't produce the XML.
After 4 hours wasted, in desperation, I change the code to
\n ForwardeeInfo forwardeeInfoReal = new ForwardeeInfo();\n forwardeeInfoReal.ForwardeeName = forwardeeInfo.ForwardeeName;\n return connector.Setup(forwardeeInfoReal);\n
This works!
The fucking piece of sorry crap can't figure out the XML marshalling if it's specified in base class! If this is the future of computing, I need an honest job, ASAP. And to think that MS stole the author of Delphy from Borland to write this shining ingot of Ineptium! I guess the brain softening is inevitable in Redmond.