Execute SSIS Package Using ASP.Net - c#

Description Of Environment
I have an SSIS task which executes from asp.net, the package gets data from excel files over UNC path and puts the data into a sql server databaase . I have deployed the SSIS to file system, it has windows authentication database connections and the IIS user has database access. I can log in as the AppPoolUser I have used to host the web application and open/modify the files in question so those basic permissions are there. Web App is compiled in x86.
When it works:
When run from Visual Studio (ctrl + shift + W) it works fine and every thing is done succefuly.
When it doesn't work:
When run from client browser. it upload the file but fail in the package.
My Question
What is different about the client and server and how do I make it work? I was under the impression that when running the web app all connections go through the AppPool User so it should behave the same on any machine server included? i need to do so without the need of CMD.
c# Code running SSIS Package
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Microsoft.SqlServer.Dts.Runtime;
public partial class Pages_Quality : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Upload_Click(object sender, EventArgs e)
{
if (FileUpload1.HasFile)
{
string fileExt =
System.IO.Path.GetExtension(FileUpload1.FileName);
if (FileUpload1.FileName == "Breached.xlsx")
{
try
{
FileUpload1.SaveAs("*:\\***\\***\\" +
FileUpload1.FileName);
Label1.Text = "Upload Done";
Application app = new Application();
Package package = app.LoadPackage(#"*:\**\**\Quality.dtsx", null);
DTSExecResult result = package.Execute();
Label2.Text = (result.ToString());
}
catch (Exception ex)
{
Label1.Text = "ERROR: " + ex.Message.ToString();
}
}
else
{
Label1.Text = "Only Breached.xls is allowed!";
}
}
else
{
Label1.Text = "You have not specified a file.";
}
}
}

Do you have SSIS service or SSIS Component (Client Tools) installed in the machine (web server in your case) where you are deploying and running your application from?
You may have bids in the same development PC where you have Visual Studio to develop and debug your application application. Usually the SSIS component is installed along with BIDs so you do not need SSIS service to run the package. This might be the case where your package execution is fine in you development PC. However it will never work in your web server because you do not have these components installed in your web server.
Hope this will help you.
Regards,
Sandip

If you are using Excel source connection, most probably the error happened because the excel driver work under 32 bit mode only, while when you try to call it from web, it's execute under 64 bit.
Check that.
Regards

Related

Windows Server 2016 C# Launched process window is blank and unusable

I am running an automated test using C# and Coded UI Tests on Window Server 2016. I am using the process.start method to launch an installer but when the test launches the installer, the window is blank and cannot be used either by the test or manually.
This does not happen when I launch the installer manually (works fine) or on any other OS (only happens on Server 2016).
Everything is running as admin. I have updated windows itself and video drivers.
Here is the code used to launch the installer:
public void LaunchUnifiedDashboardInstaller(bool upgrade = false)
{
string pathtoInstaller = "";
// Get path to installer
if (upgrade == false)
{
pathtoInstaller = TestRunSettings.TestSetting.GetPathToInstallers();
}
else if (upgrade == true)
{
pathtoInstaller = TestRunSettings.TestSetting.GetPathToUpgradeInstaller();
}
//string pathtoInstaller = #"E:\";
Console.WriteLine("LaunchUnifiedDashboardInstaller() - Path to installer is: " + pathtoInstaller);
TestReport.WriteText("Launching Unified Dashboard setup .... ");
//Server Installer
System.Diagnostics.ProcessStartInfo proc = new System.Diagnostics.ProcessStartInfo(pathtoInstaller + #"\setup.exe");
//proc.UseShellExecute = true;
//proc.Verb = "runas";
System.Diagnostics.Process.Start(proc);
TestReport.WriteText("Launching Unified Dashboard setup .... ");
}
screenshot of blank windows
This one has me totally stumped. Has anyone seen this before?
Thanks
Richard
Fixed it. Sort of.
This was happening using Server 2016 with all the available updates applied.
So I went back to the base original release of Server 2016 (from 2016) and turned off Windows update. Lo and behold, it now works fine. Something in a newer Windows version must have disagreed with Coded UI.

Access to path denied - IIS express - upload file -Windows 8.1

I know this error maybe very popular and there are many people asking about it. I have read through other threads but can not seem to find a solution applicable to my scenario.
I am new to ASP.NET programming, am using vs 2013 ultimate, IIS express on my laptop with Windows 8.1.
I have created a new website using WebForms and I was testing the upload function to my local machine running IIS express that came with VS2013.
My code behind is as simple as
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class MyWebForm : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (IsPostBack)
{
string name = TextBox1.Text;
string type = DropDownList1.SelectedValue;
string filename = FileUpload1.FileName;
FileUpload1.SaveAs(Server.MapPath("~/Content"));
}
}
}
Ran it and got this error:
{"Access to the path 'C:\\Users\\xxx\\Documents\\Visual Studio 2013\\WebSites\\WebFormDemo\\Content' is denied."}
I understand that it is an unauthorized access due to lack of privilege, but my question is how do I give access to my application? I have admin right on my machine, run it locally so the firewall should not be an issue. Some threads suggested to go to IIS manager and adjust the right to DefaultPool but I do not think I have InetMgr on my Windows 8.1,
How do I solve the unauthorized access for my case?

