cancel
Showing results for 
Search instead for 
Did you mean: 

Creating an AppDomain in a Unity Workflow Script

Tony_Rush1
Champ on-the-rise
Champ on-the-rise

Has anyone played around with creating an additional AppDomain in a Unity Workflow Script?  I have toyed around with it and cannot get the DoCallBack method to execute without error.  I get the following error on the "domain.DoCallBack" line of code:

 

Type 'Library.Library+<>c__DisplayClass5' in assembly 'UnityScript-Id147-Ver7, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' is not marked as serializable.

 

Here's my code:

 AppDomain domain = AppDomain.CreateDomain("anotherdomain", null);

CrossAppDomainDelegate action = () => {

 //it doesn't matter what I put in here

};

domain.DoCallBack(action); 

 

Why am I trying to create an additional AppDomain?  Because I have resources such as assemblies and Windows.Application (WPF) references that I create during the course of the script that I want to unload/release at the end.

1 REPLY 1

Brian_Koning
Star Contributor
Star Contributor

Hello Tony,

I apologize for the delay in our response to your question. At this point, my answer is probably of little use to you but might come in handy for others who are attempting the same thing.

As far as I know, creating your own AppDomains within a Unity Script is not a tested feature at all. I would say AppDomains fall outside of the defined script scope that Unity Scripts are attempting to emulate and may or may not work as expected. If you are part of an API Certified organization, the best course of action would be to contact us at API Support and troubleshoot with us through the problem.

Looking at the exception you mention and the little information there is, I would suggest you mark the DisplayClass class with the System.SerializableAttribute. My guess is .NET is attempting to serialize this DisplayClass for execution across the AppDomain boundry and cannot because it is not Serializable. I would need more information to confirm my suspicions, however.