|
I put the break points, and step into the code but still, not working. While I run it in the emulator, it adds the data to the mobile database, but after i stop the debugging and restart the application, the data is lost.
Any other idea?
|
|
|
|
|
I created a client-server application. So far I created 3 Projects from visual studio C#.. First project is the Server project, second project is the Client Project, and the Third Project is the connector project. The connector project is responsible for linking the client and the server together. Here's the problem, the connector project produces a DLL file when compiled which will be imported into the client and into the server so that they can communicate with each other. So this time after importing the DLL file to the client project and server project, I compiled them and beside the produced executable file of the 2 projects you can find the DLL file that has been imported. The problem is without the DLL(beside the executable) the program doesn't work. What I was expecting is that during the compilation of the 2 projects(client and server) the DLL is somehow integrated on the executable file and I could just copy the EXE file and run it on any computer. Do you have any idea how I can do this?
|
|
|
|
|
You can't. You obvioulsy misunderstood what a dll is. It's a seperate file. You can write a ton of code to fail gracefully, but the point of a dll is to be seperate. If you want it all in the exe, move the code into the main project.
Christian Graus
No longer a Microsoft MVP, but still happy to answer your questions.
|
|
|
|
|
|
Hello,
I have a console application the runs every few minutes and processes some files.
I am using the timer to do that.
However, I want the console window to disappear when my code is done processing all the files, then to reappear after the specific time has elapsed.
I dont know how to do this.
Thanks.
|
|
|
|
|
The simple way is to run it via a Scheduled Task instead.
|
|
|
|
|
Thanks PIEBALD. I think thats a great idea.
|
|
|
|
|
This p/invoke works
[DllImport("Kernel32.dll")]
public static extern int AllocConsole();
[DllImport("Kernel32.dll")]
public static extern int FreeConsole();
...
System.Threading.Thread.Sleep(3000);
FreeConsole();
System.Threading.Thread.Sleep(3000);
AllocConsole();
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
So, in the example - its going to allocate the console for 3 sec and then free it for 3 sec?
In my Main - I have the following:
<br />
Timer myTimer = new Timer();<br />
myTimer.Elapsed += new ElapsedEventHandler( DisplayTimeEvent );<br />
myTimer.Interval = 900000;<br />
myTimer.Start();<br />
while (Console.Read() != 'q')<br />
{<br />
;<br />
} <br />
How do I incorporate System.Threading.Thread.Sleep here. I'd have to get rid of the timer?
Thanks.
|
|
|
|
|
The Sleep(3000) in my example just demonstrated it -
in my case I was testing from a console app so the console
was already open when the sample code was hit.
I let it show for 3 seconds, hide it for three seconds,
then show it again.
You could use the same code in a GUI app but you'd need to
call AllocConsole() first to show the console window.
The Sleep() was to demonstrate that it works - you shouldn't be using
Sleep() - you have a timer
AllocConsole() shows the console, FreeConsole() hides it.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Thanks, Great - Mark.
In my while loop, I called the AllocConsole and FreeConsole, but my console still stays.
Also, I was actually trying to synchronize it with the processing. So, its like -
1) After 15 seconds has elapsed, the console pops up - the program does the processing.
2) As soon as the processing completes - the console goes away.
3) Repeat.
Thanks for all your help.
|
|
|
|
|
Ekjon wrote: In my while loop, I called the AllocConsole and FreeConsole
Then what's the timer for?
Ekjon wrote: After 15 seconds has elapsed,
Is that controlled by the timer? If I did the math
correctly, your timer is at 15 MINUTE intervals, not 15 seconds.
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Thats right.
The reason is - I was testing it and didn't want to wait for 15 minutes every time, so I set it to 90000 which is 1.5 minute.
So, the problem is: the console just stays, while it should go away when the FreeConsole() is called.
Thanks.
|
|
|
|
|
hmm I'm not sure what's happening. Without your code it's tough to debug
All I know is I tested the code I posted in a C# console app.
If you make a C# console app that does the following, does it work?
[DllImport("Kernel32.dll")]
public static extern int AllocConsole();
[DllImport("Kernel32.dll")]
public static extern int FreeConsole();
static void Main(string[] args)
{
Console.WriteLine("Hi from the first console");
System.Threading.Thread.Sleep(3000);
FreeConsole();
System.Threading.Thread.Sleep(3000);
AllocConsole();
Console.WriteLine("Hi from the second console");
Console.WriteLine("\r\n\r\n");
Console.WriteLine("Press Enter to end...");
Console.ReadLine();
}
If that works, then what are you doing different in your code?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I did the following and it's working fine now.
[DllImport("Kernel32.dll")]public static extern int AllocConsole();<br />
[DllImport("Kernel32.dll")]public static extern int FreeConsole();<br />
static void Main(string[] args)<br />
{<br />
System.Timers.Timer myTimer = new System.Timers.Timer();<br />
myTimer.Elapsed += new ElapsedEventHandler( DisplayTimeEvent );<br />
myTimer.Interval = 90000;<br />
myTimer.Start();<br />
while (true)<br />
{ <br />
;<br />
}<br />
}<br />
public static void DisplayTimeEvent( object source, ElapsedEventArgs e )<br />
{<br />
AllocConsole();<br />
FreeConsole();<br />
}<br />
Before...I was trying to call them in the wrong place.
Thanks so much.
|
|
|
|
|
Cool
Cheers,
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Any experience or ideas printing labels from Dot.net (C#) - what's the best way
Current project uses 2 column/5 row and 3 column/10 rows labels. TIA
Tom
|
|
|
|
|
Hi,
Both Crystal and Reporting Services can be used. Maybe it's a little bit easier with crystal (mainly creating the layout).
However, if you can use MS Word, it's even simpler with it using mail merge. In that case c# code creates the data and delivers it to Word and all of the layout is done using Word. This method is perhaps the easiest and as a bonus, the layout can be modified independently from the program.
Hope this helps,
Mika
|
|
|
|
|
|
Sounds like a plan to me especially if you don't see any downsides in current solution.
Mika
|
|
|
|
|
try the SQL Reproting Service
Vikas Amin
My First Article on CP" Virtual Serial Port "[^]
modified on Thursday, July 24, 2008 5:33 PM
|
|
|
|
|
hy everyone!
i do have some problems with the process.start() methode.
i want to start the following command via the process.start()
"C:\Program Files\Acrobate\Reader 8.0\Reader\AcroRd32.exe" /h /t "C:\sourcedir\somefile.pdf" "printer001" (sure it's not the correct syntax here, but it's readable this way)
when i try to start this code in command line then it works fine, but when i add it to the process.start() methode, it either does nothing or it throws an exception "there is/are invalid path/s"
I added full access to the sourcedir, so access problems shouldn't be the reason.
when i just try to start acrobate as parameter (so e.g.
System.Diagnostics.Process.Start("\"C:\\Program Files\\Acrobate\\Reader 8.0\\AcroRd32.exe\"");
, it works and it start acrobate as a process. when i just add the file including the dirinfo e.g.
System.Diagnostics.Process.Start("\"C:\\sourcedir\\somefile.pdf\"");
, it accepts it as well. but it does not work using the whole string above.
i also tried to use the startinfo object with all it's parameters, but it didn't work neither.
does anyone of you have an idea? I don't think it's a problem because of access rules, because why would the acrobate start if there were some??
thanks!
stephan.
|
|
|
|
|
Hi,
What if you try:
System.Diagnostics.Process.Start("C:\\Program Files\\Acrobate\\Reader 8.0\\AcroRd32.exe", "\"C:\\sourcedir\\somefile.pdf\"");
Mika
|
|
|
|
|
is there a difference in mering it to one string or to seperate it with a comma??
and is there a chance to get it start with the parameters and the printer this way?
|
|
|
|
|
Just wondering is there a typo. Should there be folder Reader after Reader 8.0? Take a look at the paths you posted
C:\Program Files\Acrobate\Reader 8.0\Reader\AcroRd32.exe
C:\\Program Files\\Acrobate\\Reader 8.0\\AcroRd32.exe
|
|
|
|