|
Hi all,
Ok here is the scenario. I wrote an application which reads information from a access database
and then the user has the option to export it to an MS word Document. This work 100% on some machines but troughs a Runtime error on other.
Here is a code snippet.
ApplicationClass wordApp = new Word.ApplicationClass();
//Error when creating event.
wordApp.DocumentBeforeClose += new Word.ApplicationEvents4_DocumentBeforeCloseEventHandler(wordApp_DocumentBeforeClose);
I almost don't see this being a code/logical error, may it be the version of Office
that differs on the PC's?
Thanx in advance
|
|
|
|
|
I have seen some issues, where if office is installed before the .net framework. The .net hooks into office don't get installed. So if you go into add remove programs and fix the install of office you should see a .net option that wasn't there before, if you istall the .net hooks then it should work for you.
Hope that helps.
Ben
|
|
|
|
|
Hi,
Thanx for the reply, I'm not too sure with the whole hooks concept.
But correct me if I am wrong, If I reinstall Office/Repair the installation
I don't have to do anything else???
If so I'll give it a shot and let u know!
Oh ja, one thing I forgot to mention is that only the events raises an error, I put them in a try/catch
block and the failed of cause but the word document still opened... Make any sense?
-- modified at 10:58 Thursday 26th July, 2007
|
|
|
|
|
When you reinstall / fix office there is a new option that talks about add .net components. You should see that if office was installed before the .net framework.
Ben
|
|
|
|
|
Hello,
In my application, I have to get a microsecond resolution for a timer.
Is it possible to do (on WinXP or Vista) ?
There should be high precision timers in kernel mode, but what is it and how could I get to them from .Net code?
All help will be appreciated.
Roman
-- Everything is possible, even the impossible! ^_^
|
|
|
|
|
Luc's article[^] is probably the definitive article on the subject.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Already read and tested, with this I can only get 1 millisecond resolution (Multimedia Timer), but I need 1 microsecond...
-- Everything is possible, even the impossible! ^_^
|
|
|
|
|
If you need to control timing that tightly, then you need a real time OS. There are several flavors of *nix that are, but windows is not.
--
You have to explain to them [VB coders] what you mean by "typed". their first response is likely to be something like, "Of course my code is typed. Do you think i magically project it onto the screen with the power of my mind?" --- John Simmons / outlaw programmer
|
|
|
|
|
Yeah, but it should work in windows. I'm sure there's something like nanosleep in win32 kernel mode.
-- Everything is possible, even the impossible! ^_^
|
|
|
|
|
Kel_ wrote: I'm sure there's something like nanosleep in win32 kernel mode.
No, there isn't.
|
|
|
|
|
I am confident it is not; it probably is adequate for timing software events.
But who ever is interested in interfacing to the outside world,
or adding some special hardware to a PC, will ask things like the OP did.
And since there is no perfect solution available yet, MS is likely to continue and improve
on it step-by-step, as usual.
|
|
|
|
|
Use the System.Diagnostics.Stopwatch class.
---
single minded; short sighted; long gone;
|
|
|
|
|
Yeah, it's a good solution for measuring time, but for waiting (sleeping) I wasn't able to find a way to use it.
Thread.Sleep in combination with winmm.dll calls give 1ms precision only :/
-- Everything is possible, even the impossible! ^_^
|
|
|
|
|
Hi Kel_,
regular threads cant be scheduled at such precise moments. The scheduler basically
works with the system timer (thats around 16-20 msec) and it may be locked by something,
and hence take tens of microseconds to perform a switch; you can improve in two ways:
1.
the hacking way: give yourself a high priority, do a busy wait, then go for it;
as a general solution, it stinks; the other threads and processes wont like you and neither will the user in front of the PC; if you only need it occasionally (say you did cause an
external action to start and need to measure a micro-switch very accurately, then react on it),
you might even raise your thread priority to real-time. Dont do this for more than a few
milliseconds, or your PC will seem dead (and may even need a reboot). Even so, I dont
think you will succeed each time; at best I expect it to work most of the time.
2.
the normal way: write a driver; use interrupts, and run your ISR at one of the interrupt
priorities, then do postprocessing at one of the real-time priorities, then signal the user
(at a normal priority). This involves quite some work and knowledge; I have done this often
on embedded systems, never on a PC. And the more evolved the Windows version, the harder it
gets; they keep adding protections and barriers...
|
|
|
|
|
Thank you! This is helpful
So I should look for creating a driver, I'm interested in some examples... For the work and knowledge, I have my time and I like to learn.
Just for the context: my application is XNA flight simulator for a real world helicopter.
-- Everything is possible, even the impossible! ^_^
|
|
|
|
|
OK, I dont remember having seen a single CP article on drivers.
And IIRC the first thing you will need is called a DDK (Drivers Development Kit).
I also suggest you trim down your PC as much as you can: since you are going to reboot
your PC every time you hit the RUN button, better have the fastest boot time possible.
|
|
|
|
|
Isn't there a timer which uses Performance Counters or something like that?
|
|
|
|
|
You could always look at rdtsc ( ReaD TimeStamp Counter ) instruction which gives you a 64bit integer of how many clock cycles have passed since the computer was started up. To use it, you would have to write a .dll in C++ with inline assembly language, and call the .dll from your .NET app. Since it is in terms of clock cycles, it might be too fine of a measurement, but just a thought...
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
i have to display reports in my application.how can i do it?my application is device application and not for desktop.
|
|
|
|
|
I'm building a "simple" program to provide support to a much larger software package that runs on some dedicate machines. The "simple" program consists primarily of a single form that I imported from the larger software package. Unfortunately, the form from the larger package is sized at 1280, 1024 to fit with the resolution used on the dedicated machines and to enable to display of all the data I need to display on one page.
The support program, though, will not run on dedicated machines, so there's no way I can guarantee the user of the support program will have his/her screen set to 1280 x 1024 resolution. I could either try to resize the form, i.e., rearrange the data so the form's size can be 800 x 600, or do something else, like add a vertical and horizontal scroll bar to the form. If I do that, how do the scroll bars actually work? Any suggestions on how I might best handle the situation would be appreciated. Thanks.
|
|
|
|
|
You might try breaking up the components from the imported forms and placing them in tabs. They you can get your simple form sized down for your users and still be able to present all the info.
Hogan
|
|
|
|
|
You could look at the AutoScroll property of your host form, and place your large form as a control on the host form.
|
|
|
|
|
Thanks. The AutoScroll property worked fairly well. What I'm thinking of trying also is temporarily adjusting the screen resolution on the customer computer if the 1280 x 1024 setting is available for as long as the support program I'm developing is running and active and then resetting the resolution back to whatever the customer had it set to originally when the application closes. I don't know if this is considered acceptable programming practice or not, but it might be the best thing for the customer, ultimately, so they can easily see the data they need to see on one page.
|
|
|
|
|
Hi,
some MS specialists will flame you if you programmatically change the desktop resolution,
since the desktop belongs to everyone, not just your program.
Furthermore, it is not simple; it needs some P/Invoke to get it done, but when you try
to undo, you will notice that:
1. desktop icons have moved
2. some open windows have been resized
3. some minimized windows, when they get restored, dont restore to their original size.
I am still working on a utility to do all this correctly; I have covered 1 partially,
2 entirely, and I am afraid 3 is impossible to solve. All this for XP; it may be quite
different on every other Windows incarnation.
And concerning your form problem: you might consider reducing the size of (most of) the
controls on your form, which also means reducing font sizes of course.
Whatever you do (adapt resolution, or adapt sizes), the visibility is likely to suffer.
Hope this helps.
|
|
|
|
|
Thanks. I managed to edit the desktop resolution on program startup, but, well, the first form the user sees is a small login screen. If I change the resolution when the login screen appears, the user will see everything behind the login screen change without any prompting, and that, honestly, freaked me out a bit (and I expected it to happen, obviously). If, on the other hand, I have the resolution change when the larger form appears, it's still a bit unnerving because the difference between the resolution on the login screen and the resolution on the main application form is rather obvious. I can see the whole process causing a bit of angst in the users of the application.
What I decided to do, ultimately, is resize the form so that it will fit a 1024 x 768 desktop, which, I believe, is the most common resolution for the average user. If someone uses an 800 x 600, I have the AutoScroll property set to true so they can see the information if needed. When I resized the controls (and the fonts), well, as you said, the form loses some of its visibility, but I think it will work well enough.
Thanks or the advice, and for cueing me in to some of the problems inherent in attempting to solve this problem.
|
|
|
|
|