vtable error. "vtable for ETRun", referenced from: - c++-cli

I have an object called Run. I can instantiate in header of a class. But, when i try to do the same .cpp file the above error was popped out.
vtable error. "vtable for Run",
referenced from:
__ZTV5Run$non_lazy_ptr in Para.o
string Para::name()
{
Run* newRun = new Run;
return mName;
}
how can i get out of this error...

This probably happens because Run is a derived class, and it has a declaration of some virtual function but this function is not implemented.
Try to check whether your problem is this case.

Related

sharedObject does not save my data.

static private function ifonEnternameFrame():Void
{
so.data.name = _root.getName.text;
//trace(so.data.name);
_root.nameBtn.onPress = function ()
{
_root.gotoAndStop(2);
}
}
When you start the application this code will save your name.
But when you then go to another function then it says that it's undefined.
trace(so.data.name);
I traced this when I was on the next frame and it couldn't find the previous name.
Please help.
Flushing the shared object data is necessary to get those variables.
Use the flush function of shared object.
Your problem doesn't come from SharedObject. The origin of your error message is that your textField getName is incorrectly named in your code.
If you trace _root.getName.text in your function ifonEnternameFrame you shall have the same error message:
trace(_root.getName.text); // undefined

aggregate ‘QSqlQuery testQuery’ has incomplete type and cannot be defined

I'm sure this must be something simple, but I can't quite work out what's up here...
I'm trying to create a QSqlQuery, and the compiler is giving me this:
error: aggregate ‘QSqlQuery testQuery’ has incomplete type and cannot be defined
This code is in my mainWindow class:
void MainWindow::on_toolButton_clicked()
{
QString filename;
filename = QFileDialog::getSaveFileName(this, tr("Save to SQL Database"),
"~/temp",
tr("Files (*.fdb)"));
QSqlDatabase testDatabase = QSqlDatabase::addDatabase("QSQLITE");
testDatabase.setDatabaseName(filename);
//this line won't compile:
QSqlQuery testQuery;
testDatabase.close();
QSqlDatabase::removeDatabase(QSqlDatabase::database().connectionName());
}
Can anyone see what I'm missing here?
The error message indicates that the type SqlQuery is not completely defined. QSqlQuery is defined in
#include <QSqlQuery>
Include that and things should compile ok.

Mono and Extension Methods with MonoDevelop 2.8.5

I have written a unit test with MD 2.8.5 in a project that includes System.Core and with build target Mono/.NET 3.5. I really like the Assert.Throws of the newer NUnit, so decided to write an extension method for it. I created a new file with this as its content in the same namespace as the test. Can anyone see my error?
public delegate void TestDelegate();
public static class AssertThrows
{
public static T Throws<T>(this Assert assert, TestDelegate td)
where T : Exception
{
try
{
td();
}
catch(T e)
{
return e;
}
catch
{
throw new AssertionException("Wrong exception type.");
}
throw new AssertionException("Did not throw an error.");
}
}
MonoDevelop "sees" the extension method through its code completion. However, the compiler reports:
Performing main compilation...
/Users/shamwow/dev/EngineTests.cs(19,37): error CS0117:
`NUnit.Framework.Assert' does not contain a definition for `Throws'
/Applications/MonoDevelop.app/Contents/MacOS/lib/monodevelop/AddIns/NUnit/nunit.framework.dll (Location of the symbol related to previous error)
Build complete -- 1 error, 0 warnings
(I know MD and Mono are not the same.)
I assume you're trying to use it just as:
Assert.Throws<FooException>(() => ...);
Extension methods don't work like that - they appear to be instance methods on the extended type. As you won't have an instance of Assert, you can't call your extension method like that.

Managed C++, Object reference not set to an instance of an object

