Web Q&A: Request Timeouts, Byte Array Conversio...

We were unable to locate this content in de-de.

Here is the same content in en-us.

Web Q&A
Request Timeouts, Byte Array Conversion, and More
Edited by Nancy Michell


Q I have an ASP.NET Web service and I continually get a ThreadAbortException. Is it possible that this is happening because I'm taking too long to read data from a database and the ASP timeout has been reached?
Q I have an ASP.NET Web service and I continually get a ThreadAbortException. Is it possible that this is happening because I'm taking too long to read data from a database and the ASP timeout has been reached?

A Yes. ASP.NET has a class called the RequestTimeoutManager whose job is to enforce the timeouts. At the beginning of the request, ASP.NET uses the current HttpContext object to create a RequestTimeoutEntry for each request, adding it to a list, and then removing it when the request has finished processing.
A Yes. ASP.NET has a class called the RequestTimeoutManager whose job is to enforce the timeouts. At the beginning of the request, ASP.NET uses the current HttpContext object to create a RequestTimeoutEntry for each request, adding it to a list, and then removing it when the request has finished processing.
However, if the request is in the list and it is scheduled to time out, then the runtime calls Thread.Abort to abort the thread executing the request. You can see this in the function TimeoutIfNeeded if you are looking at the Microsoft® intermediate language in ILDASM for the private System.Web.RequestTimeoutManager.RequestTimeoutEntry class. Depending on how long you want to allow for your database query, it might make sense to increase the timeout for that page so that you don't hit the limit.

Q How can I convert a byte array into usable info in VBScript?
Q How can I convert a byte array into usable info in VBScript?

A This question is asked rather frequently. Though VBScript has no ability to manipulate a byte array, OLE Automation does. If you pass the data to the CStr method, that should call OLE Automation's "convert this thing to a string" method, which will turn an arbitrary byte array "thing" into a Unicode string. You can then extract the bytes with the LenB, InstrB, and similar methods. It's a clunky solution, but it will work.
A This question is asked rather frequently. Though VBScript has no ability to manipulate a byte array, OLE Automation does. If you pass the data to the CStr method, that should call OLE Automation's "convert this thing to a string" method, which will turn an arbitrary byte array "thing" into a Unicode string. You can then extract the bytes with the LenB, InstrB, and similar methods. It's a clunky solution, but it will work.
A better solution would probably be to either use a language that supports the data type you want or use an object model that returns the data type you want, but you don't always have those choices available.

Q What exactly causes additional instances (additional processes) of iexplore.exe to run with Microsoft Internet Explorer 6.0? On some machines I only get one instance of Internet Explorer listed in Task Manager no matter how many windows are open. On other machines, when I look at Task Manager I find many instances.
Q What exactly causes additional instances (additional processes) of iexplore.exe to run with Microsoft Internet Explorer 6.0? On some machines I only get one instance of Internet Explorer listed in Task Manager no matter how many windows are open. On other machines, when I look at Task Manager I find many instances.
I have a related question as well. I am having difficulty getting the following line of code to work:
top.window.open("http://intranet", "name");
I am using Internet Explorer 6.0 and have much more than 32MB free. Any idea why this doesn't work? I just want to open a browser window in a new process.

A The most common reason for the failure of code like yours is popup-blocking applications. If any of these apps were installed on the target machine, that would cause this problem.
A The most common reason for the failure of code like yours is popup-blocking applications. If any of these apps were installed on the target machine, that would cause this problem.
As far as how a new process gets started, if you open new instances of Internet Explorer using either the Start menu, the quick launch, or some other method that runs iexplore.exe, then in reality a new process is being launched (see Figure 1 for an example).
Figure 1 Launching a New Process 
If you open a new Internet Explorer window from within an existing one using Ctrl+N, the window opens in the same process. In that case you are instantiating a window, and you'll only see one iexplore process running. When you launch an Internet Explorer window from an Internet Explorer process, there is still only one process running, regardless of the number of child windows. When you create a new process in Windows®, you create a new instance of an application that runs in its own main thread, gets allocated its own memory, and so forth.
An external application launches Internet Explorer by creating a new process. When you click on, say, a hyperlink in an MSN® Messenger window, a new Internet Explorer process is launched (which is a new instance of iexplore.exe). Since the HTTP protocol is registered with the shell to launch the default browser, that app is just ShellExecuting the href of the link, or even better (and more secure), passing the href as a parameter to an invocation of iexplore.exe (via CreateProcessEx or some other process-creation API).
Internet Explorer used to offer an option called "Launch Browser Windows in a Separate Process" but it's not available in newer versions of Internet Explorer, as the document at "Launch Browser Windows in a Separate Process" Setting Is Not Available in Internet Explorer 5.01 or Internet Explorer 5.5 explains.

