|
So what happened when you followed the very clear and detailed troubleshooting instructions in the error message?
Or the instructions in the linked page? vsts-tasks/README.md at master · Microsoft/vsts-tasks · GitHub[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Hi,
I have a console Application (AppA) which is calling another Console Application (AppV) with Elevated rights, problem is when I run the first Application AppA its opening many Consoles of AppB without limit continuously.
Here is my Code, any advice is going to be very helpful, thanks in advance.
class Program
{
public static int ERROR_CANCELLED { get; private set; }
private static bool IsRunAsAdmin()
{
WindowsIdentity id = WindowsIdentity.GetCurrent();
WindowsPrincipal principal = new WindowsPrincipal(id);
return principal.IsInRole(WindowsBuiltInRole.Administrator);
}
static void Main(string[] args)
{
if (!IsRunAsAdmin())
{
ProcessStartInfo proc = new ProcessStartInfo(@"C:\Personal Docs\FileWatcherBackups\20170221\FileWatcher\FileWatcherScheduleApp\bin\Release\FileWatcherScheduleApp.exe");
proc.UseShellExecute = true;
proc.WorkingDirectory = Environment.CurrentDirectory;
proc.FileName = Assembly.GetEntryAssembly().CodeBase;
proc.WindowStyle = ProcessWindowStyle.Normal;
//proc.FileName = myExePath;
proc.CreateNoWindow = false;
//proc.UseShellExecute = false;
proc.Verb = "runas";
try
{
Process.Start(proc);
}
catch (Win32Exception ex)
{
if (ex.NativeErrorCode == ERROR_CANCELLED)
{ }
else
{ }
}
catch
{
Console.WriteLine("This application requires elevated credentials in order to operate correctly!");
}
Application.Exit();
}
}
}
Where am I going wrong, is there any way I can control the calling of AppB from AppA here?
Thanks,
Abdul Aleem
"There is already enough hatred in the world lets spread love, compassion and affection."
|
|
|
|
|
That code will only make a single attempt to launch AppB.exe. So whatever your using to launch AppA.exe is what's causing this problem.
Also, that "Application.Exit()" is not required at all.
|
|
|
|
|
All I am doing is either running the AppA.exe from Visual Studio or right clicking the AppA.exe and saying run as an Administrator or just saying Run, in both the cases its ending up opening unlimited number of Consoles of AppB.exe.
Thanks,
Abdul Aleem
"There is already enough hatred in the world lets spread love, compassion and affection."
|
|
|
|
|
Ummm.... most of the options you're setting in the ProcessStartInfo object are the default values. The only things you're actually changing are Filename (more on this in a second) and Verb. Everything else you're setting the values to their default values. You're really not changing anything there.
The Filename you're changing is your problem. The Assembly.GetEntryAssembly().CodeBase returns the fill filepath TO YOUR APPA.EXE LAUNCHER!! You're Launcher is relaunching itself and then quitting. A simple trip through the debugger would have told you that!
YOU NEVER LAUNCH APPB.EXE!
modified 8-May-17 10:33am.
|
|
|
|
|
Thanks Dave, I would definitely follow it up, thanks again man.
Thanks,
Abdul Aleem
"There is already enough hatred in the world lets spread love, compassion and affection."
|
|
|
|
|
Hello to all,
I'm writing an application using C# in VisualStudio 2008 for Windows Embedded Compact 7 operating system, that is a SmartDevice application.
I have a Form and a UserControl.
In the Form load event I create a UserControl instance and I put it in the form:
private void Form1_Load(object sender, EventArgs e)
{
UserControl1 uc1 = new UserControl1();
uc1.Parent = this;
uc1.Location = new Point(607, 350);
}
This works.
I want also to write a string in the UserControl from Form1.
I tried writing the following function in the UserControl:
public void SetText(String testo)
{
Graphics gr;
PaintEventArgs e;
gr = CreateGraphics();
Font f = new Font("Tahoma", 14, FontStyle.Bold);
e = new PaintEventArgs(gr, ClientRectangle);
SolidBrush br = new SolidBrush(System.Drawing.SystemColors.ControlText);
StringFormat sf = new StringFormat();
sf.Alignment = StringAlignment.Center;
Rectangle centered = e.ClipRectangle;
centered.Offset(0, (int)(e.ClipRectangle.Height - e.Graphics.MeasureString(testo, f).Height) / 2);
e.Graphics.DrawString(testo, f, br, centered, sf);
}
and I called it from Form1:
private void Form1_Load(object sender, EventArgs e)
{
UserControl1 uc1 = new UserControl1();
uc1.Parent = this;
uc1.Location = new Point(607, 350);
uc1.SetText("1");
}
but it doesn't work, it writes nothing without errors.
So I modified the function in the UserControl in this way:
public void SetText(String testo, PaintEventArgs e)
{
Graphics gr;
gr = CreateGraphics();
Font f = new Font("Tahoma", 14, FontStyle.Bold);
SolidBrush br = new SolidBrush(System.Drawing.SystemColors.ControlText);
StringFormat sf = new StringFormat();
sf.Alignment = StringAlignment.Center;
Rectangle centered = e.ClipRectangle;
centered.Offset(0, (int)(e.ClipRectangle.Height - e.Graphics.MeasureString(testo, f).Height) / 2);
e.Graphics.DrawString(testo, f, br, centered, sf);
}
and I called it in this way:
private void Form1_Load(object sender, EventArgs e)
{
UserControl1 uc1 = new UserControl1();
uc1.Parent = this;
uc1.Location = new Point(607, 350);
PaintEventArgs ea;
Graphics gr;
gr = CreateGraphics();
ea = new PaintEventArgs(gr, uc1.ClientRectangle);
uc1.SetText("1", ea);
}
still doesn't work without errors.
If I use the same code in the UserControl Paint event it works:
private void UserControl1_Paint(object sender, PaintEventArgs e)
{
Font f = new Font("Tahoma", 14, FontStyle.Bold);
string s = "1";
SolidBrush br = new SolidBrush(System.Drawing.SystemColors.ControlText);
StringFormat sf = new StringFormat();
sf.Alignment = StringAlignment.Center;
Rectangle centered = e.ClipRectangle;
centered.Offset(0, (int)(e.ClipRectangle.Height - e.Graphics.MeasureString(s, f).Height) / 2);
e.Graphics.DrawString(s, f, br, centered, sf);
}
It works also if I call the SetText function from the UserControl Paint Event:
private void UserControl1_Paint(object sender, PaintEventArgs e)
{
SetText("1");
}
or:
private void UserControl1_Paint(object sender, PaintEventArgs e)
{
SetText("1",e);
}
I think the problem could be in the PaintEventArgs: when I work inside the UserControl Paint event I have the "right" PaintEventArgs objec, when I try to write my string from Form1 I'm not able to point to the "right" PaintEventArgs.
Obviously my suspicion can be wrong.
I don't know how to solve this problem, someone can help me?
Thanks in advance.
|
|
|
|
|
You do NOT put the Graphics and Drawing code in SetText. That goes in the Paint event of your UserControl.
SetText should only set a private field that contains the text to paint and then call Invalidate on itself to get the control to repaint itself.
Your code also leaks resources badly. You're not calling Dispose on the GDI objects (Graphics, Brush, Pen, ...) that you're creating. You'll eventually run Windows out of handles and it'll start acting weird and crash.
|
|
|
|
|
Thanks very much Dave,
this is the help I needed.
I solved the problem.
...and yes, you're right, I miss some Dispose, but this was just a short and fast sample to show my problem.
Anyhow I recognize that my code is not good code...
Thanks
|
|
|
|
|
When i try to build a project using MSBuil tools for VS2017 an error occurred Could not find required file 'setup.bin'
|
|
|
|
|
|
After upgrade to VS 2017 i got "Error An error occurred while signing: SignTool.exe not found." But only using MSbuild on the Visual Studio publish there's no problem.
I already checked folder "C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin" and in fact there's no SignTool.exe present. But there was before installing VS2017, any ideas?
|
|
|
|
|
Start Developer Command Prompt for VS 2017
enter signtool, hit enter
then it is in the path variable.
That seems to do the trick, now the problem is with setup.bin file.
error MSB3147: Could not find required file 'setup.bin' in csproj folder
|
|
|
|
|
|
Thanks but already tried those.
|
|
|
|
|
Hi,
I have an Application which runs fine and gives perfect results when the Application runs with right click and Run as Administrator option, but when I try to run the application a batch file or Scheduled task (even though I selected option of Run with highest privileges for Scheduled Task) still it runs as I am running without Admin Privileges.
Is there any way I can run the Application same as "Run as Administrator" and can schedule it as well. Tried different approaches nothing worked so far. Any help would be really grateful. As the application is not giving 100% results, people are thinking that Application is not working properly.
Any help can help me, thanks in advance.
I have few questions about it, the Application is actually calling SSIS Packages running good for some Packages but for some its not, Application executes the SSIS Packages but when the Package itself doesn't completes it fully. Because of this I am getting doubts like
- Does SSIS Package which runs from within C# code, does it run with the same Privileges as then Windows logged in account or different account? If its different account what account it runs with?
Thanks,
Abdul Aleem
"There is already enough hatred in the world lets spread love, compassion and affection."
-- modified 25-Apr-17 19:57pm.
|
|
|
|
|
Type thanglish in keyboard when display tamil letters in textbox
|
|
|
|
|
So what is your question here?
modified 20-Sep-20 21:01pm.
|
|
|
|
|
You need to use a translation service, which would read the Tamil words and then generate English, or Thanglish for them. No framework, — ASP.NET, PHP, Node.js even Java EE — is capable of doing this all by themselves.
You can use services by either Google, or Microsoft and then write your own service that converts the words. Which is beyond the scope of these discussions. Both of these giants provide some good APIs that you can subscribe to,
Cloud Translation API - Dynamic Translation | Google Cloud Platform
Translator API - Microsoft Translator
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~
|
|
|
|
|
Hi,
I want to get the current week of the month in string, like for example I want to check if this current week is the first week of the month, second week of the month like this is it last week of the month. Usually I am not having problem in finding if this week is first, second, third or even 4th but the problem is in finding which is the last week.
Any help is going to be greatly helpful - thanks in advance.
Thanks,
Abdul Aleem
"There is already enough hatred in the world lets spread love, compassion and affection."
|
|
|
|
|
So, which is the last week? Since you are able to calculate the week, what prevents you from finding out whether this is the last, or which is the last week of the month?
Quote: like this is it last week of the month How? Isn't there going to be another week, or my April 21st, Friday calendar date is wrong? — there is another working week coming up, or maybe I'm a bit more sleepy and should take a nap.
Perhaps, the question itself is a bit unclear. As a suggestion, please review the following thread, datetime - Calculate week of month in .NET - Stack Overflow
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~
|
|
|
|
|
Presumably, the last week in the month is the one containing the last day. So if you have any date you should be able to find out which week it is part of.
|
|
|
|
|
Sorry I was busy in other stuff and with my kids, yes I came back, yes I did my friend. It was more logical but I want to do it.
Here it is.
public static bool RunForTheDay(bool IsTheJobWeekly, bool IsTheJobMonthly, bool IsTheJobYearly,
int WhatDayOfMonthJobRuns, int WhatWeekOfMonthJobRuns, int WhatMonthOfYearJobRuns,
int WhatDayOfYearJobRuns, bool RunForTheDay, string strDayOfTheWeek)
{
bool retRunForTheDay = false;
//string strDayOfTheWeek = DateTime.Now.ToString("dddd");
if (IsTheJobYearly)
{
if (WhatDayOfYearJobRuns > 0)
{
if (WhatDayOfYearJobRuns == DateTime.Now.DayOfYear)
retRunForTheDay = true;
}
else if ((WhatMonthOfYearJobRuns > 0) && (WhatMonthOfYearJobRuns == DateTime.Now.Month))
{
if ((WhatDayOfMonthJobRuns > 0) && (WhatDayOfMonthJobRuns == DateTime.Now.Day))
{
retRunForTheDay = true;
}
else if (WhatWeekOfMonthJobRuns > 0)
{
int tempWeekOfTheMonth = GetWeekOfMonth(DateTime.Now);
if ((tempWeekOfTheMonth == WhatWeekOfMonthJobRuns) && RunForTheDay)
retRunForTheDay = true;
}
}
}
else if (IsTheJobMonthly)
{
if ((WhatDayOfMonthJobRuns > 0) && (WhatDayOfMonthJobRuns == DateTime.Now.Day))
{
retRunForTheDay = true;
}
else if (WhatWeekOfMonthJobRuns > 0)
{
int tempWeekOfTheMonth = GetWeekOfMonth(DateTime.Now);
if ((tempWeekOfTheMonth == WhatWeekOfMonthJobRuns) && RunForTheDay)
retRunForTheDay = true;
}
}
else
{
retRunForTheDay = RunForTheDay;
}
return retRunForTheDay;
}
public static int GetWeekOfMonth(DateTime date)
{
DateTime beginningOfMonth = new DateTime(date.Year, date.Month, 1);
while (date.Date.AddDays(1).DayOfWeek != CultureInfo.CurrentCulture.DateTimeFormat.FirstDayOfWeek)
date = date.AddDays(1);
return (int)Math.Truncate((double)date.Subtract(beginningOfMonth).TotalDays / 7f) + 1;
}
Thanks,
Abdul Aleem
"There is already enough hatred in the world lets spread love, compassion and affection."
|
|
|
|
|
I have a fairly simple VB.Net application which I wrote a few years ago to chart weather observations. It uses two DateTimePicker controls to specify the date/time range of the data to be charted and had been working fine, once I got a few initial minor bugs sorted out. I don't use it that often (perhaps once every 3-6 months), so I don't know when the behavior I am about to describe started. A couple of days ago, I ran the application, and, instead of defaulting to displaying the beginning and end of the most recent 24 hours for which data was available (e.g. 04/18/2017 12:23), both controls displayed only the delimiter characters (// : ). The values of the fields were apparently correct - choosing a data set and pressing the 'plot' button produced the expected plot of 24 hours' data - but the datetimepicker controls didn't 'work'.
Debugging with Visual Studio confirmed that the contents of all the variables were as expected, but the controls still looked (differently!) weird in the running program, although they looked as they should in design view. Running under Visual Studio, the controls sort of worked, but with an enormous amount of horizontal space (and no delimiters) between each subfield (month, day, year, minutes, seconds), so that only one or at most two subfields were in view at a time.
Has anyone seen anything like this and/or does anyone know what may be going on.
|
|
|
|
|
There was a similar question posted yesterday, but I cannot recall where it was (can't find it in the obvious places). Someone suggested checking the code to see if some control information is being garbage collected early.
[edit]
Found it in the C++ forum: CDateTimeCtrl in Windows 10 - C / C++ / MFC Discussion Boards[^], but not sure if that helps.
[/edit]
|
|
|
|
|