app domain behavior for .net components accessed through COM interop - iis-7

I have searched the site for a similar question but did not find anything close. My apologies to the community if i missed it.
Setup:
Windows 2008, 64 bit server
Classic ASP applications (a few of them) deployed in the same application pool under IIS
Some pages in these classic ASP applications create and access .Net components exposed as COM components.
What we are seeing (we verified this by logging information about the current process and app domain from the .net components exposed through COM):
The .Net components exposed through COM interop are being loaded in a single app domain under the worker process created by IIS for the app pool regardless of which classic asp application under the app pool calls them. Basically, it is behaving as if IIS is creating a single app domain for COM interop components that is shared by all apps in that app pool. (by "shared" i mean that calls to these .Net components are all routed to that single app domain by IIS regardless of which web app under the app pool is initiating the call). I was expecting IIS to load the COM interop components in each web app's app domain.
[If we deploy the classic ASP apps in different app pools under IIS, then (obviously) the .Net components are loaded in an app domain within each worker process spun by IIS for each app pool.]
I was wondering if anyone else has seen this behavior and whether it is a known behavior with IIS 7.x and .Net COM components.

This is normal behaviour. When an external COM Client instantiates a COM Visible .NET component that .NET component is loaded into the Default AppDomian for that process. If a Default AppDomain does not exist then it is created.
Whilst in IIS7 running with an integrated pipeline it would be possible to change this behaviour it would break existing ASP websites that might be migrated to IIS7 that depend (even if that be inadvertently) on this behaviour.

Related

How to route request from one application pool to another in iis 6.0

I have got two web applications (separate virtual directories) residing in the DefaultAppPool on Windows Server 2003. My first application has got a link and when I click on it, the second application opens up.
Now I want to use different .Net framework for both web applications and for that in IIS 6.0, I will have to host them in separate app pools.
Now the question is - is it possible to host them in different app pools and keep the behavior intact so that if I click on the link in first web application, it can still open the second web application hosted in a different app pool?
Thanks in advance,
D
I think I've found the solution and it is simpler than what I actually thought.
Steps I took:
Create another app pool in IIS 6.0 on Windows Server 2003
Assign one of the web applications to this pool. So now I have two web applications in two different app pools. Currently both are having ASP.NET version as 2.0.50727
Change the ASP.NET version of one of the applications to 4.0.30319. So interesting fact to understand here is - in IIS 6, you can't set the .NET framework for an app pool. It actually assumes it from the first application in it and then applies it to all the web applications residing in this app pool
And it is done!!
It can be checked to list all the sites and which .NET versions they are configured to by using aspnet_iisreg -lk. Run this command from your .NET framework directory. For ex: C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319
Both the sites with different .NET framework will be listed
Hope this helps.

Starting .Net web service on the same port as the ASP.Net application

