我目前正在尝试制作一个游戏引擎,尝试逐个复制统一功能,用于加载一些脚本,我没有问题,但是当我必须重新加载它们时,单声道编译失败,告诉我DLL是已经访问过,或者无法删除DLL文件。
这是我的代码:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Reflection;
using System.IO;
using System.Runtime.InteropServices;
using System.Threading;
using System.Diagnostics;
using System.Security.Policy;
using System.Security;
using System.Security.Permissions;
public class Proxy : MarshalByRefObject
{
public Assembly GetAssembly(string assemblyPath)
{
try
{
byte[] response = new System.Net.WebClient().DownloadData(assemblyPath);
return Assembly.ReflectionOnlyLoad(response);
}
catch (Exception)
{
return null;
}
}
public Assembly GetAssembly2(string assemblyPath, AppDomain domain)
{
try
{
byte[] bytesDLL = new System.Net.WebClient().DownloadData(assemblyPath);
return domain.Load(bytesDLL);
}
catch (Exception)
{
return null;
// throw …Run Code Online (Sandbox Code Playgroud)