appdomain

How can I prevent AppDomainUnloadedException after NUnit tests PLINQ code?

How can I diagnose and minimize or prevent AppDomainUnloadedException? NUnit 2.5.2 consistently throws AppDomainUnloadedException after long (>10s) tests involving PLINQ. Back in July 2008, Stephen Toub said: Yes, the scheduler in the CTP doesn't handle thread aborts very well, which frequently causes the process to crash when...

appdomain c++ c#

hello, when we write Assembly asm = AppDomain.CurrentDomain.Load(SomeByteArray); when SomeByteArray read from .net .exe all is ok, and when from c++, error. for this function is important using .net exe ? if yes please other way to do this. thanks ...

How to completely reset a c# app in code?

I have an app with login/logout functionality. When the user logs out, I want to completely reset all classes and variables (I use static classes so this makes the problem even harder). I have decided that its best to just leave the resetting and do a total reload of the app - the user wouldn't know the difference and it would clear any...

How to properly access the PrivateBinPath property of the current AppDomain?

Since AppDomain.AppendPrivatePath() is obsolete, I'm trying to figure out how to specify a PrivateBinPath for the current AppDomain in my project without spinning up a whole new AppDomain, and being able to access it later. I know I can set the PrivateBinPath on an AppDomainSetup object (which would be ok if I wanted to create a new App...

.NET System.OutOfMemoryException and AppDomains

Hi, I have a plugin manager that launches a plugin which connects to a FoxPro database through the ADO.NET OLE DB provider. At one client site connections are opened and closed without any problems but at another client site, it gets stuck in 'connection.Open();' and within a couple of seconds over 1GB of memory is allocated. With...

Restrict plugin access to file system and network via appdomain

I asked a while ago how to restrict plugins access ( I want to prevent them from writing to the disk or network ) and i was told to use AppDomain. I have searched and tried and failed on how to get this working. Can anyone provide some information so i can get started, simply put make a AppDomain that does not allows writing to the file...

Passing a lambda to a secondary AppDomain as a stream of IL and assembling it back using DynamicMethod

Is it possible to pass a lambda expression to a secondary AppDomain as a stream of IL bytes and then assemble it back there using DynamicMethod so it can be called? I'm not too sure this is the right way to go in the first place, so here's the (detailed) reason I ask this question... In my applications, there are a lot of cases when I ...

Using the LoaderOptimizationAttribute on a WCF service

I have a wcf service that uses the .net System.AddIns framework to load assemblies into a seperate process and app domain. To improve performance I want to enable the Cross-Domain FastPath. According to the documentation I need to add the LoaderOptimizationAttribute attribute to the main method of my host application. However I do not h...

How to host an IronPython engine in a separate AppDomain?

I have tried the obvious: var appDomain = AppDomain.CreateDomain("New Domain"); var engine = IronPython.Hosting.Python.CreateEngine(appDomain); // boom! But I am getting the following error message: Type is not resolved for member 'Microsoft.Scripting.Hosting.ScriptRuntimeSetup,Microsoft.Scripting, Version=0.9.0.0, Culture=neutral, Pu...

How to detect when application terminates?

This is a follow up to my initial question and I would like to present my findings and ask for corrections, ideas and insights. My findings (or rather interpretations) come from people's answers to my previous question, reading MSDN .NET 3.5 documentation and debugging .NET 3.5 code. I hope this will be of value to someone who was wonder...

Can I make the default AppDomain use shadow copies of certain assemblies?

A short explanation of why I want to do this: I am busy writing a plugin for Autodesk Revit Architecture 2010. Testing my plugin code is extremly cumbersome, as I have to restart Autodesk for each debug session, manually load a Revit project, click on the Add-Ins tab and then start my plugin. This is just taking too long. I have writte...

Is it possible to write a C# code, which would trigger the AppDomain.TypeResolve event?

Dear ladies and sirs. The AppDomain.TypeResolve is mysterious in my eyes. Can someone provide a sample code that triggers this event? Thanks. ...

How to load + unload ASPNET runtime, without using bin directory, for automated testing purposes

I want to load the ASPNET runtime, run one or more pages, then unload it. This is for testing purposes. It's not UI testing; I'm really just testing the use of a library in an ASPNET context. Normally this kind of thing is done with a call to System.Web.Hosting.ApplicationHost.CreateApplicationHost . This is how I have it currently...

Why are some .Net assemblies not available via an AppDomain's GetAssemblies() method?

I have a little bit of code that loops through the types currently loaded into an AppDomain that runs in an ASP.NET application. Here's how I get the assemblies: var assemblies = AppDomain.CurrentDomain.GetAssemblies(); When the application first starts up there is no problem and all the types I expect are present. But when I update t...

Timing initial startup in an ASP.NET application

My ASP.NET app takes a long time to load the first page request after an iisreset or app domain recycle. Is there a way to reliably measure the amount of time it takes for the app domain to recycle? ...

AppDomain.CreateInstanceFromAndUnwrap - Unable to cast transparent proxy

I'm writing a .NET library to inject managed DLLs into external processes. My current approach is: Use CreateRemoteThread to force the target process to call LoadLibrary on an unmanaged bootstrap DLL. From this point we're executing code in the target process. My bootstrap DLL then creates an instance of the CLR and calls ExecuteInDefa...

Is it likely appdomains will help in this scenario?

I have a dotnet process that through calls to an unmanaged dll is communicating with a Java process. Under some circumstances, the Java process appears to be crashing and taking my dotnet process down with it. No exceptions are raised, the process just dies. Upon crashing, java is creating a log file with names like "hs_err_pid3228" e...

Is there any difference between Console and WPF application? (Event cross AppDomain)

Hello there, I built some assemblies, one of them is to provide some functionalities and some events. some relationship as below: Assembly A is one interface facade component, it declares all service interfaces. Assembly B is one "Mock" implementation of all interfaces declared Assembly A (include event) Assembly C is one "Real" imple...

Unloading an appdomain with references

I'm new to using appdomains, so I'm learning as I go. I'm making use of appdomains to isolate plugin instances that I'm loading at runtime. If I am referencing a plugin object (in its own appdomain) from the main appdomain and I unload that plugin appdomain, will it fully unload? My understanding is that by referencing the plugin inst...

ASP.NET - context-agile object,Data sharing concept in application domain ?

I read some articles about Application Domain.The deep reading finally resulted in whirling confusion.So I submit the questions to subject experts. 1) As CLR takes care of creating AppDomain as and when needed,could there be a critical need to go for manual Application Domain Creation ? 2)I heard that one application domain can not...