We have a simple Visual Studio solution containing 2 projects:
A.) Simple ASP.Net website
B.) RESTful web service hosted in another ASP.Net application
We want to simply start the projects in Debug mode (F5) and have A consume data from B through Ajax. We do not have the possibility to configure IIS on all development machines (because some of them are on the client's side). The problem might be that JavaScript needs to be in the same domain as the URL it posts to.
Is there any way we can use Visual Studio 2010 Development Server to start both applications simultaneously in debug mode on the same port?
If this is not possible, what is the next best thing you can recommend?
We solved this problem by installing IIS on the development workstation.
In each Visual Studio project, on the Web property page, select Use Local IIS Web server.
Do not check Use IIS Express. The Project URLs will be set to http:localhost/<projectname> (note: in the same domain). You’ll be prompted to Create a Virtual Directory for each. Each will be assigned to the default IIS app pool. Open the Internet Information Services (IIS) Manager. Click Application Pools on the left pane. On the right pane add another integrated application pool. For one of the applications, open the Advanced Settings... In the properties view select the app pool you just created as the application pool. The applications should be debuggable in parallel because each Application Pool spawns a new operating system process to which a separate debugger can be attached.
Yo won't be able to host different apps on the same port within a Cassini instance, there are tools that might be useful but I would leave Cassini host them on different ports which is its regular behavior.
Options are (not tested):
UltiDev
Cassini Extesion
By the way, not sure if you know this, but to start both projects go to Set startup projects, there's an option on the Solution context menu.

Relating ASP.Net, WCF, App. Domain, Instance, Process , App. Pool , w3wp.exe

Situation:
I have website which calls WCF Service and i'm trying to understand it..
Question:
Consider i have a ASP.Net (IIS7 hosted) website how do i relate AppDomain, W3Wp.exe Process , Instance ,App.Pool.& How can i relate WCF service with (AppDomain, Instance ,App.Pool) with WAS server & Windows Service..when multiple requests are made to asp.net website & website calls WCF ..how it will be related with each other? i'am little confused...
If possible can anyone of you put a diagram to relate it..
Highly appreciate your responses
What exactly is it you need to know or doesn't understand?
W3Wp.exe is the process IIS uses to run a AppPool in
AppPool is a IIS concept, doesn't exist in .Net
Each website application runs in it own AppDomain
AppPools is run multiple website applications inside the same process
AppDomain is a .Net concept that relates to how code executes inside your application, establishes boundaries and such.
From MSDN: Represents an application domain, which is an isolated environment where applications execute.
You can have many AppDomains inside the same process, but AppDomains cannot live across different processes.
Code in one AppDomain can create new AppDomains
You can communicate across AppDomain boundaries via Remoting
Technique for communicating with another AppDomain in the same process, in another process or even on a remote computer is the same.
All code in .Net has to be executed inside a AppDomain. If you're hosting your WCF service in your ASP.Net application the WCF service will run in the same AppDomain as your ASP.Net application (see WCF and ASP.Net http://msdn.microsoft.com/en-us/library/aa702682.aspx). In that context the AppDomain will be running in a AppPool inside IIS, but that hos nothing to do with .Net.
If you're hosting the WCF service in a Windows Service the WCF service will run inside the AppDomain created by the Windows Service, no AppPools involved here.
If your execution path is
Client requests asp.net webpage hosted on IIS
webpage requests WCF service hosted in a Windows Service
then there will be 1 AppPool, 1 W3Wp.exe process, 1 Windows Service process and 2 AppDomains involved.
I don't know if your question relates in any way to WCF service Appdomain details ?

Deploy ASP.NET application in the same web site as Sharepoint

I am trying to deploy the Bugtracker.NET tool (http://ifdefined.com/bugtrackernet.html), which is a normal ASP.NET 2.0 application, into the default web site of an IIS which already has Sharepoint installed in it. The OS is Windows Server 2008 R2, IIS 7.5 and Sharepoint Services 3.0.
The question is that when I execute the application, I get a NullReferenceException because HttpContext.Current.Session is null, and I think that this could be due to a problem with the configuration of the web site, as the application runs perfect in web sites with no Sharepoint installed.
I already know that Sharepoint customizes the web site with handles, modules and so on, that all applications in the web site inherit, modifying their behavior. I have already given to the ASP.NET application Full trust level, enabled Anonymous authentication and InProc session state, but I am still getting that HttpContext.Current.Session is null. Even changing the app pool from Wss3AppPool to DefaultAppPool does not succeed.
Maybe someone could tell me which settings do I need to tweak in the web site in order to avoid this exception.
Many thanks in advance.
José Antonio Arroba
You need to look into Managed Paths and excluding the path to your bugtrackernet app.
However why do you HAVE to use the default web application?
Why not keep your life simple and setup a new IIS web application on a separate host header or subdomain and host your app there.
e.g.
http://bugtracker.yourdomain/
or just
http://bugtracker/

IIS6 | Application Pools | ASP.NET Framework

In IIS6 it's possible to have more than one ASP.NET application running in the same application pool. This is fine, except that there is nothing in IIS6 that prevents you from running multiple .NET versions in the same pool.
When you create application pools in IIS7 you must explicitly state was .NET version will be running in that pool. Running multiple .NET versions in IIS7, in the same application, is impossible.
How can I enforce such rules on my IIS6 server in order to prevent my deployment team from creating such problems?
What I do:
Step 1. Create the following application pools:
.NET 1.1 Apps
.NET 2.0 Apps
Step 2. Disable the "Default App Pool"
Now, any time a new application is configured in IIS, it will not work right away because the default app pool is disabled. This forces the person configuring the application to select an app pool that is appropriate for the .NET framework version of the app.
We tend to use one application pool per site, so that each application is isolated in its own process space. Application pool recycles will only affect a single application, and each worker process ends up with its own 4gb memory space. Badly programmed applications have no chance of affecting other applications, resulting in a highly isolated deployment model.
We've also standardized on x64 OS builds running 32bit application pools. While there is overhead using this technique since each application ppol contains a separate copy of the .Net framework, we feel that the added granularity of the application space adds stability to our deployments. You also get the ability to run each application as it's own domain identity, allowing for further memory space isolation and eliminating any need for identity impersonate in web configs.
With IIS 7, you have the ability to run each application pool as either 32 bit or 64 bit, so you can run large memory applications in 64 bit application pools. IIS 7 application pool security is also much more simplified.
I don't think you can. What I do is name my app pools in IIS 6 so that they show what .Net version they host. That way it's easy to pick the correct app pool when creating a new application.
If I remember correctly, you can also setup application pools in IIS6 (Windows 2003). Create one application pool per framework version in use.
I am not aware of any possibility to enforce the version of the .NET framework being used by an application. If you have setup an application pool to use .NET 1.1 and you have a .NET 2.0 application running in that application pool, you will get an exception in the application (yellow screen of death), since it will not find some referenced assemblies and classes.

Resources