I have a strange problem. I’m getting this error in my customers test environment, but not in my local development setup:
"This Automation variable has not been instantiated. You can instantiate it by either creating or assigning it."
Normally this error is because the automation has not be initiated. But it has, why it also works fine locally.
The code is:
[code]GetNodeText(VAR Element : Automation “‘Microsoft XML, v6.0’.IXMLDOMElement”;NodeName : Text) : Text
Node := Element.selectSingleNode(NodeName);[/code]
Before this code the Element has been set through:
OrderId := GetNodeText2(XMLNode,'OrderId');
Where LoadNodeListAndNode uses:
XMLNodeList := XMLDocument.getElementsByTagName(ElementName);
XMLNode := XMLNodeList.item(0);
to get the Element.
The test server is running Windows Server 2003 R2 with a Navision 4.0 SP3. Locally I’m running Windows 7 64bit.
Either you would need to run the CREATE statement ,or need to check if the OLE Object exists on the server too.
Hi Erik P,
One possible reason it is because the XML automation version 6.0 component isn’t exist in your customer test environment. Navision 4.0 product normally use XML automation version 3.0. I hope this is the case at your end.
You need to create the automation variable like create(Automation,true,true).
Maybe I should add that it worked yesterday, but not today! So I don’t think it’s the version.
And in regards to using CREATE then if I’m adding a CREATE then it fails. But normally you only use CREATE on the “main” automation, not the once that are initiated from the already initiated automation. Like here I’m using XMLDocument to initiate XMLElements and then the XMLNode. And I’m only using CREATE on the XMLDocument.
What I normally do is that I test the code with VBA in an excel for example. then you know if the automation object is all ok or not .
And how do I test it with VBA, when the code works fine locally and it worked fine yesterday?
I guess it doesnt work at the moment.
So , you get more visibility over the COM errors with Excel VBA.
You need to investigate further what goes wrong… Then you can share with us what it was…
Ah one more thing . Does the code compile properly ?
Then the automation object may be ok… (still better to check with VBA too :).
This is really strange. Now I tried to change the code to use XML version 4.0 instead of version 6.0.
It still works perfectly when I test it locally. On the server it compiles fine (I actually changed the code from 6.0 to 4.0 and compiled on the server). But when I run it then it fails again.
I seems to load the actual XML document fine. But when it comes to working with the XML, then it appears empty!
How can I test that the core XML automation works on Excel as suggested by faludigabor?
I’m just wondering that since it worked last week and no upgrades or any other applications has been applied to the server since, if the Windows XML automation somehow can be corrupted. But I actually thought that changing the version from 6.0 to 4.0 would have told this.
Or can it be a security problem? I’m admin on the server so this also sounds too weird.
So what can it be? Anyone has any ideas?
IT doesnt sound like an authoriztion issue.
Do you run it via the gui or application server?
What you could do too is to apply the Microsoft Core XML Services (MSXML) 6.0 package to the server.
That could do the trick. Do you have other components used ?
Did you test using exactly from the same XML data? If I don’t get it wrong, your code try to get xml node value from certain path. If the data that you are looking is not around, then the return object would be null (not instantiated).