-
Notifications
You must be signed in to change notification settings - Fork 259
Description
A hosted script 'A' defines a script specific class TypeX
. That TypeX
accesses an event of the hosting application. The script can be started, the event can be handled. So far, all fine.
Another hosted script 'B' defines another script specific class TypeY
. That TypeY
also accesses the event of the hosting application. When trying the invoked that script, a TypeLoadException
is thrown:
System.TypeLoadException: Der Typ "Test.ScriptB.TypeY" in der Assembly "Script, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null" konnte nicht geladen werden.
Stack:
bei System.Reflection.Assembly._GetType(String name, Boolean throwOnError, Boolean ignoreCase)
bei System.Reflection.MemberInfoSerializationHolder..ctor(SerializationInfo info, StreamingContext context) bei CSScriptLibrary.AsmBrowser.Invoke(Object obj, String methodName, Object[] list)
bei CSScriptLibrary.AsmRemoteBrowser.Invoke(String methodName, Object[] list)
Exception rethrown at [0]:
bei CSScriptLibrary.IAsmBrowser.Invoke(String methodName, Object[] list)
bei CSScriptLibrary.AsmHelper.Invoke(String methodName, Object[] list)
bei .InvokeAssembly(String assemblyFilePath, AsmHelper helper, String scriptMainMethod, Boolean scriptMainHasArgs)
Interestingly, this only happens if both scripts are compiled into an assembly with the same name, in this case Script.dll
. If they are built into ScriptA.dll
and ScriptB.dll
, all works fine.
Additional findings:
- It doesn't matter whether type has same or different name.
- It doesn't matter whether type is
MarshalByRefObject
or not. - It doesn't matter whether CSScript caching is enabled or not.
- It doesn't matter whether
CSScript.ShareHostRefAssemblies
istrue
orfalse
. - It does matter that script defined type is located in an assembly that has the same name as an assembly that got loaded before (e.g.
Script.dll
). - It does matter that script defined type accesses the hosting application.
Take your time in evaluating this issue. I can live with it for the moment, as it is a more or less rare use case of my hosting application.