home
products
contribute
download
documentation
forum
Home
Forums
New posts
Search forums
What's new
New posts
All posts
Latest activity
Members
Registered members
Current visitors
Donate
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Search titles only
By:
Menu
Log in
Register
Navigation
Install the app
Install
More options
Contact us
Close Menu
Forums
MediaPortal 1
Support
Watch / Listen Media
Television (MyTV frontend and TV-Server)
Tip - Single seat, wait for services to start before running Mediaportal
Contact us
RSS
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="rtv" data-source="post: 239909" data-attributes="member: 12309"><p>I wonder who did that...</p><p></p><p>[CODE]</p><p>315 System.ServiceProcess.ServiceController ctrl = new System.ServiceProcess.ServiceController("TVService");</p><p>316 try </p><p>317 { </p><p>318 string name = ctrl.ServiceName; </p><p>319 } </p><p>320 catch (Exception) </p><p>321 { </p><p>322 ctrl = null; </p><p>323 Log.Info("Main: TvServer not installed, so we can go on."); </p><p>324 }</p><p>[/CODE]</p><p></p><p>There are various issues with this code.</p><p>1. Exceptions are bad for performance - a simple "== null" check for ctrl would have been better. </p><p>2. The ServiceController's Konstruktor needs priviledged access. It's call however is NOT in the try-catch block. So if some user does not run MP with Administrator rights (after installation) this will fail.</p><p></p><p>Here are some docs:</p><p><a href="http://msdn2.microsoft.com/en-us/library/s3ket56y.aspx" target="_blank">ServiceController Constructor (String) (System.ServiceProcess)</a></p><p></p><p>In general the current implementation can hardly be considered more than a workaround. And if even that might cause troubles <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite11" alt=":rolleyes:" title="Roll Eyes :rolleyes:" loading="lazy" data-shortname=":rolleyes:" /></p></blockquote><p></p>
[QUOTE="rtv, post: 239909, member: 12309"] I wonder who did that... [CODE] 315 System.ServiceProcess.ServiceController ctrl = new System.ServiceProcess.ServiceController("TVService"); 316 try 317 { 318 string name = ctrl.ServiceName; 319 } 320 catch (Exception) 321 { 322 ctrl = null; 323 Log.Info("Main: TvServer not installed, so we can go on."); 324 } [/CODE] There are various issues with this code. 1. Exceptions are bad for performance - a simple "== null" check for ctrl would have been better. 2. The ServiceController's Konstruktor needs priviledged access. It's call however is NOT in the try-catch block. So if some user does not run MP with Administrator rights (after installation) this will fail. Here are some docs: [url=http://msdn2.microsoft.com/en-us/library/s3ket56y.aspx]ServiceController Constructor (String) (System.ServiceProcess)[/url] In general the current implementation can hardly be considered more than a workaround. And if even that might cause troubles :rolleyes: [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
MediaPortal 1
Support
Watch / Listen Media
Television (MyTV frontend and TV-Server)
Tip - Single seat, wait for services to start before running Mediaportal
Contact us
RSS
Top
Bottom