471,122 Members | 2,437 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,122 software developers and data experts.

Windows Service Version

Hi,
I have windows service, in the event of an exception calling (which is
important enough to write away to a customer event log) i would like to
write away the software version as part of the evenetlog message text.

I have used the following code with existing windows forms applications
System.Diagnostics.FileVersionInfo.GetVersionInfo( System.Reflection.Assembly
..GetExecutingAssembly.Location).FileVersion ;

but am unable to use it in a windows service due to the following compiler
error.

'System.Reflection.Assembly.GetExecutingAssembly() ' denotes a 'method'
which is not valid in the given context
So how do i accomplish this in a windows service and is it the best method
anyway.
--
--
TimB
Nov 16 '05 #1
4 5369
Tim,

Can you post the code? There should be no reason you get this error
because of the type of project it is in. It looks like a syntax error, to
say the least.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"timb" <ti**@test.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
Hi,
I have windows service, in the event of an exception calling (which is
important enough to write away to a customer event log) i would like to
write away the software version as part of the evenetlog message text.

I have used the following code with existing windows forms applications
System.Diagnostics.FileVersionInfo.GetVersionInfo( System.Reflection.Assembly .GetExecutingAssembly.Location).FileVersion ;

but am unable to use it in a windows service due to the following compiler
error.

'System.Reflection.Assembly.GetExecutingAssembly() ' denotes a 'method'
which is not valid in the given context
So how do i accomplish this in a windows service and is it the best method
anyway.
--
--
TimB

Nov 16 '05 #2
Tim,

Can you post the code? There should be no reason you get this error
because of the type of project it is in. It looks like a syntax error, to
say the least.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"timb" <ti**@test.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
Hi,
I have windows service, in the event of an exception calling (which is
important enough to write away to a customer event log) i would like to
write away the software version as part of the evenetlog message text.

I have used the following code with existing windows forms applications
System.Diagnostics.FileVersionInfo.GetVersionInfo( System.Reflection.Assembly .GetExecutingAssembly.Location).FileVersion ;

but am unable to use it in a windows service due to the following compiler
error.

'System.Reflection.Assembly.GetExecutingAssembly() ' denotes a 'method'
which is not valid in the given context
So how do i accomplish this in a windows service and is it the best method
anyway.
--
--
TimB

Nov 16 '05 #3
System.Diagnostics.FileVersionInfo.GetVersionInfo( System.Reflection.Assembly.GetExecutingAssembly.Lo cation).FileVersion ;

Aren't you missing a set of parenthesis after GetExecutingAssembly?
System.Diagnostics.FileVersionInfo.GetVersionInfo( System.Reflection.Assembly.GetExecutingAssembly(). Location).FileVersion ;

--
Adam Clauss
ca*****@tamu.edu
"timb" <ti**@test.com> wrote in message news:%2****************@TK2MSFTNGP12.phx.gbl...
Hi,
I have windows service, in the event of an exception calling (which is
important enough to write away to a customer event log) i would like to
write away the software version as part of the evenetlog message text.

I have used the following code with existing windows forms applications
System.Diagnostics.FileVersionInfo.GetVersionInfo( System.Reflection.Assembly
.GetExecutingAssembly.Location).FileVersion ;

but am unable to use it in a windows service due to the following compiler
error.

'System.Reflection.Assembly.GetExecutingAssembly() ' denotes a 'method'
which is not valid in the given context
So how do i accomplish this in a windows service and is it the best method
anyway.
--
--
TimB

Nov 16 '05 #4
System.Diagnostics.FileVersionInfo.GetVersionInfo( System.Reflection.Assembly.GetExecutingAssembly.Lo cation).FileVersion ;

Aren't you missing a set of parenthesis after GetExecutingAssembly?
System.Diagnostics.FileVersionInfo.GetVersionInfo( System.Reflection.Assembly.GetExecutingAssembly(). Location).FileVersion ;

--
Adam Clauss
ca*****@tamu.edu
"timb" <ti**@test.com> wrote in message news:%2****************@TK2MSFTNGP12.phx.gbl...
Hi,
I have windows service, in the event of an exception calling (which is
important enough to write away to a customer event log) i would like to
write away the software version as part of the evenetlog message text.

I have used the following code with existing windows forms applications
System.Diagnostics.FileVersionInfo.GetVersionInfo( System.Reflection.Assembly
.GetExecutingAssembly.Location).FileVersion ;

but am unable to use it in a windows service due to the following compiler
error.

'System.Reflection.Assembly.GetExecutingAssembly() ' denotes a 'method'
which is not valid in the given context
So how do i accomplish this in a windows service and is it the best method
anyway.
--
--
TimB

Nov 16 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by Eric Chong | last post: by
7 posts views Thread by Larry Bird | last post: by
5 posts views Thread by dm3281 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.