Click here to Skip to main content
15,892,059 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
We have a VB6 DLL which is being called by external application using VBScript. It is called like this,
VB
Set sa=CreateObject("Server.Area")
sa.Import(a)

It has been working on WinXP since years. Now that we are moved to Windows 7 Enterprise(x86), this DLL gives error Invalid procedure call or argument. Debugging can't help. If I debug it, it works fine without any error. Nothing is found in event viewer.

To summarize,
1. It is 32 bit system (Win7), there is no separate SYSWOW.
2. There is no error while debugging.
3. Error is being generated at random stage in process.
4. It was working fine for years in WinXP


It could be access permission issue. I tried application with elevated rights with no success. I even tried it in compatibility mode, but it makes it worse by making calling application hang.

Can somebody guide me to get rid of this? Or even what is causing this issue?

Thanks in advance.
Posted

VB6 usually throws this error if you try to call a non-existent method using late binding. Make sure your DLL is registered using regsvr32 and that the Import method exists.
 
Share this answer
 
Comments
Prerak Patel 19-Aug-11 6:58am    
Yes, everything is fine. Method is there, as it is working since years. DLL is registers, still I have tried to re-register it. But no success. Thanks Shameel.
[no name] 19-Aug-11 7:00am    
Since VBScript uses late binding, it is very difficult to troubleshoot COM errors. If you have VB6 installed, you can create a Forms application and use the DLL to debug it. If the DLL has an embedded type library (which all VB6 DLLs have), VB6 IDE will use early binding and help you with troubleshooting the problem.
Prerak Patel 19-Aug-11 7:07am    
When I debug, it just works fine without any error. Error comes only when it is called from script without debugging.
[no name] 19-Aug-11 15:26pm    
It could be permission problem in Windows 7. Make sure your NETWORKSERVICE account (or any other account ASP.NET is running as) has permissions to the folder where the COM DLL resides.
Prerak Patel 22-Aug-11 23:55pm    
Thanks Shameel for the interest. I found a classic work around. I couldn't find the exact reason, but I just placed a delay in loop. The old code was working fine for years on XP, I wonder what's wrong in Weven!
There was a loop to process n nummber of objects. And there it was getting stuck after some iteration. I couldn't find the exact reason, but tried out some random stuffs and found the classic work-around - "Delay".

I replaced ShowName o.Cases(i).Name with a loop which puts a delay and try it again and again until it succeeds. You may like to put the limit on number of retries in while like while attempts < 10.
VB
Do
  If Err.Number <> 0 Then DoEvents : Sleep 2000 : DoEvents : Err.Clear
  ShowName o.Cases(i).Name
Loop While Err.Number <> 0


PS: Sleep is an API call
VB
Private Declare Sub Sleep Lib "kernel32.dll" (ByVal dwMilliseconds As Long)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900