|
No, I was tired and being sloppy in my coding and inserted => when I wanted >=. This mistake should have been caught in the visual studio 2005 environment as an error, but it built cleanly. I understand that the syntax was wrong, but it let me run with no errors. On my home dev machine, the interface caught this as an error.
AAron
Our developers never release code. Rather, it tends to escape, pillaging the countryside all around.
The Enlightenment Project (paraphrased comment)
|
|
|
|
|
Actually, the operator is valid, so the compiler may no capture it. You're probably not running 3.0 at home, because 2.0 doesn't have this operator, thus flagging as an error.
|
|
|
|
|
I am running 2.0 at home. So theoretically you can compare two values with a lambda(=>) expression? If not, this should have been recognized as an invalid argument and displayed an error. I understand that the syntax is used in 3.0, but is it used in the describe context?
Our developers never release code. Rather, it tends to escape, pillaging the countryside all around.
The Enlightenment Project (paraphrased comment)
|
|
|
|
|
Intellisense works by doing partial compiles of your code in the background, as you write it. The compiler didn't catch an error because there wasn't one. The expression is perfectly valid, it just doesn't do much except return the value of two .
You can find a little more on it here[^].
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Which explains while it bombed at runtime - the if statement only accepts boolean results.
Our developers never release code. Rather, it tends to escape, pillaging the countryside all around.
The Enlightenment Project (paraphrased comment)
|
|
|
|
|
You got to be using 3.0 without knowing it. I just tried your example on a GUARANTEED 2.0 machine (it's never seen .NET 3 installed on it) under VS.NET 2005 and VS flagged the operator as an Invalid Expression before I even hit Build.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Yes, I am using 3.0 on the machine that threw the error, I thought I had made that clear. A coworker of mine ran it on his which is running 3.0 and did not get the error. So it's not a 2.0 or 3.0 issue. The only other difference might be linq or it might just be my machine.:->
Our developers never release code. Rather, it tends to escape, pillaging the countryside all around.
The Enlightenment Project (paraphrased comment)
|
|
|
|
|
I have a fairly standard forms-based application with a lot of data-bound combos (DropDownList style) in it. Everything works fine except when the form is used to edit a 'new' object. In that case, all the form fields should be cleared. But combos dont show in cleared state, they just keep displaying the first value in the list. So now the user thinks that a value is already selected for him, but the application doesnt actually update the bound property of the object unless some other value is selected in the combo.
Lets say I have these two classes in my app.
<br />
class SelItem<br />
{<br />
public string Id { get; set; }<br />
}<br />
<br />
class MyObj<br />
{<br />
public SelItem Selection { get; set; }<br />
}<br />
To fill the drop down list of the combo i use (Id is a string property of the objects im passing through valuesList):
<br />
combo.DisplayMember = "Id";<br />
combo.DataSource = valuesList;
and using the forms designer I've bound the Text & SelectedValue of the combobox in this way (bindingSource contains a list of MyObj):
<br />
combo.DataBindings.Add(new System.Windows.Forms.Binding("SelectedValue", bindingSource, "Selection", true));<br />
combo.DataBindings.Add(new System.Windows.Forms.Binding("Text", bindingSource, "Selection.Id", true));<br />
Currently, I'm clearing the combo-boxes by setting their SelectedIndex property to -1 every time a 'new' form is launched, but thats just a hack. Anyone got an idea why isnt the combo taking care of this automatically.
|
|
|
|
|
I am having problem regarding debugging MMC application which is developed using C# and .Net version 1.1. Currently I have installed .Net version 2.0 and now if I try to debug the application it starts normally and when I try to add an existing snap-in using Add/Remove snap-in option of MMC the application closes without any error. If I run the application in release mode it works fine.
If I uninstall .Net 2.0 then I am able to debug the application but I don’t think this is a good solution.
If any one have faced similar problem or having any idea regarding this issue please help.
Regards,
Prakash Kalakoti
|
|
|
|
|
I want to convert an application written in VB.NET into a Window service. I tried an example which writes to the event log every 10 secs. Following is the code i wrote in a timer's tick event:
Dim MyLog As New EventLog() ' create a new event log
' Check if the the Event Log Exists
If Not MyLog.SourceExists("MyService") Then
MyLog.CreateEventSource("MyService", "Myservice Log")
' Create Log
End If
MyLog.Source = "MyService"
' Write to the Log
MyLog.WriteEntry("MyService Log", "This is log on " & _
CStr(TimeOfDay), _
EventLogEntryType.Information)
The timer is enabled in the OnStart(). The Service got installed using the InstallUtil command. And I was able to start the service. But this was not my requirement. I tried to display a message box instead of writing to Log. So I replaced the above code with a line to display a messagebox; ie it brings up a messagebox every 10 secs. The service got installed but it did not start. It brought up a dialog saying "The service returned no error. This could be a problem with the internal Windows....". I tried writing similar code like showing a form but all returned the same problem. But it works with code written above but if it contain any MsgBox then the problem occurs. Is it possible to write pure VB code in a Window Service?
|
|
|
|
|
A service is usually run under the System user account. There is noone logged in using this account, so there is nowhere that the service can display any user interface. Even if you run the service using your own user account, it might not be able to show a user interface. A service is not supposed to have a user interface.
If you want a user interface for your service, write a regular program that monitors the service.
---
Year happy = new Year(2007);
|
|
|
|
|
I have set the Account as Local system, then it should work irrespective of user account. But how can you say that a window service is not supposed to have a user interface while Norton Antivirus does have one.
-- modified at 5:02 Thursday 18th January, 2007
|
|
|
|
|
tonymathewt wrote: Local system, then it should work irrespective of user account
No, it doesn't. Services run under their own Desktop, not the one the user sees and interacts with. The only way you can get an interface to show up is to go into the Services manager, get the Properties on your service, go to the LogOn tab, make sure it's using the Local System account, then check the box that says something like "Allow service to interact with desktop".
But, like the other poster said, Services are not supposed to have a user interface, so don't expect to just start throwing forms all over your service and watch them work. Services do not get their own message pump like a normal application does. This is something that is required to make forms and events work properly in VB.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Thankyou dave I understand that it is a regular application that has the UI not the service. But I need my application to come up while the system is booted. Could you give me a simple example like an application that displays a messagebox.
|
|
|
|
|
If there is no user logged in the login screen is yet another Desktop that is controlled by MSGINA.DLL.
If you're talking about starting your monitor app, all you have to do is put a shortcut to launch your app in All Users\StartMenu\Programs\Startup or put the command line to launch it under the Run key in Registry.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
I want my application to be ran as a service or create a service for it. Like Norton Antivirus, you can see its service in the service window named 'Norton Antivirus Auto Protect Service'. I guess that's the service which which later brings up the application while the user is logged in you can see its icon in the system tray that enables you to have the user interface. I have the application that does this much but no service. How can I do that?
|
|
|
|
|
OK. You write two applications. One is a Windows Service that does whatever you need it to, and the other is the monitor application that is launched out of the Run key in the Registry. Everything in that key is executed every time someone logs in.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Dave can you explain it a little more breifly. Do you mean that the Service is intended to execute the Application? How do I make an application that can be launched out of the Run key?
|
|
|
|
|
tonymathewt wrote: Do you mean that the Service is intended to execute the Application?
No. The service doesn't do anything other then its job. It shouldn't care if anyone is logged in or not. The application is launched, as I said, out of the Registry Run key when a user logs in and communicates with the service either through sockets or .NET Remoting. That application is responsible for communicating the status of the service with the user and passing user commands to the service.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
The service should check whether a few of the sites are up or not and it should be able to access a local and a remote database. Will it be possible? And how do I launch an application out of the Registry Run key?
|
|
|
|
|
tonymathewt wrote: The service should check whether a few of the sites are up or not and it should be able to access a local and a remote database. Will it be possible?
Of course. So long as you understand how Services work. How you write your code depends on your definitions of "local" and "remote" and what DB engine your using for those databases.
tonymathewt wrote: how do I launch an application out of the Registry Run key?
All you have to do is supply the command line to launch your application. I'm pretty sure you can figure it out if you just look at what's already in there.
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Thankyou very much dave. I have quite understood the run registry key. I am not quite aware of .NET remoting required for communication b/w the application and the service. I think I can easily handle it.
|
|
|
|
|
tonymathewt wrote: But how can you say that a window service is not supposed to have a user interface while Norton Antivirus does have one.
If you examine what Norton Antivirus actually does, I am quite sure that you will find that it's not the service that has the user interface, but a regular program that monitors the service.
---
Year happy = new Year(2007);
|
|
|
|
|
Thankyou Guffa. Any idea how to write a regular program that monitors the service say like Norton Antivirus. I want my application to come up while the system is booted up. Could you give me a simple example like an application that displays a messagebox.
-- modified at 21:57 Thursday 18th January, 2007
|
|
|
|
|
You can use the System.ServiceProcess.ServiceController class to monitor a service. In the documentation you will find several examples.
Put a shortcut to your program in the Startup folder in the Start menu to make it start when you log in. There is also somewhere in the registry that you can add a key for the same effect.
---
Year happy = new Year(2007);
|
|
|
|