appdomain

How can I implement ISerializable in .NET 4+ without violating inheritance security rules?

不问归期 提交于 2020-02-26 05:05:28
问题 Background: Noda Time contains many serializable structs. While I dislike binary serialization, we received many requests to support it, back in the 1.x timeline. We support it by implementing the ISerializable interface. We've received a recent issue report of Noda Time 2.x failing within .NET Fiddle. The same code using Noda Time 1.x works fine. The exception thrown is this: Inheritance security rules violated while overriding member: 'NodaTime.Duration.System.Runtime.Serialization

How can I implement ISerializable in .NET 4+ without violating inheritance security rules?

廉价感情. 提交于 2020-02-26 05:05:28
问题 Background: Noda Time contains many serializable structs. While I dislike binary serialization, we received many requests to support it, back in the 1.x timeline. We support it by implementing the ISerializable interface. We've received a recent issue report of Noda Time 2.x failing within .NET Fiddle. The same code using Noda Time 1.x works fine. The exception thrown is this: Inheritance security rules violated while overriding member: 'NodaTime.Duration.System.Runtime.Serialization

StructureMap - Ability to replace an assembly at runtime

与世无争的帅哥 提交于 2020-02-08 02:42:07
问题 Example: Console application: class Program { static void Main(string[] args) { var calculator = ObjectFactory.GetInstance<ICalculator>(); for (var i = 0; i < 10; i++) { Console.WriteLine(calculator.Calculate(10, 5)); Console.ReadLine(); } Console.ReadLine(); } } Assembly "Interface": public interface ICalculator { int Calculate(int a, int b); } Assembly "Implemenation": internal class Calculator : ICalculator { public int Calculate(int a, int b) { return a + b; } } Assembly "Implemenation",

StructureMap - Ability to replace an assembly at runtime

a 夏天 提交于 2020-02-08 02:42:07
问题 Example: Console application: class Program { static void Main(string[] args) { var calculator = ObjectFactory.GetInstance<ICalculator>(); for (var i = 0; i < 10; i++) { Console.WriteLine(calculator.Calculate(10, 5)); Console.ReadLine(); } Console.ReadLine(); } } Assembly "Interface": public interface ICalculator { int Calculate(int a, int b); } Assembly "Implemenation": internal class Calculator : ICalculator { public int Calculate(int a, int b) { return a + b; } } Assembly "Implemenation",

How do I dynamically load raw assemblies that contains unmanaged code?(bypassing 'Unverifiable code failed policy check' exception)

微笑、不失礼 提交于 2020-01-30 19:43:25
问题 I'm going to give an example of using System.Data.SQLite.DLL which is a mixed assembly with unmanaged code: If I execute this : var assembly= Assembly.LoadFrom("System.Data.SQLite.DLL") No exceptions are thrown, but if I do this : var rawAssembly = File.ReadAllBytes("System.Data.SQLite.DLL"); var assembly = Assembly.Load(rawAssembly); The CLR throws a FileLoadException with "Unverifiable code failed policy check. (Exception from HRESULT: 0x80131402)". Let's say I'm trying to load this

How do I dynamically load raw assemblies that contains unmanaged code?(bypassing 'Unverifiable code failed policy check' exception)

做~自己de王妃 提交于 2020-01-30 19:43:19
问题 I'm going to give an example of using System.Data.SQLite.DLL which is a mixed assembly with unmanaged code: If I execute this : var assembly= Assembly.LoadFrom("System.Data.SQLite.DLL") No exceptions are thrown, but if I do this : var rawAssembly = File.ReadAllBytes("System.Data.SQLite.DLL"); var assembly = Assembly.Load(rawAssembly); The CLR throws a FileLoadException with "Unverifiable code failed policy check. (Exception from HRESULT: 0x80131402)". Let's say I'm trying to load this

Reflection & Application Design

久未见 提交于 2020-01-23 18:51:26
问题 Let me describe the problem and the solution i currently have and maybe you can help enlighten me on why it's a bad idea (assuming it is) and what i can do to make it a better system. right now i have 600 "rippers" that parse files and rip them to csv or other formats. the rippers all implement a common interface and base class. At the moment when a job is queued up depending on the configuration of that job a specific ripper is called using reflection. foreach (var stream in streams) { try {

SerializationException: Type is not resolved for member “…”

久未见 提交于 2020-01-14 07:02:27
问题 I've been trying to dynamically load an assembly to an AppDomain. I need to do it because I want to call a method dynamically, but don't keep the handle to the DLL while my app is running, so that it can be replaced, if needed. But I'm getting this SerializationException exception: Type is not resolved for member "..." Here's my code: AppDomain domain = AppDomain.CreateDomain("Temp AppDomain", null, AppDomain.CurrentDomain.SetupInformation); try { object obj = domain

SecurityException in Sandboxed AppDomain

百般思念 提交于 2020-01-13 10:15:10
问题 I'm attempting to use C# as a scripting language using CSharpCodeProvider (using VS2010 and .NET 4.0). I want the scripts to be run in a restricted AppDomain with minimal permissions. Currently, I'm getting an exception while trying to instantiate a class in the AppDomain (The call to CreateInstanceAndUnwrap() ). Here is some simplified code that reproduces the exception: using System; using System.Collections.Generic; using Microsoft.CSharp; using System.CodeDom; using System.CodeDom

Can an appdomain be restricted to one directory?

Deadly 提交于 2020-01-13 09:22:26
问题 I am developing a plugin host. The plugins should have as little trust as they need, however I want to have the possibility for a plugin to read and write files. Can the AppDomain where the assembly will be loaded be restricted to have access to only one directory for reading and writing? Other options and ways to go about this are also appreciated like for example easy ways to stream file data from the host to the plugin (reading) and from the plugin to the host (writing). If its relevant: I