I have a script that creates a directory oath based on two variables. I was trying to troubleshoot it when the script suddenly stopped building.
First, there is a read only variable that provides the directory/folder (User::sPriceListSourceFolder). A second grabs the latest price list file (User::sRecentPriceListFile, read/write). The next step in the SSIS sequence is to use this combination to copy a most recent file based on the previously determined directory to another directory. This process was failing for some reason because it wasn't producing the final /, so the directory and file name weren't separated.
I inserted two message boxes, one for each variable, to test what strings were being passed. I kept getting "There is an error, are you sure you want to build?" which I may have accidentally accepted the first time. I went back and commented out the two message boxes to get rid of the error, but I'm still getting the error. I don't know why this suddenly happened. Any suggestions here given my main? The only changes to this are the two commented out lines. Thanks in advance.
public void Main()
{
var directory = new DirectoryInfo(Dts.Variables["User::sPriceListSourceFolder"].Value.ToString());
/// MessageBox.Show(Dts.Variables["User::sPriceListSourceFolder"].Value.ToString());
FileInfo[] files = directory.GetFiles();
DateTime lastCreated = DateTime.MinValue;
foreach (FileInfo file in files)
{
if (file.CreationTime > lastCreated)
{
lastCreated = file.CreationTime;
Dts.Variables["User::sRecentPriceListFile"].Value = file.ToString();
}
}
/// MessageBox.Show(Dts.Variables["User::sRecentPriceListFile"].Value.ToString());
Dts.TaskResult = (int)ScriptResults.Success;
}
EDIT: I have tried the following: -Restarting the PC -Updating main so it only returns success -Rebuilding and trying to run from within the scripting window.
The final says I have 26 errors?? This is a sample of the output, won't put all 26 here:
System.IO.FileNotFoundException: Could not load file or assembly 'System.Collections.Immutable, Version=1.1.37.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified. ST_4aac98dc09864544a7485d4005384dc9 C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.CSharp.Core.targets
File name: 'System.Collections.Immutable, Version=1.1.37.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' ---> System.IO.FileNotFoundException: Could not load file or assembly 'System.Collections.Immutable, Version=1.1.36.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified. ST_4aac98dc09864544a7485d4005384dc9 C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.CSharp.Core.targets
File name: 'System.Collections.Immutable, Version=1.1.36.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' ---> System.IO.FileNotFoundException: Could not load file or assembly 'file:///C:\Program Files (x86)\MSBuild\14.0\bin\System.Collections.Immutable.dll' or one of its dependencies. The system cannot find the file specified. ST_4aac98dc09864544a7485d4005384dc9 C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.CSharp.Core.targets
File name: 'file:///C:\Program Files (x86)\MSBuild\14.0\bin\System.Collections.Immutable.dll' ST_4aac98dc09864544a7485d4005384dc9 C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.CSharp.Core.targets
at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) ST_4aac98dc09864544a7485d4005384dc9 C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.CSharp.Core.targets
Not sure what happened here, all I did was add a row for a Message box and then comment it out.