Azure / Azure/Azure-Functions

AppDomain does not load and unwrap objects correctly

Offen
#802 3 Kommentare 0 Reaktionen 1 zugewiesene Person Beansprucht von @fabiocav Auf GitHub ansehen
Vorherrschende Sprache
PowerShell
Sterne
1.1k
Forks
215
Ø Merge
4 Std. 2 Min.
Gemergte PRs (30 T.)
1

Beschreibung

Using an AppDomain in Azure Functions causes the object to be null when it is unwrapped. For example, here is a class that attempts to create a new AppDomain:

```
public class Sandboxer
{
public void Run()
{
var location = typeof(OtherProgram).Assembly.Location;
AppDomainSetup ads = new AppDomainSetup();
ads.ApplicationBase = Path.GetDirectoryName(location);
AppDomain newDomain = AppDomain.CreateDomain("name", null, ads);
var obj = newDomain.CreateInstance(typeof(OtherProgram).Assembly.FullName, typeof(OtherProgram).FullName).Unwrap();
var other = obj as OtherProgram;
var other2 = obj as MarshalByRefObject;
}
}

public class OtherProgram : MarshalByRefObject
{
public void Main(string[] args)
{
Console.WriteLine(AppDomain.CurrentDomain.FriendlyName);
foreach (var item in args)
Console.WriteLine(item);
}
}
```

Calling Run() causes "other" to be null, but "other2" is a __TransparentProxy. It seems like it is finding and loading the dll, but doesn't understand the type.

This same code runs perfectly fine on a Console app.

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.