Microsoft KB Archive/822321

= PRB: No Option to Attach in Native Mode When the Native COM DLL Throws an Exception =

Article ID: 822321

Article Last Modified on 10/17/2003

-

APPLIES TO


 * Microsoft ASP.NET 1.1

-



SYMPTOMS
When you call a Component Object Model (COM) DLL from server-side Microsoft Active Server Pages (ASP) code, you may receive an exception. The native code of the COM DLL throws this exception, and the Just-In-Time Debugging dialog box appears without an option to attach to the native mode.



CAUSE
This behavior is by design because Microsoft Internet Information Services (IIS) catches the native exception and then turns this exception into a script error.



WORKAROUND
To work around this problem, manually attach the Dllhost.exe process to the native mode. To work around this problem for the scenario that is mentioned in the &quot;More Information&quot; section of this article, follow these steps:  In Microsoft Visual Studio .NET, open the Proj1 project.

Note Proj1 is the name of the project that is created in the &quot;More Information&quot; section of this article. In Windows Explorer, locate the DllStore folder that is created in the &quot;More Information&quot; section of this article. Drag the Cal.cls file to Visual Studio .NET where the Proj1 project is open.  In the Cal.cls file, set a breakpoint on the following statement: Function Divfunction(FirstNumber, SecondNumber)  On the Debug menu, click Processes, and then select the Dllhost.exe process that has the Title field as Microsoft Active Server Pages.

Note If the DLLHOST.EXE process is not available in the list of processes, click Start on the Debug menu to stop debugging. Click Attach. In the Attach to Process dialog box, click to select the Native check box, and then click OK.</li> In the Processes dialog box, click Close.</li> Visit the ASP page with the following URL:

http://localhost/Proj1/Asp1.asp

Notice that debugging breaks at the breakpoint that you have set in the Cal.cls file.</li></ol>

<div class="status_section">

STATUS
This behavior is by design.

<div class="moreinformation_section">

Create a COM DLL
<ol> Create a folder that is named DllStore to save your COM DLL.</li> Start Microsoft Visual Basic 6.0.</li> On the File menu, click New Project.</li> In the New Project dialog box, click to select ActiveX DLL, and then click OK.</li> On the View menu, click Properties Window.</li> In the Properties window, click Class1 in the (Name) list, and then change the Name property to Cal .</li>  Add the following code to the Cal class: Public Num1 As Variant Public Num2 As Variant Function DivFunc(Num1, Num2) DivFunc = Num1 / Num2 End Function </li> On the Project menu, click Project1 Properties.</li> Click the Compile tab, and then click to select the Create Symbolic Debug Info check box.</li> Click the General tab, change Project Name to Computation, and then click OK.</li> On the File menu, click Make Computation.dll.</li> In the Make Project dialog box, locate the DllStore folder that you created in step 1, and then click OK to save the Computation.dll file.</li> On the File menu, click Save Project As.</li> <li>In the Save File As dialog box, locate the DllStore folder that you created in step 1, and then click OK to save the Cal.cls file.</li> <li>In the Save Project As dialog box, click Save to save the Computation.vbp file.</li></ol>

Create an ASP.NET Project
<ol> <li>Start Visual Studio .NET.</li> <li>Create an ASP.NET Web Application project by using Microsoft Visual Basic .NET.

Note In the Location text box, type the project name as http://localhost/Proj1 .</li> <li>In Solution Explorer, right-click Proj1, point to Add, and then click Add New Item.</li> <li>In the Name text box, type Asp1.asp, and then click Open.</li> <li> Replace the existing code in the Asp1.asp file with the following code: <HTML> <TITLE>Test asp </TITLE> <BODY> <%   Dim finalanswer Dim addthis Set addthis=Server.CreateObject(&quot;Computation.Cal&quot;) finalanswer=addthis.DivFunc(15,0) Response.write finalanswer %> <BODY> <HTML> </li> <li>In Solution Explorer, right-click References, and then click Add Reference.</li> <li>Locate and then select the Computation.dll file that you created earlier, and then click Open.</li> <li>Click OK to add a reference to the Computation.dll file.</li> <li>On the Build menu, click Build Solution.</li> <li>In Solution Explorer, right-click Asp1.asp, and then click Set As Start Page.</li> <li>On the Debug menu, click Start.

The Just-In-Time Debugging dialog box appears that is mentioned in the &quot;Symptoms&quot; section of this article.</li> <li>When you click OK in the Just-In-Time Debugging dialog box, an Attach to Process dialog box that does not have the option to attach to the native mode appears.</li></ol>

<div class="references_section">