Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 441
  • Last Modified:

Err.Raise Returns Wrong Info from OCX

We created a DCOM32.OCX.  We created a function called DCOM321.ErrorNumber as a temp for now, but we want to put the Err.Raise within it.  That way you can catch the error as a normal error at Client end.  When we try to connect to the remote server we can get server error's and then send them back to the Client EXE.  

One error being -2147221005 meaning cannot connect to server.

In the OCX we have something like this..
lr = functionname(parms)
msgbox lr            '  hr at this time is -2147221005
if hr <> 0 then
   Err.Number = lr
   Err.Raise lr + 27
   exit sub
endif

But the client EXE received -2147220978

Then we tried:

if lr <> 0 then
   lr = lr - 27
   Err.Number = lr
   Err.Raise lr + 27
   exit sub
endif

Then Client EXE received 429

The only way we can get this to work is at the client end we did this:
    msgbox Err.Description,,"Error: " & Err.Number - 27
That STINKS!

Help, on Raise, tells us to use the vbObjectError + 27 before it will work
properly.

Why must we add 27 to the ErrorObject?  
When we remove the + 27 then 429 is
sent back to the client EXE.
Because of this we can not get the error we want returned.
 
Any help would be Great!
0
Chizl
Asked:
Chizl
  • 3
  • 3
1 Solution
 
mrmickCommented:
Chizl, your error numbers should be between 0 and 65535.  Certain error numbers are reserved by VB.  You're first example shouldn't have worked according to the docs; however,

(-2147221005) + 27 = (-2147220978)

Is a true statement.  I would assume that since errors above 65535 or below 0 are not allowed, this behavior may not be reliable.

I suspect the 429 error you experienced in your second example was a runtime error 429 (ActiveX object can't create object) because of the improper use of the ERR object.

Pick a number like 20000 for example and raise the error as follows:

Const ErrNoConnect = 20000

Err.Raise vbObjectError + ErrNoConnect

0
 
ChizlAuthor Commented:
Thanx for the note, but that is already understood.  There is a way just maybe you and me don't know it..

-2147221005 is a Microsoft error that is returned from CLSIDFromString,
CLSIDFromProgID,
and CoCreateInstanceEx
API calls when connection to a remote server.   Using these calls disables VB debugging and we have figuared a way around it so ppl can debug again.  Miscrosoft knows of this problem and is fixed in VB6, but for now we are updating our DCOM32.ocx to return the error numbers that the API call returns to us.   http://www.karland.com/OurProducts/DCom32/ to see what we have so far.
0
 
ChizlAuthor Commented:
Oh, by the way as you can see we have returned -2147220978 so subtracting 27 from it should be possible.  We just didn't want the end user to have to do this.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
ChizlAuthor Commented:
-2147221005  == "Invalid class string" in MS terms..   If you have VC5 you can go into the BIN directory and launch ErrLookup
0
 
mrmickCommented:
Chizl, I didn't say it couldn't be done.  I have no idea what else may be affected if you go outside of the number range reserved for VB errors.  At best, my guess is you'll get unpredictable behavior (which might explain your experience).   Search help on "raise".
0
 
mrmickCommented:
Chizl, I didn't say it couldn't be done.  I have no idea what else may be affected if you go outside of the number range reserved for VB errors.  At best, my guess is you'll get unpredictable behavior (which might explain your experience).   Search help on "raise".
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now