CIL Generation error for xmlSerializer method x++

Hello All,

i am trying to covert an incoming soap message that is received as an Ojbect type into xml for logging purpose. Actually the feature i am working consumes a web service hosted on biztalk. The service has exposed certain methods. one of which is actually a response message. which actually returns an object type. in order to convert that message into xml, i wrote following method

public str toXML(Object objToXml)

System.Xml.Serialization.XmlSerializer xmlSerializer;
System.IO.StringWriter stringWriter = new System.IO.StringWriter();

xmlSerializer = new System.Xml.Serialization.XmlSerializer(objToXml.GetType());
return stringWriter.ToString();

catch(Exception::Error )
throw Exception::Error;

as you can see method is taking an object type as parameter and returning a string (xml message converted into string) that i am saving into db into a filed of memo type.

everything is working fine . no compile time errors. i am getting the desired result (i.e. xml message is getting stored into db). however when i try to generate CIL, i get error on this line --xmlSerializer.Serialize(stringWriter, ojbToXml). The Error message says ‘Value cannot be Null’. while looking into other forums on net, some folks suggested to delete all the source files and run full compile and and full cil in order to resolve such issues. I tried that , it didnt work. still getting this issue.

can any one shed some light on what could be the potential cause of such issue? I know AIFMessage class has a serialize method where similar sort of task is being performed however i believe mine method is much simpler and is doing what i need , its just give error on CIL. ( i tired both incremental and full CIL)

Please assist .

I think the issue with this line of code, where the CIL generation doesn’t know the type of the objToXML (as it is not initialized during the compile time)

What type really it takes as parameter?

If you know the type, use it directly.

Thanks alot Kranthi for responding to my query and helping me in resolving the issue. Keeping your suggestion into consideration, i tried using a CLRObject type variable to store the service response instead of an Object type. Same type variable passed to the method and the CIL issue got resolved. Thanks again!