问题标签 [appdomainsetup]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
157 浏览

log4net - 将 log4net 配置文件传递给新的 AppDomain

我需要做的是掌握:

值,但是当我尝试使用以下内容访问附加程序时:-

我发现我得到的都是空的。那么如何访问我的路径?

这是我的 log4net 配置部分:-

谢谢

0 投票
1 回答
133 浏览

c# - Code in Partially-Trusted AppDomain throws System.Security.Permissions.FileIOPermission on Relative Path resolve

I am adding a Sandbox layer to a framework that I have created.

The main concept is that the framework loads plugin-like DLLs.

On the plugin load, I create an AppDomain to isolate the execution and set the ApplicationBase of the AppDomain to the DLL's directory and set the access to full.

Now the problem is that, inside the plugins, although the base path is correctly set, if the code tries to load a file using it's relative path, .net will raise System.Security.Permissions.FileIOPermission exception.

However the same file will be easily loaded using the absolute path.

I have tried different Security Permissions sets but no one fixes the relative path loading issue.

Here is the code that I am using:

I am aware that I can just go for the first approach but I want the framework to be as flexible as possible, therefore I prefer to find a workaround for this issue.

Can anyone help with any solution or suggestions please?

0 投票
0 回答
803 浏览

.net - 如何在 Powershell 中使用 AppDomainInitializer

我正在尝试在 Powershell 脚本中创建 AppDomain。我在 C# 中实现了完全相同的,它似乎工作正常。但是,Powershell 版本总是失败并出现异常。脚本代码为:

例外是:未处理的异常:System.AccessViolationException:试图读取或写入受保护的内存。这通常表明其他内存已损坏。在 System.AppDomain.nCreateDomain(String friendlyName, AppDomainSetup setup, Evidence providedSecurityInfo, Evidence creatorsSecurityInfo, IntPtr parentSecurityDescriptor) ...

我在这里想念什么?

编辑1:

问题似乎出在 AppDomainSetup 中的委托上,Powershell 从中创建了一个动态方法。有没有办法改变这种行为?

0 投票
0 回答
599 浏览

c# - Assembly.Load + AppDomain.CreateDomain

我正在CLRHostHelper.dll使用方法加载新的程序集()Assembly.Load( byte[] )。从我正在调用的那个程序集中AppDomain.CreateDomain- 方法抛出异常:

Exception thrown: 'System.IO.FileNotFoundException' in mscorlib.dll Additional information: Could not load file or assembly 'CLRHostHelper, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.

据我所知,只有在磁盘上实际存在 .dll 时才能进行新的 appDomain 创建(使用AppDomainSetup domainSetup = new AppDomainSetup() { ApplicationBase = inDir };可以指定从哪个文件夹中) - 并且不能仅将其加载到 ram 中。

可以使用AppDomain.CurrentDomain.AssemblyResolve += newapp_AssemblyResolve;- 但该事件仅适用于当前 appDomain,不适用于新创建的。

也不可能立即挂钩新 appDomain 的 AssemblyResolve - 没有这样的方法。

在 AppDomainSetup 类中 - 还存在 AppDomainManagerAssembly 和 AppDomainManagerType - 更多信息可以从这里找到: https ://blogs.msdn.microsoft.com/shawnfa/2004/11/12/the-managed-hosting-api/ 理论上我们可以创建我们自己的 AppDomainManager,并覆盖 EntryAssembly 以提供我们自己的程序集,但是:

在这里,您再次指定程序集名称,该名称又需要从磁盘加载。

在这里 - http://andrewzak.tumblr.com/ -Small .NET desktop applications. Turning on shadow copying.有一些关于类似问题的提及,并且可能会使用SetAppDomainManagerType- 但没有执行此操作的实际示例。也许你能找到别的地方?

谁能推荐我如何从 ram 中的程序集创建 appDomain 而无需从硬盘执行任何加载(一切都将保存在 ram 中)。

0 投票
0 回答
125 浏览

c# - 卸载 AppDomain 后尝试删除 COM dll 文件时出现异常

卸载 AppDomain 后尝试删除 COM dll 文件时出现异常。异常详细信息:无法应用自动更新 System.UnauthorizedAccessException:对路径“IQVdxp32.dll”的访问被拒绝。代码:

0 投票
0 回答
77 浏览

reflection - VSIX:AppDomain CreateInstanceAndUnwrapError

我已经创建了 AppDomainSetup 并应用于控制台项目,它工作正常。但是当我用 VSIX 应用它时,它不起作用,我不知道为什么。你能不能有人调查一下并帮助我摆脱它。

VSIX MenuItemCallback 上的代码

0 投票
0 回答
239 浏览

c# - 应用域证据的目的?

我一直在研究应用程序域,以创建一个简单的轻量级应用程序,该应用程序将沙箱代码为我运行。我有一个简单的控制台应用程序,它允许我请求指定的代码来运行和设置权限等。

但是,我不确定证据参数到底是什么,我查看了多个来源和几本书,但至少看起来仍然很模糊。在某些地方和代码片段中,null 用于创建沙箱,而在其他地方,应用程序域是使用主机实际证据作为参数创建的。

所以我的问题是:

  • 证据参数究竟是做什么的?
  • 是否需要/它与权限集有什么不同?
  • 沙盒用户界面是否应该影响证据?
    • 就像这是一个需要根据.exe进行修改的参数?
0 投票
1 回答
472 浏览

c# - 未生成 AppDomain.DynamicDirectory

我正在使用以下代码创建 AppDomain

但是 _Domain.DynamicDirectory 属性不存在。https://msdn.microsoft.com/en-us/library/system.appdomain.dynamicdirectory(v=vs.110).aspx明确表示使用了 AppDomainSetup.DynamicBase。

在 vstest.console.exe 中执行更改应用程序域行为的原因可能是什么。有解决办法吗。

0 投票
1 回答
26 浏览

appdomain - 使用 AppDomain.Load 将 DLL 文件加载到新创建的应用程序域中。

我只是想弄清楚 AppDomain 并将 DLL 从不同位置加载到新创建的 AppDomain 中,并且遇到了困难。我知道我将使用不同的方法,但我仍在试图弄清楚这一点。这是该示例的背景故事。

我在 c:\DLLTest 中有一个名为 MyReadableDLL.dll 的 dll。以下是内容:

我在一个单独的项目中创建了一个 DomainBuilder,内容如下:

我不明白为什么当我获得 appDomain.Load 行时它会失败。根据我对 AddDomainSetup 的了解,AppliationBase 设置了用于检查 EXE/DLL 文件的默认目录,并且该文件夹中只有 MyReadableDLL 文件。我已经看到了许多使用 CreateInstanceFromandUnwrap 的解决方案,我确信我会朝那个方向发展。与此同时,我正在尝试找到一个工作示例 1) AddDomain 创建然后 2) AppDomain.Load 到新创建的域中。而已。我错过了什么?

0 投票
0 回答
36 浏览

sql-server - 在 SQL Express 的情况下如何管理 SQL 缓冲区

我正在使用具有 5-6 个数据库和更多用户的 sql express。在一段时间内,由于缓冲区已满,用户体验缓慢。或者由于该服务中止,CLR-AppDomain 正在下载另一个问题。

如果在同一个 SQL Server Express 中有多个数据库,那么管理缓冲区的最佳方法是什么?