AppDomain does not load and unwrap objects correctly
- Dominant language
- PowerShell
- Stars
- 1.1k
- Forks
- 215
- Avg merge
- 4h 2m
- Merged PRs (30d)
- 1
Description
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.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.