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):
I would suggest that you go over your C# code and check for null references.
This is because an AccessViolationException can be thrown instead of a NullReferenceException (due to null reference usage) if the .NET code was called by the C++/CX side of the application. I think it’s because Microsoft COM (which C++/CX uses to interface with .NET) catches the .NET exceptions and turns them into less helpful COM errors as I’m sure you’re seeing here. If the stack trace doesn’t provide any useful info and adding null references checks in the code don’t fix the issue, then you’ll have to debug it old-school style and start commenting-out code until you’ve isolated the issue.
I did everything i could to try and find the issue, ill appreciate your help here.
Here is the line that causes the exception:
The thing is that the “pack” seems OK, when exploring it with the tooltip
It has 2 properties (count is 2) witch seems ok since the 1st one should be the name of the pack (to be captured by the lua) and the second is the message i want to add to it.
on the lua side i have this in my main.lua to capture the messages:
local function onGetMessageFromCSharp(event) if (event == nil or event.message == nil or event.message == "") then return; end print("GetMessageFromCSharp :"..event.message); EventHandler.ParseEvent(tostring(event.message)); end Runtime:addEventListener( "GetMessageFromCSharp", onGetMessageFromCSharp);
It does sometimes capture the first few messages from c# but then it crashes with the exception mentioned above.
Any suggestions? I’m lost here :\
Any more details you need from me? just let me know
The exception states that this is happening in “Cipher.dll” I assume this must be your library, right?
As in, your application is named Cipher or your have a separate .NET library named Cipher.
You can try to isolate it by putting breakpoints in the .NET methods that Lua calls, because this is likely where the exception is happening.
You see, the DispatchEvent() method you are calling in .NET is calling your Lua onGetMessageFromCSharp() function, which in turn is likely calling something on the .NET side in your Cipher library… and the exception is stating that this error is happening somewhere in the Cipher library.
I would suggest that you go over your C# code and check for null references.
This is because an AccessViolationException can be thrown instead of a NullReferenceException (due to null reference usage) if the .NET code was called by the C++/CX side of the application. I think it’s because Microsoft COM (which C++/CX uses to interface with .NET) catches the .NET exceptions and turns them into less helpful COM errors as I’m sure you’re seeing here. If the stack trace doesn’t provide any useful info and adding null references checks in the code don’t fix the issue, then you’ll have to debug it old-school style and start commenting-out code until you’ve isolated the issue.
I did everything i could to try and find the issue, ill appreciate your help here.
Here is the line that causes the exception:
The thing is that the “pack” seems OK, when exploring it with the tooltip
It has 2 properties (count is 2) witch seems ok since the 1st one should be the name of the pack (to be captured by the lua) and the second is the message i want to add to it.
on the lua side i have this in my main.lua to capture the messages:
local function onGetMessageFromCSharp(event) if (event == nil or event.message == nil or event.message == "") then return; end print("GetMessageFromCSharp :"..event.message); EventHandler.ParseEvent(tostring(event.message)); end Runtime:addEventListener( "GetMessageFromCSharp", onGetMessageFromCSharp);
It does sometimes capture the first few messages from c# but then it crashes with the exception mentioned above.
Any suggestions? I’m lost here :\
Any more details you need from me? just let me know
The exception states that this is happening in “Cipher.dll” I assume this must be your library, right?
As in, your application is named Cipher or your have a separate .NET library named Cipher.
You can try to isolate it by putting breakpoints in the .NET methods that Lua calls, because this is likely where the exception is happening.
You see, the DispatchEvent() method you are calling in .NET is calling your Lua onGetMessageFromCSharp() function, which in turn is likely calling something on the .NET side in your Cipher library… and the exception is stating that this error is happening somewhere in the Cipher library.