murugamsm / xmlrpcnet

Automatically exported from code.google.com/p/xmlrpcnet
0 stars 0 forks source link

Calling Assembly.DefaultAssembly.DefineDynamicAssembly() in XmlRpcProxyGen class generates exception System.InvalidCastException at mscorelib #68

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Hi,

I'm trying to create a dll that uses XML-RPC to communicate with an
external resource.

I use the XmlRpcProxyGen.Create<T>(); call to instantiate a proxy with the
proper interface definition.

However the call to Create fails when
Assembly.DefaultAssembly.DefineDynamicAssembly is called later on in the
subsequent calls, with the following exception:

System.InvalidCastException was caught
  Message="Unable to cast object of type 'System.Reflection.Module' to type
'System.Reflection.Emit.ModuleBuilder'."
  Source="mscorlib"
  StackTrace:
       at
System.Reflection.Emit.AssemblyBuilderData.GetInMemoryAssemblyModule()
       at System.AppDomain.InternalDefineDynamicAssembly(AssemblyName name,
AssemblyBuilderAccess access, String dir, Evidence evidence, PermissionSet
requiredPermissions, PermissionSet optionalPermissions, PermissionSet
refusedPermissions, StackCrawlMark& stackMark, IEnumerable`1
unsafeAssemblyAttributes)
       at System.AppDomain.DefineDynamicAssembly(AssemblyName name,
AssemblyBuilderAccess access)
       at CookComputing.XmlRpc.XmlRpcProxyGen.BuildAssembly(Type itf,
String assemblyName, String moduleName, String typeName) in
C:\Xmlrpc\src\XmlRpcProxyGen.cs:line 96
       at CookComputing.XmlRpc.XmlRpcProxyGen.Create(Type itf) in
C:\Xmlrpc\src\XmlRpcProxyGen.cs:line 56
       at CookComputing.XmlRpc.XmlRpcProxyGen.Create[T]() in
C:\Xmlrpc\src\XmlRpcProxyGen.cs:line 40

Has anyone come across issues with assembly generation / reflection issues
like this before?

One point of concern is that the dll that uses XmlRpcV2.dll is by itself
dynamically loaded by the main executable at run time. Should that make a
difference in the usage of the XmlRpc library? 
(Normally we have no problem linking to and using 3rdparty dll:s from these
dynamically loaded add-in dll:s).

System info:
Using library version 2.4 (CookComputing.XmlRpcV2.dll).
Windows Vista Enterprise SP1 32 bit
Microsoft .Net Framework 2.0 SP1
Microsoft .Net Framework 3.5 SP1

Original issue reported on code.google.com by and...@gmail.com on 25 Mar 2010 at 2:41