|
|
I am writing a command line utility in C#. When I try to run the program from a different directory with a batch file or if I put the program folder in the Path statement I get a file not found error on the App.config file. How do I build a command line program that can be called from outside it's build or installed location?
Jay Bowman
Springfield, IL
|
|
|
|
|
Hi all,
I came across a funny and I hoped you could help, I was profiling the performance of different operations in .NET and I found that double operation was faster in debug mode, than in release mode. I created a small project to test this premise it can downloaded here.
double i, j, dTest = 0;
DateTime tmrStart;
TimeSpan spanCost;
tmrStart = System.DateTime.Now;
for(i = 0; i < 100000; i++)
{
for(j = 0; j < 100000; j++)
{
dTest += i+j;
}
}
spanCost = System.DateTime.Now - tmrStart;
Console.WriteLine("Test took {0} milliseconds", spanCost.TotalMilliseconds);
The project code is the same as above code snippet. All my optimizations are set to the project defaults. Surely this can't be right ??? I have tested this on two boxes; my laptop and a performance machines with multiple processors and acres of ram, and I getting comparable results on both. So what am I doing wrong ?
C:\Documents and Settings\Administrator\Desktop\DoubleTrouble\DoubleTrouble\bin>
debug\doubletrouble.exe
Test took 82218.75 milliseconds
C:\Documents and Settings\Administrator\Desktop\DoubleTrouble\DoubleTrouble\bin>
release\doubletrouble.exe
Test took 311218.75 milliseconds
C:\Documents and Settings\Administrator\Desktop\DoubleTrouble\DoubleTrouble\bin>
|
|
|
|
|
Confirmed. Weird!
I looked at the IL between the two version. Ther'yre not that much different at all. Both are doing just about the exact same thing, with the Debug version peppered with NOP instructions and a couple of extra blocks like this:
ldc.r8 10000.
stloc.s VB$CG$t_double$S0
ldloc.s VB$CG$t_double$S0
ble.s IL_001b
The Release version doesn't have the to stloc.s and ldloc.s instructions, but it otherwise identical.
If you were to read through the IL only, you'd say that the Debug version must run slower! Hmmm....
|
|
|
|
|
I examined the IL earlier and thought they where more or less identical.
Will have another look, thanks for the confirmation. I am not sure where this leaves me though.
|
|
|
|
|
Sorry but all looks fine to me. I ran three consecutive tests
Release: Test took 36026.0145 milliseconds
Debug: Test took 91831.0365 milliseconds
Release: Test took 38050.299 milliseconds
Debug: Test took 92406.195 milliseconds
Release: Test took 36189.09 milliseconds
Debug: Test took 86926.077 milliseconds
Is it a 1.1 vs. 2.0 issue? Your projected needed to be converted when I opened it in VS2005.
-- modified at 14:30 Tuesday 15th May, 2007
only two letters away from being an asset
|
|
|
|
|
I got just the opposite using VB.NET 2005 and my own code.
Could be a JIT issue with a certain proc, maybe??
I've run it on a Pentium M 1.7GHz. Intel x86, Family 6, Model 9, Step 5.
|
|
|
|
|
VB.NET! Well that says it all
I tested on a AMD Athlon 64 X2 Dual Core 4800+ running Vista 64bit using C#.
only two letters away from being an asset
|
|
|
|
|
Hmm... OK. I've got a little time to try this in C# too. Hang on.
|
|
|
|
|
Well, not so fast. Rewriting the test in both languages, I got the same results as you. The Debug version is now SLOWER
The VB.NET version I used:
Public Class Form1
Inherits System.Windows.Forms.Form
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Button1.Enable = False
Application.DoEvents()
Dim i, j, t As Double
Dim StartTime As DateTime = DateTime.Now
For i = 0 to 10000
For j = 0 to 10000
t += i + j
Next
Next
Dim EndTime As DateTime = DateTime.Now
Dim TotalTime As TimeSpan = EndTime - StartTime
Console.WriteLine("TotalTime: " & TotalTime.TotalMilliseconds)
Button1.Enabled = True
End Sub
The C# version is, line-for-line, identical to this, even the IL is the same.
using System;
using System.Collections.Generic;
using System.Windows.Forms;
blah, blah, blah
namespace Double_Performance_Test
{
public partial class Form1 : Form
{
public Form1()
{
InitalizeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
button1.Enabled = false;
Application.DoEvents();
double i, j, t = 0.0;
DateTime StartTime = DateTime.Now;
for (i=0; i < 10000; i++)
for (j=0; j < 10000; j++)
t += i + j;
DateTime EndTime = DateTime.Now;
TimeSpan TotalTime = EndTime - StartTime;
Console.WriteLine("Total Time: " + TotalTime.TotalMilliseconds);
button1.Enabled = true;
}
}
}
Both get the same results:
Debug: avg of 3460 ms
Release: avg of 820 ms
-- modified at 16:48 Tuesday 15th May, 2007
|
|
|
|
|
Thats in .NET 2.0 though right ?
|
|
|
|
|
|
The mystery deepens
only two letters away from being an asset
|
|
|
|
|
Yes its a .NET 1.1 program ... Our flagship software is moving over to .NET 2.0 in September,
but I have trouble believing that this issue an issue in 1.1, must be something I am doing.
|
|
|
|
|
I am working on a project that communicates to an embedded microprocessor through a USB/UART chip. The processor is wired so that it can be reprogrammed through the UBS/UART also. My software is able to open the serial port and communicate with the microprocessor. I open the serial port with the following parameters: Baud 115200, Data Bits: 8, Stop Bits One, Parity: None, and Handshake: None. The problem occurs when the serial port opens: the DTR line goes low momentarily, which causes the microprocessor to reset. The software to reprogram the microprocessor forces the DTR low during the reprogramming process, so we can not just disconnect the DTR line. Basically, my question is this: is there anything in the SerialPort.Open() internals, or the internals of the WinSDK functions that the Open() uses that would explain this?
|
|
|
|
|
The only thing I can think of that might be causing this behaviour is that upon ".Open()" being called, the DCB block is being set once per setting in the DCB block. If that is the case, then setting ".DtrEnabled" to true before calling ".Open()" *might* help.
In any case the SerialPort class is just doing P/Invoke calls to the Win32 functions. I wrote my own serial port class in a way that demonstrates asynchronous behaviour. If you would like, you could take a copy of that to test with to see if you can cure this issue.
Phil
|
|
|
|
|
Hi All,
I am trying to make tool like PE viewer in VC++.NET 2005. After enumerating process module I am using ImageDirectoryEntryToData() function to get Import section. It is working fine but this function has been superseded by ImageDirectoryEntryToDataEx() function. I am able to get import section using ImageDirectoryEntryToData() but not using ImageDirectoryEntryToDataEx() . It gives me NULL every time. Here is my code for getting Import Section of the process.
DWORD aProcesses[1024], cbNeeded;
unsigned int i;
HMODULE hMods[1024];
char modName[255];
PIMAGE_IMPORT_DESCRIPTOR pImportDesc;
PIMAGE_SECTION_HEADER pImageHeader;
PSTR pszModName;
ULONG ulSize;
if(EnumProcessModules(::GetCurrentProcess(), hMods, sizeof(hMods), &cbNeeded))
{
for ( i = 0; i < (cbNeeded / sizeof(HMODULE)); i++ )
{
::GetModuleFileNameA(hMods[i], modName, 255);
ImageDirectoryEntryToDataEx(hMods[i], TRUE,
IMAGE_DIRECTORY_ENTRY_IMPORT, &ulSize, &pImageHeader);
if(pImageHeader)
{
while (pImageHeader->Name)
{
pszModName = (PSTR) pImageHeader->Name;
pImageHeader++;
}
}
}
}
Can I know what is the problem with ImageDirectoryEntryToDataEx() function?
Thanks,
Priyank
|
|
|
|
|
hi,
i am new to this site.i am doing my project on ranking web search resutls based on user interests.if u have the code please mail me to id shruthis9@gmail.com.waiting for ur reply
thanking u,
shruthi
india.
shruthis9
|
|
|
|
|
shruthis9 wrote: i am doing my project on ranking web search resutls based on user interests.if u have the code please mail me
Wait... You want me to do your work, for your project. What do I get for this?
|
|
|
|
|
Colin is correct. That's not how this site works. We'll help you write your own code. We will not write it for you.
|
|
|
|
|
Colin and Dave are both spot on when they say that we will not write your project for you. It's not fair on you because it only proves that we know how to code. On a slightly different note, it's not a good idea to put your email address in a post. If people want to reply to you directly, they can hit the email link in the window.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Then It doesn't remain your project
Develop2Program & Program2Develop
|
|
|
|
|
What does OOPS stands for
Object Oriented Programming S...???????
Develop2Program & Program2Develop
|
|
|
|
|
|
It's what you say when you accidentally erase all your data.
Deja View - the feeling that you've seen this post before.
|
|
|
|