Error executing code: Wrong type of argument for conversion function - microsoft-dynamics

I am getting this error while Deserializing an object in AX. To make it more weird its fine in my local but failing in other.
str sampleString = conpeek(nodeData, 1);
JArray jArray = JsonConvert::DeserializeObject(sampleString );

I just had this same issue. I don't know if your issue is the same as mine, but in my case, it was coming from an attempt to grab a boolean value from a deserialized container. It would work when running from the AX client, but didn't work when running from CIL. (CLR stuff sometimes behaves differently running locally vs on the server in CIL.) Solved the issue by grabbing the value as a string, then converting to boolean.

Related

After recompiling our FORTRAN-code and using it in C++ our system() or c_str() command don`t work properly

Hi I have a big problem: We created a program in C++/Qt 4.8.4 /Qt Creator 2.8.1 years ago that while executing runs another executable (written and compiled in FORTRAN). Everything worked well.
We recompiled our Fortran-Code with the new version of Visual studio and now suddenly it doesn`t work any more. I looked into my C++-Code and found the position where the program crashes:
std::string Executable = ApplicationName.toStdString();
bool RunOK= system((Executable+" > "+"X.out2").c_str());
QString ExeName = (Executable+" > "+"X.out2").c_str();
QString tf = QString::number(qweee);
if(system((Executable+" > "+"X.out2").c_str()))
{
msg.showMessage("msg.showMessage("An XXX error occured during calculation......((Executable+ > +X.out2).c_str(): "+ExeName +"......(system((Executable+ > +X.out2).c_str()): "+ QString::number(RunOK));
if(QFile(OutputFiles[0]).exists())
QFile(OutputFiles[0]).remove();
}
Somehow system((Executable+" > "+"X.out2").c_str()) gets to be true which didn`t happen before.
This seems to happen either in the c_str-command or in the system()-command.
We had some missing dll-issues before. Is this another dll-problem and if so which?
Can anybody help us on this?
Thank you
The return value of system is an integer, not a boolean. Its value is only defined for one very special case, system(nullptr). That's not the case here. So whether you get a zero or non-zero result depends on your particular C++ implementation, which has indeed changed. ("New visual studio version"). You can't rely on non-zero means error
c_str() is not a suspect at all.

SWIFT 3 unexpectedly found nil while unwrapping an Optional value (works perfect in simulator)

My code works perfectly in simulator, but it pops this "fatal error: unexpectedly found nil while unwrapping an Optional value" warning when I tried to run it on my iPhone and iPad.
Strange thing is, this error didn't occur when I tried to get the value of a variable, it happened when I tried to create an object with the values I got:
"pName" and "pQuestion" are the variables with values, but as you can see, once I tried to give these value to the attributes of my object, they just became nil.
This bit of the code really behaved in the simulator, somehow it just keeps acting out on a real device.
What Swift is telling you is totally correct. Your question variable is nil when you are assigning values to it.
Don't you wanna initialise it before you start putting values into it?
I think what you are looking for is
let question = Question(name: pName, question: pQuestion)
So, I think I know whats wrong with my code.
Like Hunaid Hassan said, my current code will just get nil out of the object.
The reason my original code didn't work is because, one of the attributes is a Date variable, and because I'm in Australia, when the app runs on a real device the Date I get will be nil because I didn't set the locale.
Here's my original code:
enter image description here
And here's the fix I found to set the locale:
enter image description here
ref: https://stackoverflow.com/a/26154583/7578872

Pyter not working when written as a Python Program

I am using pyter API for finding translational error rate(TER) between two words. Pyter normally works in terminal, but when I am using it in Python code, it isn’t working. Normally, it works by writing pyter.ter(w1,w2), but now it is saying that pyter module has no attribute "ter".
actually it got solved. BY mistake I was saving the program named as pyter.py. So, whenever I was importing pyter, the error message of the actual program was being shown. I renamed the script as pyter_xyz.py, and its running fine.
Thanks for the concern #Kamiccolo

Machine ID Code in C++

I tried this because I want to learn how to grab a machine unique ID.
I need it because I'm gonna code a program that reads the machineid and compares it to a specific one.
I edited the code(in the end, the code that prints the Machine ID) to this:
string MachineID;
MachineID = vtProp.bstrVal;
if (MachineID == vtProp.bstr)
but it only gives me this error.
How would I make my HWID variable be set to the value of vtProp.bstrVal, then compare it with vtProp.bstrVal? I've googled for some hour now, can't seem to get it fixed.
Thanks in advance!
Simple syntax error - you've used =, which is assignment, instead of ==, which is comparison.
Because c++ accepts nonboolean types in if statements, the code if(variable = value) is acceptable to the compiler, which tries to assign MachineID the value of vtProp.bstr, which causes your error due to type mismatch.

C++ and ADODB : Com error 0x800a0e78

I have a C++ library that calls a stored procedure in MSSQL database using ADODB. Everything works fine on development database. But on test database, I am getting Com error 0x800a0e78: This option is not allowed if an object is closed.
The code looks like
ADODB::_CommandPtr cmd = NULL;
ADODB::_RecordsetPtr rs = NULL;
CHECKHR(cmd.CreateInstance( __uuidof( ADODB::Command) ));
cmd->ActiveConnection = m_connexion;
cmd->CommandText = "my_stored_procedure";
cmd->CommandType = ADODB::adCmdStoredProc;
CHECKHR(cmd->Parameters->Refresh());
//input param
cmd->Parameters->GetItem(paramIndex)->put_Value(paramValue);
// output param
cmd->Parameters->GetItem(paramIndex)->PutDirection(ADODB::adParamOutput);
rs = cmd->Execute( NULL, NULL, ADODB::adCmdStoredProc);
while(! rs->ADO_EOF ) { ...
rs->ADO_EOF is where it crashes the program if I use the test database.
note: The stored procedure is same in both the databases and returns same data.
There is one more flow where another SP is called. It works well with the test database. The problem appears only with this particular SP.
I tend to think that it is not a code issue because it works with development database. But I can consistently reproduce the problem with test database.
Please suggest of next actions I should take to resolve this issue
UPDATE
Due to some miracle this C++ exception has gone away after 1 day. But it is so very slow that the execution almost always times out. I do not know how to justify this behavior
UPDATE: 2013-07-18
After so much time, the error has appeared again. This time with development DB with the same SP
[Com error 0x800a0e78 : Operation is not allowed when the object is closed.
on the same line
while(! rs->ADO_EOF ) {
in rs I can see a memory address pointing to ADODB recordset object. But rs->ADO_EOF is generating the said error