Azure / Azure/Azure-Functions

AppDomain does not load and unwrap objects correctly

Aperta
#802 3 commenti 0 reazioni 1 assegnatario Rivendicata da @fabiocav Vedi su GitHub
Lingua principale
PowerShell
Stelle
1.1k
Fork
215
Merge medio
4h 2m
PR unite (30g)
1

Descrizione

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.

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.