I have upgraded SSIS package from SQL Server 2016 to SQL Server 2019. I am getting below error while calling host.CurrentScriptingEngine.LoadProjectFromStorage() as well as host.SaveScriptProject() from script task. It's not able to load it and save it. What needs to be done to make it work?
Code:
private void RecompileScriptSource()
{
IDTSComponentMetaData100 srcComp = m_Pipeline.ComponentMetaDataCollection[BASE_SCRIPT_SOURCE_COMPONENT];
// Get design time instance of script source
CManagedComponentWrapper scriptSourceWrapper = srcComp.Instantiate();
// Get script host & save
try
{
ScriptComponentHost host = (scriptSourceWrapper as IDTSManagedComponent100).InnerObject as ScriptComponentHost;
if (host == null)
{
throw new Exception("Failed to get access to the host object for the script component.");
}
log(host.ProjectTemplatePath+"-----"); //testing or debugging purpose
if (!host.LoadScriptFromComponent()) // This returns false
{
throw new Exception("Failed to load script information from component.");
}
VSTAComponentScriptingEngine engine = host.CurrentScriptingEngine;
if (engine.VstaHelper == null)
{
throw new Exception("Vsta 3.0 is not installed properly");
}
// Facing error here
if (!host.CurrentScriptingEngine.LoadProjectFromStorage())
{
throw new Exception("Failed to load project files from storage object");
}
if (!host.SaveScriptProject())
{
throw new Exception("Failed to save project");
}
else
{
log("Saved script project");
}
engine.DisposeVstaHelper();
}
finally
{
log("Finished saving (or compiling or whatever");
}
}
Related
I have an UWP application, In that I need to run the MSI file on the button click.
I don't think UWP will support "process.start(filename)". Is it possible in UWP to achieve this?.
The UWP cant open MSI.
But uwp can open the other type file.
You can use Launcher.
Pick the msi that you want run.
Run msi by launcher file.
The result is always failed.
private async void ButtonBase_OnClick(object sender, RoutedEventArgs e)
{
//pick msi file
FileOpenPicker pick = new FileOpenPicker();
pick.FileTypeFilter.Add(".msi");
StorageFile file = await pick.PickSingleFileAsync();
//run
bool result = await Launcher.LaunchFileAsync(file);
if (result)
{
//success
}
}
But you will see the result is false ,because Many file types that contain executable code, for example .exe, .msi, and .js files, are blocked from launching
You can open the folder and make the use to click the msi file.The code is:
private async void ButtonBase_OnClick(object sender, RoutedEventArgs e)
{
//pick msi file
var pick = new FileOpenPicker();
pick.FileTypeFilter.Add(".msi");
var file = await pick.PickSingleFileAsync();
//run
var result = await Launcher.LaunchFileAsync(file, new LauncherOptions
{
TreatAsUntrusted = true,
DisplayApplicationPicker = true
});
if (result)
{
//success
}
else
{
//alway failed
var folder = await file.GetParentAsync();
if (folder != null)
{
await Launcher.LaunchFolderAsync(
folder, //if you can get the file's parent
new FolderLauncherOptions
{
ItemsToSelect = {file}
});
}
}
}
See:Windows Store App running .msi installer
https://msdn.microsoft.com/en-us/library/windows/apps/hh701471.aspx?f=255&MSPPError=-2147217396
I have an wp8 app using PeriodicTask background Agent.
The task update the information of multiple live tiles,
using POST Client to get title and image url from my server to update the live tile.
Background agent works just fine in debugging and releasing mode. When the .xap file was deployed into my device using XAPDeployement tool, the background Agent also works perfectly.
However, it won't work after submitted to wp app store, no matter it's beta version or not.
If the app is downloaded from store, the background agent has never worked, and it is blocked by system after a few minutes.
How come it goes wrong since the XAP files are the same?
part of code:
public static Task<string> jsonPostClientTask(Dictionary<string, object> parameters, string url)
{
var results = new TaskCompletionSource<string>();
PostClient proxy = new PostClient(parameters);
try
{
proxy.DownloadStringCompleted += (sender, e) =>
{
if (e.Error == null)
{
string response = e.Result.ToString();
results.TrySetResult(response);
}
else
{
results.TrySetResult("");
results.TrySetException(e.Error);
}
};
proxy.DownloadStringAsync(new Uri(url));
}
catch
{
results.TrySetResult("");
}
return results.Task;
}
ScheduledAgent class:
protected override void OnInvoke(ScheduledTask task)
{
foreach (var tile in tileList)
{
string dataString = jsonPostClientTask(parameters, url);
//update tile in used
FlipTileData tileData = new FlipTileData()
{
BackContent = "string content",
WideBackContent = "string back content",
BackBackgroundImage = new Uri("http://xxxx.xxx/xxx.png", UriKind.RelativeOrAbsolute),
WideBackBackgroundImage = new Uri("http://xxxx.xxx/xxx.png", UriKind.RelativeOrAbsolute),
};
ShellTile primaryTile = ShellTile.ActiveTiles.First();
if (primaryTile != null)
primaryTile.Update(tileData);
}
}
I have a simple SSIS package with a single script task on it. I have an OnError event with a Send Mail task.
All i'm doing is testing to see if i can send an email when i detect an error withing my script.
However the variable i use to hold the Error message for my email causes an error.
"A deadlock was detected while trying to lock variable "User::errMsg" for read access. "
Here is the very simple script
public void Main()
{
try
{
int x = 2;
if (x ==2)
{
throw new Exception("The number was 2");
}
Dts.TaskResult = (int)ScriptResults.Success;
}
catch(Exception e)
{
Dts.Variables["errMsg"].Value = e.Message;
Dts.Events.FireError(-1, "here", "my error", "", 0);
Dts.TaskResult = (int)ScriptResults.Failure;
}
How can i pass a message to my send email when an error occurs in my script task ?
SSIS variables are locked and are relased only in its Post Execute event .In your case errMsg variable gets locked by the script task and the same time the variable is accessed in On Error event by the SendMail component creating a deadlock situation .You need to specifically unlock the variable before it is accessed by other components during its execution phase.
Try this :-
catch (Exception e)
{
Variables lockedVariables = null;
Dts.VariableDispenser.LockOneForWrite("errMsg", ref lockedVariables);
lockedVariables["errMsg"].Value = e.Message;
lockedVariables.Unlock();
Dts.Events.FireError(-1, "here", "my error", "", 0);
Dts.TaskResult = (int)ScriptResults.Failure;
}
This will ensure that before the error occurs ,the variable is unlocked and can be accessed in execution events such as On Error or OnExecStatusChanged.
More on how to handle these type of deadlocks is explained by Todd McDermid in his blog
In web app development I would like a consistent way to catch and report error conditions. For example, a database update routine may detect a variety of error conditions and ideally I would like the application to capture them and report gracefully. The code below din't work because retdiag is undefined when error is thrown...
function saveData(app,e) {
var db ;
var retdiag = "";
var lock = LockService.getPublicLock();
lock.waitLock(30000);
try {
// e.parameters has all the data fields from form
// re obtain the data to be updated
db = databaseLib.getDb();
var result = db.query({table: 'serviceUser',"idx":e.parameter.id});
if (result.getSize() !== 1) {
throw ("DB error - service user " + e.parameter.id);
}
//should be one & only one
retdiag = 'Save Data Finished Ok';
}
catch (ex) {
retdiag= ex.message // undefined!
}
finally {
lock.releaseLock();
return retdiag;
}
}
Is there a good or best practice for this is GAS?
To have a full error object, with message and stacktrace you have to build one, and not just throw a string. e.g. throw new Error("DB error ...");
Now, a more "consistent" way I usually implement is to wrap all my client-side calls into a function that will treat any errors for me. e.g.
function wrapper_(f,args) {
try {
return f.apply(this,args);
} catch(err) {
;//log error here or send an email to yourself, etc
throw err.message || err; //re-throw the message, so the client-side knows an error happend
}
}
//real client side called functions get wrapped like this (just examples)
function fileSelected(file,type) { return wrapper_(fileSelected_,[file,type]); }
function loadSettings(id) { return wrapper_(loadSettings_,[id]); }
function fileSelected_(file,type) {
; //do your thing
}
function loadSettings_(id) {
; //just examples
throw new Error("DB error ...");
}
i have used this code to get camera access how i can load it on page load
private function startVideo():void
{
if (true) // TODO: Recognize no video settings
{
var camera:Camera = Camera.getCamera(cameraIndex.toString());
if (camera)
{
vidMe.attachCamera(camera);
if (outgoingStream)
{
outgoingStream.attachCamera(camera);
}
}
}
else
{
vidMe.attachCamera(null);
if (outgoingStream)
{
outgoingStream.attachCamera(null);
}
}
}
Flash shows the camera request dialog the first time you call attachCamera(). To have a user be asked upfront, before your flash application reaches any functionality, I would suggest adding it upfront in our constructor.
This dummy function puts together a fake NetConnection, and connects it to no server. Going through this upfront will present a user with the camera use dialog while your flash application is loading, thus happening on page refresh or initial load.
private function ensurePermissions() : void {
var unusedNetConnection : NetConnection = new NetConnection()
unusedNetConnection.connect( null );
var ensureCamPermissions : NetStream = new NetStream( unusedNetConnection );
ensureCamPermissions.attachCamera( myCamera );
try {
ensureCamPermissions.close();
unusedNetConnection.close();
} catch( error:Error ) {
// Ignore any errors here
} finally {
ensureCamPermissions = null;
unusedNetConnection = null;
}
}