|
hi
cant run my C# program after installation - only if i Run as administrator.
in my setup i set the
InstallAllUsers = True
i change the app.manifest file to
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
allso i try to remove this app.manifest file and i try to change to
requestedExecutionLevel level="asInvoker" uiAccess="false" - and same problem
and after the install, when i try to run the program - The software is not running
only if i click on the exe file and run as administrator.
thanks
modified 19-Dec-15 6:13am.
|
|
|
|
|
With the information you provided, it's impossible to tell you why your app won't run.
What does your app supposed to do? What is it actually doing? Are there any error messages?
As it stands, it sounds like you've written your application so only an administrator can run it because of something your app is doing.
|
|
|
|
|
Did you rebuild the app with the second manifest?
|
|
|
|
|
Hi,
I need a help
I want to store path of selected item of Listbox in a string variable .
Example:
List Box Items:
ABC
XYZ
MNF
if I select XYZ in list box ..I should be able to store its path as D:\Music\XYZ in a string ...ex: string path=D:\Music\XYZ
Thank you
|
|
|
|
|
string sPath = string.format("D:/Music/{0}",SelectedText);
or you can use System.IO.Path.Combine().
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Thanks For your precious comment.. but here we assumed that file root is D:/music.
What to do if the next file location is something like.. D:/Music/Old...
and some other file location like
D:Music/new
Thanks
|
|
|
|
|
Then use System.Path.Combine() as he suggested.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
You can bind the ListBox (set as the 'DataSource of the ListBox) to a Dictionary:
Dictionary<string, string> LbItemsToFilePaths = new Dictionary<string, string>
{
{"ABC", @"D:\Music\XYZ"}, {"XYZ", @"D:\Music\Old\XYZ"}
};
private void Form1_Load(object sender, EventArgs e)
{
listBox1.DataSource = new BindingSource(LbItemsToFilePaths, null);
listBox1.DisplayMember = "Key";
listBox1.ValueMember = "Value";
}
string selectedFilePath;
private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
{
selectedFilePath = listBox1.SelectedValue.ToString();
Console.WriteLine(selectedFilePath);
}
«Tell me and I forget. Teach me and I remember. Involve me and I learn.» Benjamin Franklin
|
|
|
|
|
Is there any difference between
var customer = Customers.Where(x => x.Id == id).FirstOrDefault();
and
var customer = Customers.FirstOrDefault(x => x.Id == id);
Any reason to use one over the other?
Thanks
If it's not broken, fix it until it is
|
|
|
|
|
Not in this case but you need the first one if need to do intermediary steps on the filtered values.
Philippe Mori
|
|
|
|
|
Option 2 will make it look like you knew what you were doing (assuming the next person reading the code knows what they are doing).
(Getting rid of the
var would be even better (IMO) once you "intelligence" it).
|
|
|
|
|
The example that uses both 'Where and 'FirstOrDefault I believe will be slower because the call to 'Where generates a new IEnumerable (of course that is really a "schema" for evaluation ... deferred until evaluated).
Also, since there's no real need for the Where clause, why use it ?
However, if you want a faster method (assuming Customers is a List<Customer>), the (not Linq) 'Find operator is faster:
var customerFound = Customers.Find(cus => cus.Id == id);
See: [^], [^], [^]
«Tell me and I forget. Teach me and I remember. Involve me and I learn.» Benjamin Franklin
|
|
|
|
|
Good info.. Thanks
If it's not broken, fix it until it is
|
|
|
|
|
The reason for spending time in theses forums, I'm going to have to devote some time to linq, I use FirstOrDefault all the time
Use something that works, never look past it for other alternatives
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
I just did some tests and the results were a tad surprising. The Where().FirstOrDefault() was faster than just FirstOrDefault. Find was slightly faster than that, however not using Linq or dynamic expressions at all was significantly faster than all of these methods. Something I come across quite a lot is the mistaken belief that Linq is a "fast" technology; it's actually quite slow but it's power makes it convenient and easy to use. If speed is paramount to you then avoid linq altogether.
|
|
|
|
|
I don't doubt your results in timing, but, of course, you don't share your methodology/code; as I'm sure you know, accurate timing (if such a thing is more than a myth) requires pre-jitting the code, use of a high-resolution timer, etc.
If you follow the three links I posted in my reply to the OP here, you'll see a variety of opinions regarding Where.FirstOrDefault vs. FirstOrDefault.
I wonder if the latest version of the .NET FrameWork might have slightly changed something with Where.FirstOrDefault, but, I'm too busy fixing the leaky plumbing in my code to plumb the depths of .NET source, and I don't speak IL
cheers, Bill
«Tell me and I forget. Teach me and I remember. Involve me and I learn.» Benjamin Franklin
|
|
|
|
|
Your reply did remind me that my results weren't particularly relevant as I was running them in debug mode d'oh. In release mode the linq versions were much quicker, but the Where + FirstOrDefault was still quicker than the FirstOrDefault alone. The Find was also much quicker and still faster than the linq methods, but interestingly the native code benefitted very little from release mode optimisation. It was still quicker than linq but now slower than Find. Interesting indeed.
|
|
|
|
|
interesting results; thanks for posting !
«Tell me and I forget. Teach me and I remember. Involve me and I learn.» Benjamin Franklin
|
|
|
|
|
Message Removed
modified 18-Dec-15 10:25am.
|
|
|
|
|
hi,all:
This question has been bothering me for a long time.
I have some series in chart1, for exampe,i have 100 series, each series have 1 point(or more). And i need paint a rectangle when mouse move, so i have code as follows, but when i run it, the rectangle can not move it smoothly, it is so slow . And i found if series number is less than 10, it maybe move fast.
how can i solve it,i have no idea.
public Form1()
{
InitializeComponent();
Series series1;
for (int i = 0; i < 100; i++)
{
series1 = new Series();
series1.Points.Add(new DataPoint(i, i)); //Just for example
series1.IsVisibleInLegend = false;
chart1.Series.Add(series1);
}
}
bool _isdown = false;
Rectangle r=new Rectangle();
private void chart1_MouseDown(object sender, MouseEventArgs e)
{
_isdown = true;
}
private void chart1_MouseMove(object sender, MouseEventArgs e)
{
if (_isdown)
{
r.Width = 100;
r.X = e.X;
r.Y = e.Y;
r.Height = 100;
panel1.Invalidate();
}
}
private void chart1_Paint(object sender, PaintEventArgs e)
{
Graphics g = e.Graphics;
Pen p = new Pen(Color.LightBlue);
p.Width = 2;
p.Color = Color.Red;
g.DrawRectangle(p, r);
}
|
|
|
|
|
First, your code leaks resources at an insane rate. Every time the Paint event is called you're creating a new Pen and not Disposing it. This will eventually cause Windows to crash.
Create the Pen once, outside the event handler and reuse it. Dispose it when your application closes.
Next, this runs slow because you're drawing 100 series on a chart! It wasn't really designed to do that and isn't optimized to handle that kind of a load.
Every time you move the mouse with the button down, the chart has to be redrawn to "unpaint" the rectangle that your painting and redraw the rectangle in its new position and dimensions. To make it worse, you only have one data point per series! The more points you add to search series the exponentially slower the painting will become.
The only solution you have is to not draw so many chart series.
|
|
|
|
|
actually ,i need plot 20 series with 400 points, but when i plot them in the chartarea, it's also slow when mouse move.
But if i put 20*400 points in one series, the mouse move is fast. But my requirement is 20 line-series, so i don't want one series's end point line to the other's begin point.
|
|
|
|
|
The only way to speed things up is to reduce the number of points you have to draw in the graph. 20 * 400 = 8000 points.
Now, the question is why are you drawing boxes on the chart?
|
|
|
|
|
oh,i need to meet ZoomIn function. When user is doing ZoomIn, he can see his mouse's trace through a various width and heigh rectangle when mouse is down.
|
|
|
|
|
When i plot in the chart, i found chart speed is slower than other soft. Now i think chartarea refresh is cost most of time, but some times i don't need to refresh background series, just need to use invalidate to call paint function.
So is there any method to stop backgound series refresh ,not refresh paint function content?
|
|
|
|