malafaya9 / aspnetserve

Automatically exported from code.google.com/p/aspnetserve
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

Remove GAC Install Dependency #11

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Currently aspNETserve.Core must be registered in the GAC before the server
can start. This is due to the use of the CreateObject method on the
System.Web.Hosting.ApplicationManager object to create the
aspNETserve.Core.DomainHook object in the hosted AppDomain.

Perhaps another implementation can be found that removes the need to
install any components in the GAC.

Original issue reported on code.google.com by jason.wh...@gmail.com on 16 Jul 2008 at 2:20

GoogleCodeExporter commented 8 years ago
assigning this issue to release 1.3.1

Original comment by jason.wh...@gmail.com on 17 Aug 2008 at 5:20

GoogleCodeExporter commented 8 years ago
After long investigation, I see no easy way to _properly_ remove the GAC 
dependency.
So, for the time being, I am putting this ticket on hold.

As a interim solution checkout:
http://jason.whitehorn.ws/2008/08/24/aspNETserve+Without+GAC+Install.aspx

Original comment by jason.wh...@gmail.com on 24 Sep 2008 at 2:47

GoogleCodeExporter commented 8 years ago
To get around the GAC, see the hack used by the latest Cassini drop:
http://blogs.msdn.com/dmitryr/archive/2008/10/03/cassini-for-framework-3-5.aspx

In particular, check out CreateWorkerAppDomainWithHost in Server.cs. Here's the 
bit 
which may help you as well:

/* 
********************************************************************************
**
 *
 * Copyright (c) Microsoft Corporation. All rights reserved.
 *
 * This source code is subject to terms and conditions of the Microsoft Public
 * License (Ms-PL). A copy of the license can be found in the license.htm file
 * included in this distribution.
 *
 * You must not remove this notice, or any other, from this software.
 *
 * 
********************************************************************************
**/

static object CreateWorkerAppDomainWithHost(string virtualPath, string 
physicalPath, 
Type hostType) {
    // this creates worker app domain in a way that host doesn't need to be in GAC 
or bin
    // using BuildManagerHost via private reflection
    var uniqueAppString = string.Concat(virtualPath, physicalPath).ToLowerInvariant
();
    var appId = (uniqueAppString.GetHashCode()).ToString("x", 
CultureInfo.InvariantCulture);

    // create BuildManagerHost in the worker app domain
    var appManager = ApplicationManager.GetApplicationManager();
    var buildManagerHostType = typeof(HttpRuntime).Assembly.GetType
("System.Web.Compilation.BuildManagerHost");
    var buildManagerHost = appManager.CreateObject(appId, buildManagerHostType, 
virtualPath, physicalPath, false);

    // call BuildManagerHost.RegisterAssembly to make Host type loadable in the 
worker app domain
    buildManagerHostType.InvokeMember(
        "RegisterAssembly",
        BindingFlags.Instance | BindingFlags.InvokeMethod | BindingFlags.NonPublic,
        null,
        buildManagerHost,
        new object[] { hostType.Assembly.FullName, hostType.Assembly.Location });

    // create Host in the worker app domain
    return appManager.CreateObject(appId, hostType, virtualPath, physicalPath, 
false);
}

Original comment by azizatif on 21 Nov 2008 at 12:44