Q I have some Microsoft Installer (MSI) packages and MSP patch packages in an IIS virtual directory. When I try to open these packages in Internet Explorer, the MSI packages open fine, but I get a "Page not found" error when I try to open MSP packages, even if I register the .msp extension with a MIME type of IIS. Do I need to add or modify any settings in IIS 6.0 or Internet Explorer 6.0 to fix this?
Q I have some Microsoft Installer (MSI) packages and MSP patch packages in an IIS virtual directory. When I try to open these packages in Internet Explorer, the MSI packages open fine, but I get a "Page not found" error when I try to open MSP packages, even if I register the .msp extension with a MIME type of IIS. Do I need to add or modify any settings in IIS 6.0 or Internet Explorer 6.0 to fix this?

A The only way to get IIS to do anything with the MSP file is to provide a mapping for the .msp extension, which is the way IIS handles requests for .asp files with asp.dll. Otherwise, you'll have the option to choose how you want the client (Internet Explorer) to act on the file. You probably don't really want to execute the MSP on the server, unless you intend to install an application on the server when a user browses to an MSP file. In the case of the MSI file, it should be executing on the client; when the user browses to somefile.msi they are prompted with a dialog to Open, Save As, or Cancel. If they choose Open, Internet Explorer will download the file to the user's Temporary Internet Files folder and then execute the MSI package. Choosing Save As will invoke the same download process, but the user will choose the folder they want to save the download into; it will not be executed. For more information see MIME Type Handling in Microsoft Internet Explorer.
A The only way to get IIS to do anything with the MSP file is to provide a mapping for the .msp extension, which is the way IIS handles requests for .asp files with asp.dll. Otherwise, you'll have the option to choose how you want the client (Internet Explorer) to act on the file. You probably don't really want to execute the MSP on the server, unless you intend to install an application on the server when a user browses to an MSP file. In the case of the MSI file, it should be executing on the client; when the user browses to somefile.msi they are prompted with a dialog to Open, Save As, or Cancel. If they choose Open, Internet Explorer will download the file to the user's Temporary Internet Files folder and then execute the MSI package. Choosing Save As will invoke the same download process, but the user will choose the folder they want to save the download into; it will not be executed. For more information see MIME Type Handling in Microsoft Internet Explorer.

Q When I select the "Open link in a new window" option within Internet Explorer, I want the new window maximized. I tried setting this registry key, but had no luck:
HKCU\Software\Microsoft\Internet Explorer\Document Windows\Maximized=yes
The following registry entry works, but it's equivalent to pressing F11—not what I want:
HKCU\Software\Microsoft\Internet Explorer\Main\Full Screen=yes
Q When I select the "Open link in a new window" option within Internet Explorer, I want the new window maximized. I tried setting this registry key, but had no luck:
HKCU\Software\Microsoft\Internet Explorer\Document Windows\Maximized=yes
The following registry entry works, but it's equivalent to pressing F11—not what I want:
HKCU\Software\Microsoft\Internet Explorer\Main\Full Screen=yes

A The only place you commonly see the "Maximized" registry value checked in code is during CD setup for autorun. By default, Internet Explorer will use the currently opened window size when launching a new window. Of course, this means it will also use the last valid window size for the Internet Explorer process. So if you open Internet Explorer, then open a new window, maximize that new window, close the old window, then close your maximized window, Internet Explorer will load maximized. This works for the main window but does not save the maximized state when you right-click on a link and choose to open in a new window.
A The only place you commonly see the "Maximized" registry value checked in code is during CD setup for autorun. By default, Internet Explorer will use the currently opened window size when launching a new window. Of course, this means it will also use the last valid window size for the Internet Explorer process. So if you open Internet Explorer, then open a new window, maximize that new window, close the old window, then close your maximized window, Internet Explorer will load maximized. This works for the main window but does not save the maximized state when you right-click on a link and choose to open in a new window.
Try this: set up a Web page that has hyperlinks on it. With no other iexplore.exe processes running, call iexplore.exe -k from the Start | Run dialog (this will load Internet Explorer in kiosk mode). Right-click on a shortcut and open the link; it should load in a new full-screen window. Close both the new window and the full screen window with Alt+F4. Now load Internet Explorer using the desktop icon. It should load full screen, as should the hyperlinked pages.

Q Are there any limitations on DataSet size in ADO.NET?
Q Are there any limitations on DataSet size in ADO.NET?

A There is no arbitrary limitation on the DataSet size. However, it was optimized for small rowsets, in the order of a few dozen to a few hundred rows. It's not recommended that you store 50,000 rows in your DataSet, for example, as performance will degrade more than linearly. Particularly for Web applications and Web services, it's best to keep the DataSet size as small as you can. However, what is reasonable performance for one application may be out of the question for another, so you should definitely test the likely usage scenarios before making any individual decisions.
A There is no arbitrary limitation on the DataSet size. However, it was optimized for small rowsets, in the order of a few dozen to a few hundred rows. It's not recommended that you store 50,000 rows in your DataSet, for example, as performance will degrade more than linearly. Particularly for Web applications and Web services, it's best to keep the DataSet size as small as you can. However, what is reasonable performance for one application may be out of the question for another, so you should definitely test the likely usage scenarios before making any individual decisions.