I've run into this problem before, but never in a situation like this. I'm completely confused. As the question states, I'm getting the runtime error "Object reference not set to an instance of an object." Using the debugger tools, I think I've pinpointed the problem to this line:
dataFileLocation = path;
The entire function is here:
void DATReader::SetPath(String^ path)
{
if(!File::Exists(path))
{
MessageBox::Show( "DATReader (missing dat file: \n"+path+"\n )", "Error", MessageBoxButtons::OK, MessageBoxIcon::Exclamation);
return;
}
dataFileLocation = path;
}
dataFileLocation is declared here, but nothing is assigned to it:
ref class DATReader
{
private:
System::String^ dataFileLocation;
// ...
}
Now I know the reason I'm getting the error is because dataFileLocation is assigned to nothing. But I'm having problems assigning it. When I add = 0; to it, it won't build because its a ref class. When I try to assigned it to = 0; in the constructor, it yells at me for trying to convert it from a System::String^ to an int. If I assign it to a = gcnew String(""); it builds, but throws the same runtime exception.
I don't get it, am I reading the debugger wrong, and this isn't the source of the problem at all? I've just started to use managed code recently, so I'm confused :\
You may want to check and make sure your DATReader object isn't null as well It may be throwing the exception at your DATReader.SetPath() call.
This is a nicety in C# that's missing in C++/CLI. C# generates code that ensures this can never be null. Easily seen in the debugger by setting a breakpoint on the method and inspecting "this". Here's an example program that reproduces the exception:
#include "stdafx.h"
using namespace System;
ref class Example {
String^ dataFileLocation;
public:
void SetPath(String^ path) {
dataFileLocation = path; // Set breakpoint here and inspect "this"
}
};
int main(array<System::String ^> ^args)
{
Example^ obj /* = gcnew Example */;
obj->SetPath("foo");
return 0;
}
Remove the /* */ comments to fix. Fix your code by looking at the call stack to find the method that forgot to instantiate the object.
Managed C++ uses nullptr for null references. So you can check:
if (path == nullptr) { ... }
or use:
if (!String::IsNullOrEmpty(path))

How to register component interface in wxwebconnect?

I'm doing an experiment with wxWebConnect test application, incorporating the xpcom tutorial at "http://nerdlife.net/building-a-c-xpcom-component-in-windows/"
I adapt MyComponent class as necessary to compile together with testapp.exe (not as separate dll), and on MyApp::OnInit I have the following lines:
ns_smartptr<nsIComponentRegistrar> comp_reg;
res = NS_GetComponentRegistrar(&comp_reg.p);
if (NS_FAILED(res))
return false;
ns_smartptr<nsIFactory> prompt_factory;
CreateMyComponentFactory(&prompt_factory.p);
nsCID prompt_cid = MYCOMPONENT_CID;
res = comp_reg->RegisterFactory(prompt_cid,
"MyComponent",
"#mozilla.org/mycomp;1",
prompt_factory);
Those lines are copied from GeckoEngine::Init(), using the same mechanism to register PromptService, etc. The code compiles well and testapp.exe is running as expected.
I put javascript test as below :
try {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
const cid = "#mozilla.org/mycomp;1";
obj = Components.classes[cid].createInstance();
alert(typeof obj);
// bind the instance we just created to our interface
alert(Components.interfaces.nsIMyComponent);
obj = obj.QueryInterface(Components.interfaces.nsIMyComponent);
} catch (err) {
alert(err);
return;
}
and get the following exception:
Could not convert JavaScript argument arg 0 [nsISupport.QueryInterface]
The first alert says "object", so the line
Components.classes[cid].createInstance()
is returning the created instance.
The second alert says "undefined", so the interface nsIMyComponent is not recognized by XULRunner.
How to dynamically registering nsIMyComponent interface in wxWebConnect environment ?
Thx
I'm not sure what is happening here. The first thing I would check is that your component is scriptable (I assume it is, since the demo you copy from is). The next thing I would check is whether you can instantiate other, standard XULRunner components and get their interface (try something like "alert('Components.interfaces.nsIFile');" - at least in my version of wxWebConnect this shows an alert box with string "nsIFile".
Also, I think it would be worth checking the Error Console to make sure there are no errors or warnings reported. A magic string to do that (in Javascript) is:
window.open('chrome://global/content/console.xul', '', 'chrome,dialog=no,toolbar,resizable');