Hey Guys,
As part of our school project in Arduino, we have the mobile application part, and we used corona to build it cause I’m familiar with the platform, we must use windows phone 8 (project limitations :\ ), so we ended up using Corona Cards.
When running the application, it runs for a minute and then we get this exception:
System.AccessViolationException
and it says it gets it from the line (which is present in one of our modules called Utils.cs):
MainPage.coronaRuntime.CoronaRuntimeEnvironment.DispatchEvent(eventArgs);
This is the code we have in the MainPage:
public partial class MainPage : PhoneApplicationPage { public MainPage() { // Initialize this page's components that were set up via the UI designer. InitializeComponent(); // Set up Corona to automatically start up when the control's Loaded event has been raised. // Note: By default, Corona will run the "main.lua" file in the "Assets\Corona" directory. // You can change the defaults via the CoronaPanel's AutoLaunchSettings property. fCoronaPanel.AutoLaunchEnabled = true; // Set up the CoronaPanel control to render fullscreen via the DrawingSurfaceBackgroundGrid control. // This significantly improves the framerate and is the only means of achieving 60 FPS. fCoronaPanel.BackgroundRenderingEnabled = true; fDrawingSurfaceBackgroundGrid.SetBackgroundContentProvider(fCoronaPanel.BackgroundContentProvider); fDrawingSurfaceBackgroundGrid.SetBackgroundManipulationHandler(fCoronaPanel.BackgroundManipulationHandler); // Add a Corona event handler which detects when the Corona project has been started. fCoronaPanel.Runtime.Started += OnCoronaRuntimeStarted; fCoronaPanel.Runtime.Loaded += OnCoronaRuntimeLoaded; PhoneApplicationService.Current.UserIdleDetectionMode = IdleDetectionMode.Disabled; } public static CoronaLabs.Corona.WinRT.CoronaRuntimeEventArgs coronaRuntime = null; private void OnCoronaRuntimeStarted(object sender, CoronaLabs.Corona.WinRT.CoronaRuntimeEventArgs e) { coronaRuntime = e; } private void OnCoronaRuntimeLoaded(object sender, CoronaLabs.Corona.WinRT.CoronaRuntimeEventArgs e) { e.CoronaRuntimeEnvironment.AddEventListener("GetMessageFromLua", Utils.OnGetMessageFromLua); } }
Please notice this field,
public static CoronaLabs.Corona.WinRT.CoronaRuntimeEventArgs coronaRuntime = null;
we store it inside MainPage and initialise it in “OnCoronaRuntimeStarted” (also tried from “OnCoronaRuntimeLoaded” and got the same results)
Its STATIC because we want to use it from other modules to pass messages to the Lua side.
And when calling it (like mentioned above) we get that exception but only after a while.
Any help will be greatly appreciated.
Roy.