Q A client has placed his Visual Basic® 6.0 COM+ components on a Network Load Balanced app server because these servers also run an IIS Web app. On the rich client (also written with Visual Basic 6.0), they configure the "stubs" to call these components via the virtual IP address of the load-balanced server. Will this work? The client is encountering performance problems on his WAN.
Q A client has placed his Visual Basic® 6.0 COM+ components on a Network Load Balanced app server because these servers also run an IIS Web app. On the rich client (also written with Visual Basic 6.0), they configure the "stubs" to call these components via the virtual IP address of the load-balanced server. Will this work? The client is encountering performance problems on his WAN.

A It looks like the client is using DCOM between client and server. DCOM is a connection-oriented protocol and cannot be properly load balanced using Network Load Balancing. There will be load balancing when a client first connects, but after that the client requests will always go back to the same physical server. DCOM caches the actual IP address of the target machine. Therefore if the server should fail, the client will not automatically failover to a new server unless there is client-side code to detect the failure and reestablish the connection. New servers added to the server farm will not get any load at all until clients disconnect and reconnect or until new clients connect. Therefore, servers added at a later time will end up being very lightly loaded. When there are many clients and few servers you should see a reasonable distribution of load between the servers. But once the clients are up and running, that load will never be redistributed, even when a server is overutilized.
A It looks like the client is using DCOM between client and server. DCOM is a connection-oriented protocol and cannot be properly load balanced using Network Load Balancing. There will be load balancing when a client first connects, but after that the client requests will always go back to the same physical server. DCOM caches the actual IP address of the target machine. Therefore if the server should fail, the client will not automatically failover to a new server unless there is client-side code to detect the failure and reestablish the connection. New servers added to the server farm will not get any load at all until clients disconnect and reconnect or until new clients connect. Therefore, servers added at a later time will end up being very lightly loaded. When there are many clients and few servers you should see a reasonable distribution of load between the servers. But once the clients are up and running, that load will never be redistributed, even when a server is overutilized.
.NET Remoting over TCP/IP works in a similar manner. The real way to observe load balancing is to see what happens when one of the load balancing servers goes down. In the scenario you describe, it should cause creation of their components to fail.
As an alternative, you can load balance COM+ components using Application Center 2000; SP2 introduces support for the Microsoft .NET Framework. They can be installed on top of Windows Server™ 2003 (downloads are available at http://www.microsoft.com/applicationcenter/downloads).

Q I am trying to recover an XML string that's generated in a stored procedure through a FOR XML EXPLICIT clause, using the SqlCommand object. However, the string is truncated after approximately 2000 characters rather than the expected 9000. I used the ExecuteScalar method, then tried to use a DataSet filled using the SqlDataAdapter object, but neither worked as I expected.
Q I am trying to recover an XML string that's generated in a stored procedure through a FOR XML EXPLICIT clause, using the SqlCommand object. However, the string is truncated after approximately 2000 characters rather than the expected 9000. I used the ExecuteScalar method, then tried to use a DataSet filled using the SqlDataAdapter object, but neither worked as I expected.

A When you select XML output through regular ExecuteXxx methods, the server returns the data in chunks of up to 2048 nchars each. Since ExecuteScalar returns only the first value, you will only get the first 2048 nchars from this output.
A When you select XML output through regular ExecuteXxx methods, the server returns the data in chunks of up to 2048 nchars each. Since ExecuteScalar returns only the first value, you will only get the first 2048 nchars from this output.
If you were reading this output through ExecuteDataReader, you would have to keep reading and concatenating the first column values in each row in order to get the whole output. ExecuteXmlReader, on the other hand, processes these chunks itself and returns the whole output at once.

Got a question? Send questions and comments to  webqa@microsoft.com.

Thanks to the following Microsoft developers for their technical expertise: Olivier Arbey, Aaron Barth, Pablo Castro, Fabricio Catae, Sushil Chordia, Tom Cox, Jeff Davis, Denny Dayton, Ira Deshpande (Volt), Lale Divringi, Nick Duane, Omar Fadl, Naphtaly Friedman, Brent Goodpaster, Paul Harper, Ron Howe, Michael Joseph, Joonas Karjalainen, Marcin Kojlo, Eric Lippert, Tony Muniz, Michael Nelson, Jaret Russell (Volt), Joshua Schroeder, Malcolm Stewart, Charles Torre, Stephen Toub, Dino Viehland, Chek Yoon Wong, and Steven Wort


Page view tracker