works in VB, doesn in ASP...

hi, I have a interesting problem here.
I created a VC6 COM object for use in VB and ASP. It works fine in VB but crashes the IIS4 when called from ASP.
What is the differences (memory allocation, etc) between VB and ASP that could cause this difference in general?
Any suggestions/ideas?


PS. My server is installed clean,
so it is not a corrupted server.

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

I think you should post some code part.. there can be lot of reasons.. i mean we are working with computers.

Give the few lines of code or the method which fails.. then can help
Does the COM get any parameters from the ASP ?
It can be conversion error after all ASP use Varient type and not
Integer,Long ,String....
Haho2Author Commented:
here is a basic code of a COM interface in VC6:
AnsiToUni and UniToAnsi are both workable functions.
does it look ok?

STDMETHODIMP CMyCOM::GetResultFunction (BSTR szTxnID, VARIANT *pvarAuthResult)

      // TODO: Add your implementation code here
      int                  iAuthResultLen = 0,
      ierr = 0;
      char            *pszTxnID = NULL,
                        *pszAuthResult = NULL;
      BSTR            szAuthResult = NULL;
      VARIANT            varAuthResult;

      UniToAnsi ( szTxnID, &pszTxnID );

      GetAuthorizationResultLength ( pszTxnID, &iAuthResultLen );
      pszAuthResult = (char *) LocalAlloc ( LMEM_ZEROINIT, sizeof(char) * (iAuthResultLen + 1) );
      if ( !pszAuthResult )
            return E_OUTOFMEMORY;

      ierr = CLibraryFunction( pszTxnID, pszAuthResult );

      AnsiToUni ( pszAuthResult, &szAuthResult );
      VariantInit ( &varAuthResult );
      varAuthResult.vt = VT_BSTR;
      varAuthResult.bstrVal = SysAllocString ( szAuthResult );

      *pvarAuthResult = varAuthResult;

      if ( pszTxnID )             LocalFree ( pszTxnID );
      if ( pszAuthResult ) LocalFree ( pszAuthResult );
      if ( szAuthResult )       LocalFree ( szAuthResult );

      return S_OK;
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

Yes I see the problem right there in the first line -- the function header itself.
ASP supports only two datatypes -- Variant and ADOR Recordsets. Hence whenever coding for ASP, all parameters to functions/procedures must be of either of these two datatypes.

BSTR won't work. What you can do is to typecast parameters into the correct type INSIDE the function.

Hope that helps.

Haho2Author Commented:
like this??
sorry cause I am not familiar with COM programming.

STDMETHODIMP CMyCOM::GetResultFunction (VARIANT szTxnID, VARIANT *pvarAuthResult)
 BSTR bstrTxnID = NULL;
 /* given that I know what field to access, in this case: bstrval */

 bstrTxnID = szTxnID.bstrVal;

increasing points
I don't think I can help you beyond this, as I am unfamiliar to VC. I've been coding in VB.

I hope the following linw that you have got successfully converts the variant szTxnID to a BSTR value.

 bstrTxnID = szTxnID.bstrVal;

If that is the case, then yes, it will work.

Good luck.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
In addition it's I it's recommended to convert all the variables to Variant just for any case .
Haho2Author Commented:
good point , but Vin32 clearly deserves the points for pointing out the problem out for me! :)
Thanks Haho2.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.