Awesomium.NET WebCore.CreateWebView throughs unhandled exception - awesomium

The following code throws an unhandled exception, and I have no clue why.
using (WebView view = WebCore.CreateWebView(1100, 600))
{
...
}
Unhandled Exception: System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
at Awesomium.Core.NativeMethods.WebCore_CreateWebView_1(HandleRef jarg1, Int32 jarg2, Int32 jarg3, HandleRef jarg4)
at Awesomium.Core.WebCore.CreateWebView(Int32 width, Int32 height)
Any idea on how to solve this?

I had the same issue and it seems when the JavaScript is off, it will crash. So it's better to start WebCore.CreateWebSession with WebPreferences.Default instead of new WebPreferences with JavaScript = false.
Also its session needs a separate thread for the whole life of the application (just one thread and not more).

Related

Program Just started getting tons of stack overflows with a whole new level of error

Alright, this is probably the biggest program i have ever written. I use task in it once so that on first run it will search all available files and folders for certain things. Everything works...well, did work. Now when i start the program after adding a few more features in. It is throwing stack overflow errors on things that never had a problem before.
My first one was right in the begging it threw on a simple return of,
return System.Environment.GetFolderPath(Environment.SpecialFolder.CommonDocuments)
i changed it to just return
public string BaseUpdaterPath { get { return "C:\\Users\\Public\\Documents"; } }
and it started working again.
it got alittle further into the program untill it runs a check to see if a specific path exists.
if (File.Exists(pathINI))
pathini is defined earlier as
string pathINI = (BaseProductPath + "\\" + Name + ".ini");
and baseproduct is
public string BaseProductPath { get { return BaseUpdaterPath + "\\" + Name; } }
these are things that should not be breaking. My error is this
An unhandled exception of type 'System.StackOverflowException' occurred in mscorlib.dll
with more investigation turns into this
Source Evaluation of method System.Exception.get_Source requires calling method System.Reflection.RuntimeMethodInfo.CreateDelegate, which cannot be called in this context. string
I can only imagine this has something to do with threading and the initial search that I am doing if this is the programs first run time.
If i can provide anymore information that i may have overlooked in my details i would be happy to provide it. I have not seen errors like this before that don't really give you much to go off of.
I may just end up throwing up a splash screen during that initial search if it's going to keep causing problems like this and have the rest of the program wait on that task.
UPDATE
I just stepped through my program starting at different steps and i was able to get past that check it kept kicking it out at. Then i got to a different if(foo == bar) and visual studio did this strange thing where it popped up a little loading window and said evaluating BAR then killed the program with
has exited with code -2147023895 (0x800703e9).
wtf is going on lmao
Another update incase anyone runs into this. I have a product preselected when i started up the programming, i wrote checks in to accommodate this however....it blocked me from being able to see what is really happening.
I disabled some code and let the thing run and after a while i found this little bastard popping up on the console
Exception thrown: 'System.IO.PathTooLongException' in mscorlib.dll
Exception thrown: 'System.IO.PathTooLongException' in mscorlib.dll
Exception thrown: 'System.IO.PathTooLongException' in mscorlib.dll
Exception thrown: 'System.IO.PathTooLongException' in mscorlib.dll
now i gotta track that down to wherever the hell it's throwing 5000 times and i should be good to go.
Update again if anyone cares.
I found out that even i caught and threw the exception away it was still getting stackoverflow in windows.old because they have tons of folders and files and i was running out of memory. My solution at this point is during the recursive file check to just discard anyfolder in windows.old. Cant think of a better way.
THE EPIC CONCLUSION...I AM A DUMBASS
i was having two properties check eachother
public bool IsInstalled { get
{
if (DefaultInstalledpath != null || DefaultInstalledpath != "Not Installed")
{
return true;
}
else
{
return false;
}
}
public string DefaultInstalledpath
{
get
{
else if(!File.Exists(pathTXT) && IsInstalled == true)
{
return "Discovering! Please Wait...";
}
.........
i don't wanna talk about the rabbit hole i just fell down

unrecognised exception in windows C++ code

We have a number of sections of code in the format:
try
{
// code
}
catch(std::exception &e)
{
// log exception
}
catch(...)
{
// log unknown exception.
}
Every so often, the unknown exception code triggers, and logs an unknown exception.
I always thought that all exceptions were meant to derive from std::exception, and thus catching std::exception would catch all exceptions.
Is there some other exception that I should be catching?
If my code ends up in the unknown exception handler, is there any way that I can find out what exception was actually caught?
edit
We managed to locate the cause of the problem- despite saying that they had, the customer had not installed .NET 3.5, which our code depends on, and the system fell over when trying to use the XML parser.
Is there some other exception that I should be catching?
This depends on your code. Libraries you call can throw exceptions not derived from std::exception, examples are MFC's CException or Microsoft's _com_error. Also, an access violation might be catched by catch(...), which is the reason why I would not use catch(...) in my code - it's just to broad for me.
2.If my code ends up in the unknown exception handler, is there any way that I can find out what exception was actually caught?
You can run your code in the debugger and configure the debugger to break your program when the exception is thrown (first chance). Then you know exactly which line of code triggers the exception and should be able to see what exactly is thrown.

Checked exceptions in visitors

I am learning ANTLR4 and I have no previous experience with parser generators.
When I define my own visitor implementation, I have to override methods of the BaseVisitor (I am looking for instance at the EvalVisitor class at page 40 of the book). In case my method implementation possibly throws an exception, what should I do? I cannot use a checked exception since the original method has an empty throws clause. Am I expected to use unchecked exceptions? (this seems a bad Java design). For instance, assume that in the EvalVisitor class I want method visitId (page 41) to throw a user-defined exception, say UndefinedId, rather than returning 0. How should I write my code?
You have two options:
Handle the exception inside the visitor method itself.
Wrap your checked exception in an unchecked exception. One possibility is ParseCancellationException, but you'll have to determine for yourself whether or not that makes sense in your application.
try {
...
} catch (IOException ex) {
throw new ParseCancellationException(ex);
}

How to let program to run instead of an exception in c#?

I am writing a program to read all files from an array.
Suppose in between if any file is corrupt or any reason it will stop the execution in between and throw an exception
I want to let the code running till end and at last it logged the error files instead of throwing exception?
try{
doSomethingThatMayRaiseAndException();
}
catch (Exception e){
NotifyTheUserThatSomethingBadJustHappened();
}
Exception here is the base class for exceptions, you may need to use a more specific one if you want to provide the user with details. But right now, what you need to learn is how to deal with exceptions. You can use the link provided by Oded, it is a good start. Then note what is the raised exception you need to handle, and handle it.

J2ME NullPointerException not getting caught

try{
imgball = Image.createImage("/ball.jpg");
//imgpad = Image.createImage("/ball.jpg");
}
catch(Exception e)
{}
The above code works as it is. But when i open imgpad statement, it gives me error of uncaught NullPointerException ? What can be wrong ?
P.S. I am working in a different Thread. If that matters.
The NullPointerException (NPE) must be later in your code. Your catch block will catch any NPE during image load.
As mdma mentioned, the NullPointerException must be later because when the Image.createImage("/ball.jpg"); fails, it will throw an Exception that you catch. Since you catch it and then do nothing, the value of imgball will be unset (null).
Since you are working from a different Thread, it's possible that you are accessing the variable too soon, but I assume the above reason is more accurate because imgball will probably always fail to be created since you give it the absolute path.
Ok. It was my mistake. I'd like to make it clear here for others to know.
The mistake I made was actually from the main thread. I'd written following :
refcan = new ReflectCanvas(2);
d.setCurrent(refcan);
And I was loading images in the constructor ReflectCanvas(). So it could bear the speed upto one image but not for two :)

Resources