SQlite using statement gives Unable to load DLL 'SQLite.Interop.dll' error on another computer

This is the code that I wrote for database connection:
private static void OnTimedEvent(Object source, ElapsedEventArgs e)
{
using (SQLiteConnection con = new SQLiteConnection(connectionString))
{
try
{
con.Open();
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}
if (con.State == System.Data.ConnectionState.Open)
{
Console.WriteLine("Database Opened");
ushort[] writeData = new ushort[10];
writeData = parseList(byteList);
if (writeData != errorBytes)
{
writeToDb(con, writeData);
}
else
{
Console.WriteLine("Error Bytes returned! BROKEN DATA!!!");
}
//con.Close();
}
else
{
Console.WriteLine("Can't open the database!");
}
}
}`
When I run the program on the computer that I wrote the code it works properly and opens the database. However when I run my program in another computer code doesn't go into using statement and gives the exception SQLite.Interop.dll not found. I added the System.Data.SQLite.dll to my project's references. Also I have this dll file in the other computer. Do I need to add anything to the other computer to make this program work properly?
I figured it out that the problem was about SQLite dlls. When I installed the System.Data.SQLite library from NuGet Package Manager and set the platform target as x86 problem resolved. Although platform target was x86 before I asked this question but re-installing the library from NuGet Package Manager solved my problem. Before that I was using the dlls I downloaded from the http://system.data.sqlite.org/index.html/doc/trunk/www/downloads.wiki as reference to my project.
Try to check the connectionString, the location of the SQLite file,.. Maybe you are trying to create it somewhere where your program is not allowed to write on the other computer. Try to run your app as administrator if there is a difference. The only thing that came on my mind is that it crashes at the moment of creating the connection and therefore it is not going into the using statement.

Running SSIS Package from WinForms app - Gnarly Error

I have a winforms application that makes use of Microsoft.SqlServer.ManagedDTS to load and execute an SSIS package. When running locally in debug and when installed the package runs fine, when installed on a dev server the package runs fine. When deployed onto a live server I get the following error.
I'm running out of ideas of what to check, I don't want to move away from using this method of executing my package as this adds further complication to the application that we really don't want to introduce. Any thoughts?
For clarity I have checked:
SSIS is installed and is the same version (Windows/SQL Server 2008)
I added the following app.config key following some google searching useLegacyV2RuntimeActivationPolicy="true"
Tried compiling as a 32-bit and 64-bit application
Ensured that the DLL is registered in the GAC on the target machine
All permissions are the same across the two boxes
The extract of source code that is throwing the error is as follows:
var app = new Microsoft.SqlServer.Dts.Runtime.Application();
var pkg = app.LoadPackage(strSSISPath, null);
pkg.ImportConfigurationFile(strSSISConfig);
var result = pkg.Execute();
if (result.Equals(DTSExecResult.Success))
{
string strMsg = strMHType + " extract completed successfully.";
MessageBox.Show(strMsg, strMHType, MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else
{
foreach (var err in pkgMHMDS.Errors)
{
MessageBox.Show(err.Description, strMHType, MessageBoxButtons.OK, MessageBoxIcon.Error);
}
MessageBox.Show(strMHType + #" extract failed!", strMHType, MessageBoxButtons.OK, MessageBoxIcon.Error);
}
pkgMHMDS.Dispose();
The error that we see (the COM class error) is caused because the version of the Microsoft.SqlServer.ManagedDTS dll is not installed on the target machine. Whilst we did install the dll into the GAC we couldn’t work round the error because Integration Services is a server component and is not redistributable to client computers. The error isn’t terribly informative but essentially what it is trying to say is that it is trying to load an assembly who’s address is stored in the registry key which is created when installing the Client Tools SDK.

InstallShield generated shortcut alters program directory? c#

I have program that reads code from a .bin file stored the same directory as the main executable and .dll.
So, the program works completely fine, unless I install it with InstallShield and have shortcuts automatically created. If I open the program via any shortcut, I get an error saying that:
"options.bin" could not be found in "directory where the shortcut is currently located"
however, if I open the .exe directly then i don't get any errors and the program runs perfectly. Also, if i create my own shortcut manually after installation (with a target directory rather than a clsid), then the program will function perfectly.
here is the code that opens "options.bin":
private void btnReadFile_Click(object sender, EventArgs e)
{
try
{
byte[] prog;
using (BinaryReader reader = new BinaryReader(File.Open("options.bin", FileMode.Open)))
{
prog = reader.ReadBytes(6 + 4 * 12 + 2);
}
updateProduct(ProductOptions.createFromBytes(prog));
}
catch (Exception ex)
{
MessageBox.Show("Failed to read from 'options.bin': " + ex.Message);
}
}
why do the shortcuts created during the installation cause my program to look for the "options.bin" in the directory where the shortcut is? How can i create a shortcut at time of installation that won't cause this problem?
(oh, and i'm using Visual Studio 2012, which doesn't include any setup option, which is why i'm using installshield)

Categories

Resources