I've kicked my head with this one for several days now. I've done a lot of research and have found issues closely related but not specific to my case.
Working on a Visual Studio 2008 SSIS package. Using only one scripting component. In this scripting component, I am serializing a stongly typed class (CCMSModel) and trying to write it out to the server's d:\ drive. I am using .NET 3.5. Works just fine on my development machine but breaks when I deploy it to my SQL Server 2008 R2 (SSIS). I've completely trimmed down my code to remove any added complexity:
[Serializable]
public class CCMSModel
{
public string BOBorEOB { get; set; }
}
...
List<CCMSModel> myList = new List<CCMSModel>();
CCMSModel item = new CCMSModel();
item.BOBorEOB = "Test";
myList.Add(item);
string filePath = "d:\\ScheduleFiles\\6xml\\ss.xml";
var serializer = new XmlSerializer(typeof(List<CCMSModel>));
using (var stream = File.OpenWrite(filePath))
{
serializer.Serialize(stream, myList);
}
...
Want to add that I have sufficient rights to write on the server and I am a sysadmin on the sql server. I also have an another SSIS package using Visual Studio 2012 (SSIS) with .NET 4.0 and deploying to SQL Server 2012. This package is EXACTLY the same (did a copy / paste of the code) and it works just fine.
In my research I found an article that I couldn't help but to see a very close relationship to. Same error and same code. However, this particular scenario is using .NET 4.0 and is deploying or executing in an environment that has .NET 4.0 and 4.5. The article contains a link (at the bottom) claiming to solve the problem (specific to the 4.0/4.5 framework). Claims that the XMLSerialize, in 4.5, is a bit different from the one that runs on my C# compiler hence the incompatibility.
InvalidProgramException with XmlSerializer
Although the article present a close resemblance, this isn't specifically my set up (since I am on 3.5). However, it does allude to the fact that I may be experiencing some incompatiblity with the XMLSerialise implementation. I've hunted down to see if this was the case but I've run dry on my search.
I get an this inner exception error: System.TypeInitializationException: The type initializer for 'Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationWriterList1' threw an exception. ---> System.NullReferenceException: Object reference not set to an instance of an object. at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationWriterList1..cctor()