• Which the release of FS2020 we see an explosition of activity on the forun and of course we are very happy to see this. But having all questions about FS2020 in one forum becomes a bit messy. So therefore we would like to ask you all to use the following guidelines when posting your questions:

    • Tag FS2020 specific questions with the MSFS2020 tag.
    • Questions about making 3D assets can be posted in the 3D asset design forum. Either post them in the subforum of the modelling tool you use or in the general forum if they are general.
    • Questions about aircraft design can be posted in the Aircraft design forum
    • Questions about airport design can be posted in the FS2020 airport design forum. Once airport development tools have been updated for FS2020 you can post tool speciifc questions in the subforums of those tools as well of course.
    • Questions about terrain design can be posted in the FS2020 terrain design forum.
    • Questions about SimConnect can be posted in the SimConnect forum.

    Any other question that is not specific to an aspect of development or tool can be posted in the General chat forum.

    By following these guidelines we make sure that the forums remain easy to read for everybody and also that the right people can find your post to answer it.

SimConnect C# Compile Error...

Messages
9
Managed Client Event sample
//
// Respond to Flaps up and down (F5, F6, F7 and F8 keys)
// Respond to Pitot switch (Shift-H)

Kind of a NewBee to C#, But I hae done lots of VB programming... I want to use C#

Using VS 2005, I have finally wired up the form correctly.

Here is the base code hat is spawning the error:

>>Error here protected override void DefWndProc(ref Message m)
{
if (m.Msg == WM_USER_SIMCONNECT)
{
if (simconnect != null)
{
simconnect.ReceiveMessage();
}
}
else
{
base.DefWndProc(ref m);
}
}

When I compile the form, I get this error:

I have all the references:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

// Add these two statements to all SimConnect clients
using Microsoft.FlightSimulator.SimConnect;
using System.Runtime.InteropServices;

Here is the error:

Error 2 'FlightSimTest.Main.DefWndProc(ref System.Windows.Forms.Message)': no suitable method found to override


Any ideas?

Thanks
 
How did you create the project in C#? - was it a console App or a forms App? The reason I ask is that the FlightSimTest.Main looks like Console App and then there is no forms defwnd proc.

Got all the namespaces all the same?

Just a SWAG - could be wrong - I'm no C# expert
 
SimConnect C# Issue

Thanks Ron,

I was able to get it to compile by adding the windows forms system controls,

But now I am getting the .exe
does not contain a static 'Main' method suitable for an entry point FlightSimTest

namespace FlightSimTest
{
public static class Main {


public partial class Form1 : Form
{

Again I am kind of new to C# (I have some books I am reading as well), but have done quite abit of programming. Once I get a working model / template to work with I will be on my way!

Thanks!

Barry
 
Barry,

Look at the program.cs part of the examples. They already have a Main.

/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
 
Last edited:
C# SimConnect Issue

Thanks Ron!

OK, a big DAH! I opened the correct project file and it compiled fine... I must have opened the Managed Event .CS file directly. The good thing is that hacking around with it and reading C#, it was a good learning experience. I came close to getting it to work just researching it on my own.

Sorry about that! MY BAD!

Take care and thanks! Hopefully, the next time it will be a more intelligent question, not just getting started :)

Take care!

Barry
 
Back
Top