?
Solved

works in VB, doesn in ASP...

Posted on 2000-01-12
9
Medium Priority
?
265 Views
Last Modified: 2012-06-27
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?

Thanks

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

0
Comment
Question by:Haho2
  • 3
  • 3
  • 2
  • +1
9 Comments
 
LVL 3

Expert Comment

by:halapaya
ID: 2345013
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
0
 
LVL 1

Expert Comment

by:vbyuval
ID: 2346138
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....
0
 

Author Comment

by:Haho2
ID: 2347868
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)
{
      AFX_MANAGE_STATE(AfxGetStaticModuleState())

      // 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;
}
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
LVL 1

Expert Comment

by:Vin32
ID: 2348101
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.

0
 

Author Comment

by:Haho2
ID: 2348227
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
0
 
LVL 1

Accepted Solution

by:
Vin32 earned 600 total points
ID: 2348972
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.
0
 
LVL 1

Expert Comment

by:vbyuval
ID: 2349685
In addition it's I it's recommended to convert all the variables to Variant just for any case .
0
 

Author Comment

by:Haho2
ID: 2351488
good point , but Vin32 clearly deserves the points for pointing out the problem out for me! :)
0
 
LVL 1

Expert Comment

by:Vin32
ID: 2351739
Thanks Haho2.
0

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

592 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question