Home All Groups Group Topic Archive Search About

How Do I Find MyApplication Events?

Author
9 Jul 2009 4:49 AM
Stewart Berman
I have a Visual Studio 2005 Windows Forms project.  I open the ApplicationEvents.vb file and the
General drop down menu is empty.

What option will populate it?

Author
9 Jul 2009 11:14 AM
Jie Wang [MSFT]
Hi Stewart,

Do you have the "Enable Application Framework" option checked in your
Project Properties (in the Application tab)?

This option must be enabled so you can have the application events.

If this option is enabled, to access code for application events:

1. Select a project in Solution Explorer, and then on the Project menu,
click Properties.

2 .Select the Application page.

3. Click the View Application Events button to open the Code Editor.

Now there should be a (MyApplication Events) item in the General drop down
list.

Or you can try manually add the following code to the MyApplication class
and see if it compiles:

Private Sub MyApplication_Startup(ByVal sender As Object, ByVal e As
Microsoft.VisualBasic.ApplicationServices.StartupEventArgs) Handles
Me.Startup
    ' place holder
End Sub

Thanks,

Jie Wang

Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
msd***@microsoft.com.

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#notifications.

Note: MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 2 business days is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions. Issues of this
nature are best handled working with a dedicated Microsoft Support Engineer
by contacting Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/en-us/subscriptions/aa948874.aspx
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
Are all your drivers up to date? click for free checkup

Author
10 Jul 2009 1:16 AM
Stewart Berman
>If this option is enabled, to access code for application events:

The option is enabled and your instructions are just what I did to open the ApplicatinoEvents.vb
and, as I mentioned in my first posting, the General drop down list is empty.

>Or you can try manually add the following code to the MyApplication class
>and see if it compiles:

There isn't any class to add it to.  If I just copy it into the ApplicationEvents.vb files via the
code editor it says "Statement is not valid in a namespace.

I finally fixed it.  I created a new windows forms project, clicked on the Application Events button
copied the generated code
Namespace My

    ' The following events are availble for MyApplication:
    '
    ' Startup: Raised when the application starts, before the startup form is created.
    ' Shutdown: Raised after all application forms are closed.  This event is not raised if the
application terminates abnormally.
    ' UnhandledException: Raised if the application encounters an unhandled exception.
    ' StartupNextInstance: Raised when launching a single-instance application and the application
is already active.
    ' NetworkAvailabilityChanged: Raised when the network connection is connected or disconnected.
    Partial Friend Class MyApplication

    End Class

End Namespace

and pasted it into the ApplicationEvents.vb file in the project I was having a problem with.

That seemed to fix it.

I then went back into the project and deleted ApplicationEvents.vb completely.  Pressing the
Application Events button recreated it properly.

Finally, I closed the project, manually edited the ApplicationEvents.vb file and deleted call of the
lines in the file and saved it -- basically an empty file.  I then opened the project, pressed
Application Events and had the same problem as I originally had.

Conclusion: The original problem was caused by an empty ApplicatoinEvents.vb file.  Visual Studio
2005 is very unstable and often goes into a hard loop that requires killing it so a corrupted file
is not unexpected.  I tried reporting the problem but Microsoft is no longer accepting bug reports
for Visual Studio.

jie***@online.microsoft.com ("Jie Wang [MSFT]") wrote:

Show quoteHide quote
>Hi Stewart,
>
>Do you have the "Enable Application Framework" option checked in your
>Project Properties (in the Application tab)?
>
>This option must be enabled so you can have the application events.
>
>If this option is enabled, to access code for application events:
>
>1. Select a project in Solution Explorer, and then on the Project menu,
>click Properties.
>
>2 .Select the Application page.
>
>3. Click the View Application Events button to open the Code Editor.
>
>Now there should be a (MyApplication Events) item in the General drop down
>list.
>
>Or you can try manually add the following code to the MyApplication class
>and see if it compiles:
>
>Private Sub MyApplication_Startup(ByVal sender As Object, ByVal e As
>Microsoft.VisualBasic.ApplicationServices.StartupEventArgs) Handles
>Me.Startup
>    ' place holder
>End Sub
>
>Thanks,
>
>Jie Wang
>
>Microsoft Online Community Support
>
>Delighting our customers is our #1 priority. We welcome your comments and
>suggestions about how we can improve the support we provide to you. Please
>feel free to let my manager know what you think of the level of service
>provided. You can send feedback directly to my manager at:
>msd***@microsoft.com.
>
>==================================================
>Get notification to my posts through email? Please refer to
>http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#notifications.
>
>Note: MSDN Managed Newsgroup support offering is for non-urgent issues
>where an initial response from the community or a Microsoft Support
>Engineer within 2 business days is acceptable. Please note that each follow
>up response may take approximately 2 business days as the support
>professional working with you may need further investigation to reach the
>most efficient resolution. The offering is not appropriate for situations
>that require urgent, real-time or phone-based interactions. Issues of this
>nature are best handled working with a dedicated Microsoft Support Engineer
>by contacting Microsoft Customer Support Services (CSS) at
>http://msdn.microsoft.com/en-us/subscriptions/aa948874.aspx
>==================================================
>This posting is provided "AS IS" with no warranties, and confers no rights.

Bookmark and Share