# Modular Server .NET

**URL:** https://talk.remobjects.com/t/modular-server-net/8381
**Category:** Remoting SDK
**Created:** [March 7, 2016, 3:27pm UTC](https://talk.remobjects.com/t/modular-server-net/8381 "2016-03-07T15:27:56Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![birger](https://talk.remobjects.com/letter_avatar_proxy/v4/letter/b/df705f/32.png) [@birger](https://talk.remobjects.com/u/birger)
#### Post date: [March 7, 2016, 3:27pm UTC](https://talk.remobjects.com/t/modular-server-net/8381/1 "2016-03-07T15:27:56Z")

</div>

I have tried with this sample:

[http://old.wiki.remobjects.com/wiki/Modular\_Server\_Sample\_(.NET)](http://old.wiki.remobjects.com/wiki/Modular_Server_Sample_%28.NET%29)

Do you have any recommendations concerning unloading assembly DLLs ?

There is an example here:

> <https://stackoverflow.com/questions/4145713/looking-for-a-practical-approach-to-sandboxing-net-plugins>

Or something like this:

var f := ‘\<path\_to\_dll\>’;  
var domain := AppDomain.CreateDomain(System.IO.Path.GetFileName(f));  
var reader := new System.IO.StreamReader(f, System.Text.Encoding.GetEncoding(1252), false);  
var b := new Byte[reader.BaseStream.Length];  
reader.BaseStream.Read(b, 0, System.Convert.ToInt32(reader.BaseStream.Length));  
domain.Load(b);  
reader.Close();  
domains.Add(System.IO.Path.GetFileName(f), domain);

It should then be possible to unload the AppDomain.

Any recommendations? Thanks.

---

<div class="post-metadata">

### Author: ![birger](https://talk.remobjects.com/letter_avatar_proxy/v4/letter/b/df705f/32.png) [@birger](https://talk.remobjects.com/u/birger)
#### Post date: [March 7, 2016, 3:31pm UTC](https://talk.remobjects.com/t/modular-server-net/8381/2 "2016-03-07T15:31:35Z")

</div>

I see this sample:

> [@Creating an appdomain](https://talk.remobjects.com/t/creating-an-appdomain/6763):
>
> A simple example of creating and destroying an AppDomain on .NET, and running code inside the app domain. Generally used to load plugins or other code that should allow for dlls to be unloaded after use. RemoteAppDomain = public class(IDisposable) public constructor; method Dispose; property Domain: AppDomain; readonly; property RemoteHelper: RemoteHelper; readonly; end; RemoteHelper = public class(MarshalByRefObject, IDisposable) private public method Run; …

I guess that would be the recommended way?  
Does it also work with RO/DA services inside the assembly?

---

<div class="post-metadata">

### Author: ![birger](https://talk.remobjects.com/letter_avatar_proxy/v4/letter/b/df705f/32.png) [@birger](https://talk.remobjects.com/u/birger)
#### Post date: [March 8, 2016, 11:47am UTC](https://talk.remobjects.com/t/modular-server-net/8381/3 "2016-03-08T11:47:27Z")

</div>

If I do the following:

var f := ‘filename.dll’;  
var domain := AppDomain.CreateDomain(System.IO.Path.GetFileName(f));  
var reader := new System.IO.StreamReader(f, System.Text.Encoding.GetEncoding(1252), false);  
var b := new Byte[reader.BaseStream.Length];  
reader.BaseStream.Read(b, 0, System.Convert.ToInt32(reader.BaseStream.Length));  
domain.Load(b);  
reader.Close();

The runtime-generated RODL works as expected, it shows the Service Methods from the loaded class library DLL.

However if I run this:

AppDomain.Unload(domain);

The Service Methods are still visible in the generated RODL - can I force the runtime-generated RODL to be regenerated?

---

<div class="post-metadata">

### Author: ![antonk](https://talk.remobjects.com/letter_avatar_proxy/v4/letter/a/a5b964/32.png) [@antonk](https://talk.remobjects.com/u/antonk)
#### Post date: [March 9, 2016, 9:26am UTC](https://talk.remobjects.com/t/modular-server-net/8381/4 "2016-03-09T09:26:45Z")

</div>

Hello

Could you create a small testcase of your server? By default RODL is generated only for the current AppDomain, so I would like to check how exactly did you get RODLes from the loaded assemblies to get merged into the main server’s RODL

Regards

---

<div class="post-metadata">

### Author: ![birger](https://talk.remobjects.com/letter_avatar_proxy/v4/letter/b/df705f/32.png) [@birger](https://talk.remobjects.com/u/birger)
#### Post date: [March 9, 2016, 10:07am UTC](https://talk.remobjects.com/t/modular-server-net/8381/5 "2016-03-09T10:07:34Z")

</div>

Here you have a test-case.  
[ROSDK\_Load\_Assembly.zip](https://talk.remobjects.com/uploads/default/original/2X/1/1e1ca05126c93bf1a7d60007142a0643a96a4116.zip) (119.7 KB)

---

<div class="post-metadata">

### Author: ![antonk](https://talk.remobjects.com/letter_avatar_proxy/v4/letter/a/a5b964/32.png) [@antonk](https://talk.remobjects.com/u/antonk)
#### Post date: [March 10, 2016, 1:48pm UTC](https://talk.remobjects.com/t/modular-server-net/8381/6 "2016-03-10T13:48:54Z")

</div>

Hello

The RODL generator was not designed to be used with multiple AppDomains. It works only with services defined in the main applcation Domain.
