| Author |
Message |
Uniwares_AS
Joined: 11 Oct 2007 Posts: 132
|
Posted: Wed Mar 23, 2011 3:40 pm Post subject: Exception: Invalid type owner for DynamicMethod. |
|
|
I am a bit lost on this one. It happened with SA5 and happens with SA6 but doesnt (of course) in the non-protected assembly.
What i get is the following:
System.ArgumentException occurred
Message=Invalid type owner for DynamicMethod.
Source=mscorlib
StackTrace:
at System.Reflection.Emit.DynamicMethod.Init(String name, MethodAttributes attributes, CallingConventions callingConvention, Type returnType, Type[] signature, Type owner, Module m, Boolean skipVisibility, Boolean transparentMethod)
InnerException:
The call stack though shows a bit more:
mscorlib.dll!System.Reflection.Emit.DynamicMethod.Init(string name, System.Reflection.MethodAttributes attributes, System.Reflection.CallingConventions callingConvention, System.Type returnType, System.Type[] signature, System.Type owner, System.Reflection.Module m, bool skipVisibility, bool transparentMethod)
mscorlib.dll!System.Reflection.Emit.DynamicMethod.DynamicMethod(string name, System.Type returnType, System.Type[] parameterTypes, System.Type owner, bool skipVisibility)
Uniwares.Mail.Server.dll!#e.#d.#F()
Uniwares.Mail.Server.dll!Uniwares.Mail.Server.ServiceApplication<.>.ServiceApplication()
[Native to Managed Transition]
[Managed to Native Transition]
Uniwares.Mail.Server.dll!Uniwares.Mail.Server.ServiceApplication<.>.#Xk(string methodName = "OnStart", object[] parameters = {object[0x00000001]})
Uniwares.Mail.Server.dll!Uniwares.Mail.Server.ServiceApplication<.>.Start()
Uniwares.Mail.Server.dll!Uniwares.Mail.Server.ServiceApplication<.>.ServiceMain(string[] args = {string[0x00000000]})
Uniwares.Mail.Server.dll!Uniwares.Mail.Server.SelfMonitoringServiceApplication<.>.Main2(string[] args = {string[0x00000000]})
aMandaServer.exe!..(string[] args = {string[0x00000000]})
[Native to Managed Transition]
[Managed to Native Transition]
Deobfuscating the trace:
mscorlib.dll!System.Reflection.Emit.DynamicMethod.Init(string name, System.Reflection.MethodAttributes attributes, System.Reflection.CallingConventions callingConvention, System.Type returnType, System.Type[] signature, System.Type owner, System.Reflection.Module m, bool skipVisibility, bool transparentMethod)
mscorlib.dll!System.Reflection.Emit.DynamicMethod.DynamicMethod(string name, System.Type returnType, System.Type[] parameterTypes, System.Type owner, bool skipVisibility)
Uniwares.Mail.Server.dll!SmartAssembly.HouseOfCards.Strings.CreateGetStringDelegate()
Uniwares.Mail.Server.dll!Uniwares.Mail.Server.ServiceApplication<.>.ServiceApplication()
[Native to Managed Transition]
[Managed to Native Transition]
Uniwares.Mail.Server.dll!Uniwares.Mail.Server.ServiceApplication<.>.InvokeServiceMethod(string methodName = "OnStart", object[] parameters = {object[0x00000001]})
Uniwares.Mail.Server.dll!Uniwares.Mail.Server.ServiceApplication<.>.Start()
Uniwares.Mail.Server.dll!Uniwares.Mail.Server.ServiceApplication<.>.ServiceMain(string[] args = {string[0x00000000]})
Uniwares.Mail.Server.dll!Uniwares.Mail.Server.SelfMonitoringServiceApplication<.>.Main2(string[] args = {string[0x00000000]})
aMandaServer.exe!..(string[] args = {string[0x00000000]})
[Native to Managed Transition]
[Managed to Native Transition]
The "Uniwares.Mail.Server.ServiceApplication<.>" doesnt deobfuscate at all, reason unknown yet.
Any ideas where to start? This used to work before, there has been no change at all in the Uniwares.Mail.Server.dll since ages. Changes have been applied to assemblies below and above the call chain. |
|
| Back to top |
|
 |
Brian Donahue
Joined: 23 Aug 2004 Posts: 6346 Location: Red Gate Software
|
Posted: Fri Mar 25, 2011 10:54 am Post subject: |
|
|
Hello.
It looks like this is one of those "you can't obfuscate anonymous types" issues that can happen with LINQ to SQL. The list of all the types I know of that must be excluded are listed on the SDK Wiki. (The list may be incomplete)
The bits that can't be deobfuscated probably exist in another assembly that has been protected with SmartAssembly at obfuscation level 2 or higher (non-ASCII) because you can't use the stack decoder except with ASCII obfuscation. _________________ Brian Donahue
Technical Support
Red Gate Software Ltd.
44 (0)870 160 0037 ext 8521
US and CAN 1-866-RED GATE ext 8521 |
|
| Back to top |
|
 |
Uniwares_AS
Joined: 11 Oct 2007 Posts: 132
|
Posted: Fri Mar 25, 2011 1:02 pm Post subject: |
|
|
I wish it was LINQ to SQL or at least LINQ at all, but its not. LINQ is not used at all.
The interesting thing I found out here is that in a release version without SA the exception is another one but its swallowed by the runtime.
The runtime tries to load an serialization assembly which doesn't exist but it continues without it (who has the guts to dive into such a thing?)
Yet, after protection it turns into something completely different which worries me a bit. |
|
| Back to top |
|
 |
Brian Donahue
Joined: 23 Aug 2004 Posts: 6346 Location: Red Gate Software
|
Posted: Fri Mar 25, 2011 1:40 pm Post subject: |
|
|
It looks like an anonymous type -- I'm not sure about all of the .NET objects that use them, but LINQ and lambda expressions are two I know of. _________________ Brian Donahue
Technical Support
Red Gate Software Ltd.
44 (0)870 160 0037 ext 8521
US and CAN 1-866-RED GATE ext 8521 |
|
| Back to top |
|
 |
Brian Donahue
Joined: 23 Aug 2004 Posts: 6346 Location: Red Gate Software
|
Posted: Tue Mar 29, 2011 1:08 pm Post subject: |
|
|
Did you try excluding the anonymous types? Sorry I don't know which - they appear to be non-ASCII obfuscated in another assembly of yours.
In my experience all .NET apps throw a serialization exception when they look for pre-compiled "XmlSerializers" assemblies, handle the exception, and emit an "XmlSerializers" assembly dynamically. _________________ Brian Donahue
Technical Support
Red Gate Software Ltd.
44 (0)870 160 0037 ext 8521
US and CAN 1-866-RED GATE ext 8521 |
|
| Back to top |
|
 |
Chris.Allen
Joined: 12 Mar 2009 Posts: 443
|
Posted: Tue Mar 29, 2011 1:22 pm Post subject: |
|
|
| Another line of attack- could you help us reproduce please? This allows us access to development resources and often speeds up resolution time dramatically. I can set you up any ftp space necessary. |
|
| Back to top |
|
 |
Uniwares_AS
Joined: 11 Oct 2007 Posts: 132
|
Posted: Tue Mar 29, 2011 11:01 pm Post subject: |
|
|
I guess what Brian said about the XmlSerializers is happening here (at the not protected app shows that), but what happens then with the protected app is at the moment out of my understanding.
I will be able to repro that for you but give me a few days resolver other issues first. |
|
| Back to top |
|
 |
|