Results 1 to 27 of 27

Thread: [RESOLVED] [1.0/1.1] Reference Errors? Help Me, Gimme Code :lol:

  1. #1

    Thread Starter
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Resolved [RESOLVED] [1.0/1.1] Reference Errors? Help Me, Gimme Code :lol:

    Why cant I do this without getting the described errors?

    Error 1:
    Form1.cs(84): 'Outlook_Email_CS.Form1.moApp' denotes a 'field' where a 'class' was expected

    Error 2:
    Form1.cs(85): An object reference is required for the nonstatic field, method, or property 'Outlook_Email_CS.Form1.moApp'


    VB Code:
    1. public class Form1 : System.Windows.Forms.Form
    2.     {
    3.         private System.Windows.Forms.Button button1;
    4.         /// <summary>
    5.         /// Required designer variable.
    6.         /// </summary>
    7.         private Microsoft.Office.Interop.Outlook.Application moApp;
    8.         private System.ComponentModel.Container components = null;
    9.  
    10.         [STAThread]
    11.         static void Main()
    12.         {
    13.             Application.Run(new Form1());
    14.             [color=red]moApp.Quit(); 'Error 1
    15.             moApp = null;[/color] 'Error 2
    16.         }
    Thanks
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  2. #2
    PowerPoster sunburnt's Avatar
    Join Date
    Feb 2001
    Location
    Boulder, Colorado
    Posts
    1,403

    Re: [1.0/1.1] Reference Errors? Help Me, Gimme Code :lol:

    You don't have an instance of the object.

    Code:
    moApp = new Microsoft.Office.Interop.Outlook.Application();
    or something like

    Code:
    moApp = this.ActiveExplorer().Application;
    HTH
    Every passing hour brings the Solar System forty-three thousand miles closer to Globular Cluster M13 in Hercules -- and still there are some misfits who insist that there is no such thing as progress.

  3. #3

    Thread Starter
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: [1.0/1.1] Reference Errors? Help Me, Gimme Code :lol:

    I set it in the form load event because I didnt want to create it at the declaration line. Is this wrong for C#?
    VB Code:
    1. private void Form1_Load(object sender, System.EventArgs e)
    2.         {
    3.             moApp = new Microsoft.Office.Interop.Outlook.Application();
    4.         }
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  4. #4
    PowerPoster sunburnt's Avatar
    Join Date
    Feb 2001
    Location
    Boulder, Colorado
    Posts
    1,403

    Re: [1.0/1.1] Reference Errors? Help Me, Gimme Code :lol:

    Nope, that should work fine.

    I see the problem now.

    Main is static method -- you are referencing moApp, which is a non-static variable inside of it.

    I think you should destroy moApp in your form's destructor of form_closed event.
    Every passing hour brings the Solar System forty-three thousand miles closer to Globular Cluster M13 in Hercules -- and still there are some misfits who insist that there is no such thing as progress.

  5. #5

    Thread Starter
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: [1.0/1.1] Reference Errors? Help Me, Gimme Code :lol:

    Ok, its moved but now another error.
    Form1.cs(99): 'Microsoft.Office.Interop.Outlook.MailItemClass.MailItemClass()' is inaccessible due to its protection level

    VB Code:
    1. private void button1_Click(object sender, System.EventArgs e)
    2.         {
    3.             Microsoft.Office.Interop.Outlook.MailItem oEmail = [color=red]new[/color] Microsoft.Office.Interop.Outlook.MailItem();
    4. '...
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  6. #6

    Thread Starter
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: [1.0/1.1] Reference Errors? Help Me, Gimme Code :lol:

    How come my closing event doesnt fire?
    VB Code:
    1. private void Form1_Closing(object sender, System.EventArgs s)
    2.         {
    3.             moApp.Quit();
    4.             moApp = null;
    5.         }
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  7. #7
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [1.0/1.1] Reference Errors? Help Me, Gimme Code :lol:

    Quote Originally Posted by RobDog888
    How come my closing event doesnt fire?
    VB Code:
    1. private void Form1_Closing(object sender, System.EventArgs s)
    2.         {
    3.             moApp.Quit();
    4.             moApp = null;
    5.         }
    Are you exiting the app using Application.Exit? If so then no Closing or Closed events will be raised. That's fixed in 2.0 with FormClosing and FormClosed, which are still raised when Application.Exit is called, replacing the Closing and Closed events.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  8. #8

    Thread Starter
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: [1.0/1.1] Reference Errors? Help Me, Gimme Code :lol:

    No, I am clicking on the 'x' to close the form. In VB.NET this would fire the form_closing event.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  9. #9
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [1.0/1.1] Reference Errors? Help Me, Gimme Code :lol:

    Are you sure that that method is handling the Closing event fo the form? How did you create it? Have you checked the Properties window to make sure they are linked? There's no Handles clause in C# so it isn't immediately obvious.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  10. #10

    Thread Starter
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: [1.0/1.1] Reference Errors? Help Me, Gimme Code :lol:

    I'll check but I did fix my other error. I have no idea what I was thinking earlier.
    VB Code:
    1. Microsoft.Office.Interop.Outlook.MailItem oEmail = moApp.CreateItem(Microsoft.Office.Interop.Outlook.MailItem);
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  11. #11

    Thread Starter
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: [1.0/1.1] Reference Errors? Help Me, Gimme Code :lol:

    I spoke too soon. Its giving me an error that I cant use MailItem as it denotes a class, but its actually an object.

    Heres my closing event adjusted. I am not sure if the signature is correct.

    VB Code:
    1. private void Form1_Closing(object sender, System.EventArgs e)
    2.         {
    3.             moApp.Quit();
    4.             moApp = null;
    5.         }
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  12. #12
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [1.0/1.1] Reference Errors? Help Me, Gimme Code :lol:

    Quote Originally Posted by RobDog888
    I spoke too soon. Its giving me an error that I cant use MailItem as it denotes a class, but its actually an object.

    Heres my closing event adjusted. I am not sure if the signature is correct.

    VB Code:
    1. private void Form1_Closing(object sender, System.EventArgs e)
    2.         {
    3.             moApp.Quit();
    4.             moApp = null;
    5.         }
    The fact that you say you don't know if the signature is correct suggests to me that you created that method manually and it is not actually handling the intended event. In the C# IDE you create event handlers in the Properties window in a method equivalent to using the drop-down lists in the code window in VB.NET (see screenshot). Both methods are available in the VB 2005 IDE, which is cool because there are times when one is a better option than the other and vice versa. If you already knew all this then forget I was here but, as I say, your language suggests otherwise.

    Edit: Double-click to create a method or use the drop-down list to select from existing methods with the appropriate signature.
    Attached Images Attached Images  

  13. #13

    Thread Starter
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: [1.0/1.1] Reference Errors? Help Me, Gimme Code :lol:

    Yes, your right. I created the closing event myself manualy. I am still on 2003 and I dont have the property like posted so I figure something may be missing as I dont have the form closing event from the dropdown in the codebehind.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  14. #14

    Thread Starter
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: [1.0/1.1] Reference Errors? Help Me, Gimme Code :lol:

    Fixed the other error. Now just need to fix the closing event so it can properly dispose of the Outlook application object.
    VB Code:
    1. Microsoft.Office.Interop.Outlook.MailItem oEmail = (Microsoft.Office.Interop.Outlook.MailItem)moApp.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem);
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  15. #15
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [1.0/1.1] Reference Errors? Help Me, Gimme Code :lol:

    Quote Originally Posted by RobDog888
    Yes, your right. I created the closing event myself manualy. I am still on 2003 and I dont have the property like posted so I figure something may be missing as I dont have the form closing event from the dropdown in the codebehind.
    That drop-down list just shows you all the existing methods that have the appropriate signature. To create a new event handler you double-click either the event name or the empty space where the method name will go.

    As for your other error I was just coming with the solution and you beat me to it.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  16. #16

    Thread Starter
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: [1.0/1.1] Reference Errors? Help Me, Gimme Code :lol:

    Ill try what you suggested but is there any way to shorten the Outlook objects?

    I added the using at the top with "using Microsoft.Office.Interop;" but it doesnt recognize any Outlook objects unless fully qualified.


    Yay, I finally beat you at something
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  17. #17

    Thread Starter
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: [1.0/1.1] Reference Errors? Help Me, Gimme Code :lol:

    Ok, I finally got the freaking event to be created. It was an incorrect signature too. Damn event icon button on the properties window (HOW BLIND AM I?). Why cant they just have the events avalable like in VB.NET?
    VB Code:
    1. private void Form1_Closing(object sender, System.ComponentModel.CancelEventArgs e)
    Any idea on shortening the Office qualification?
    Attached Images Attached Images  
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  18. #18
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [1.0/1.1] Reference Errors? Help Me, Gimme Code :lol:

    Did you perhaps not look too closely at the screenshot I posted earlier?

    The equivalent of "Imports" from VB is "using", so at the top of your code file add:
    Code:
    using Microsoft.Office.Interop.Outlook;
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  19. #19

    Thread Starter
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: [1.0/1.1] Reference Errors? Help Me, Gimme Code :lol:

    Yup, I know about that but its still not working. This is like pulling teeth.
    VB Code:
    1. using System;
    2. using System.Drawing;
    3. using System.Collections;
    4. using System.ComponentModel;
    5. using System.Windows.Forms;
    6. using System.Data;
    7. using Microsoft.Office.Interop;
    And it will give an error that Outlook.Application is undefiuned in my code.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  20. #20
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [1.0/1.1] Reference Errors? Help Me, Gimme Code :lol:

    Quote Originally Posted by RobDog888
    Why cant they just have the events avalable like in VB.NET?
    I know that this was at least partly rhetorical but I'll give an explanation anyway. The drop-down lists in the VB code window are for all member variables declared WithEvents. You can declare a variable manually in code as WithEvents and it will appear in that list. It has no specific connection with the designer, except that every object added in the designer is declared WithEvents automatically. There is no WithEvents or Handles equivalents in C# so that doesn't apply. You are provided a method for creating event handlers for objects added in the designer as a time saver. Like I said, both mechanisms are available in VB 2005 and I find them both useful. One of the good things about the Properties window is that you can add a single event handler for multiple objects just as you can set the same property for multiple objects: just select them all in the designer and double-click the name of the event. This creates one method with all the objects listed in the Handles clause. You can also then use it to select existing methods for other events with compatible signatures.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  21. #21

    Thread Starter
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: [1.0/1.1] Reference Errors? Help Me, Gimme Code :lol:

    Thanks for the explaination. Hopefully as I write a couple more C# projects the pieces will start to come together.

    I dont know why the "using" isnt linking the Outlook.Application code to it. It should be working.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  22. #22
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [1.0/1.1] Reference Errors? Help Me, Gimme Code :lol:

    You cannot use unqualified namespaces in C#. You can only use unqualified types. There is no namespace named "Outlook". Try:
    Code:
    using Outlook = Microsoft.Office.Interop.Outlook;
    Then "Outlook" becomes an alias for "Microsoft.Office.Interop.Outlook", so by using "Outlook" you are actually using the fully qualified name by proxy.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  23. #23

    Thread Starter
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: [1.0/1.1] Reference Errors? Help Me, Gimme Code :lol:

    Yup, that did it.

    Thanks for all the help guys
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  24. #24
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [RESOLVED] [1.0/1.1] Reference Errors? Help Me, Gimme Code :lol:

    Please use better thread titles in future. "Plzzzzzzzzz help me. Gimme code." would have been more appropriate.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  25. #25

    Thread Starter
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: [RESOLVED] [1.0/1.1] Reference Errors? Help Me, Gimme Code :lol:

    I thought I did give a sensible thread title
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  26. #26
    Frenzied Member conipto's Avatar
    Join Date
    Jun 2005
    Location
    Chicago
    Posts
    1,175

    Re: [RESOLVED] [1.0/1.1] Reference Errors? Help Me, Gimme Code :lol:

    Hey Rob,

    If you want to see how your function is attatched to the event handler, one thing you can do is let the IDE generate a handler for you, then right click it and do a Find all references.. You should be able to find where the event handler is assigned. Usually it's in the form designer generated code something along the lines of:

    Object.Event += EventHandlingFunction

    (which is also the format you use when adding event handlers in code)

    This type of functionality replaces the Handles and Addhandler bit in VB.

    Bill
    Hate Adobe Acrobat? My Codebank Sumbissions - Easy CodeDom Expression evaluator: (VB / C# ) -- C# Scrolling Text Display

    I Like to code when drunk. Don't say you weren't warned.

  27. #27

    Thread Starter
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: [RESOLVED] [1.0/1.1] Reference Errors? Help Me, Gimme Code :lol:

    Ah, so I see. Thanks Bill.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width