.NET Framework Bookmark and Share   
 index > .NET Remoting and Runtime Serialization > Security BadImageFormatException
 

Security BadImageFormatException

We are attempting to migrate a Server 2003 C# application that makes heavy use of .NET Remoting to Vista/64. In our app.config file we use the following security setting:

<provider type="Microsoft.Runtime.Remoting.Security.SecurityClientChannelSinkProvider, Microsoft.Runtime.Remoting.Security, Culture=neutral, Version=2.0.18.0"
securityPackage="ntlm" impersonationLevel="identify" authenticationLevel="call" />

We are getting a BadFormatException with the following stack. If we remove the security section everything works fine:

System.Runtime.Remoting.RemotingException: Remoting configuration failed
with the exception 'System.Reflection.TargetInvocationException: Exception
has been thrown by the target of an invocation. --->
System.BadImageFormatException: is not a valid Win32 application.
(Exception from HRESULT: 0x800700C1)
at
Microsoft.Runtime.Remoting.Security.SecurityClientChannelSinkProvider..ctor
(IDictionary properties, ICollection providerData)
--- End of inner exception stack trace ---
at System.RuntimeMethodHandle._InvokeConstructor(Object[] args,
SignatureStruct& signature, IntPtr declaringType)
at System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags
invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr,
Binder binder, Object[] args, CultureInfo culture, Object[]
activationAttributes)
at
System.Runtime.Remoting.RemotingConfigHandler.CreateChannelSinkProvider(Sin
kProviderEntry entry, Boolean bServer)


Any hints would be greatly appreciated.

ken-ca-98045
Hi,

If you change the target platform from "Any CPU" to "X86", see whether this can handle this issue.

Riquel
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
Riquel_Dong
Yes, I am assuming that this a problem where x64 code is trying to call into win32 code. I have not tried in in x32 mode because we really don't want to be running in that mode. I would have thought that this would be handled by x64 code gracefully. .NET remoting is a basic Windows feature, and theoretically x64 is the wave of the future. I know that .NET remoting is or may become deprecated in favor of WCF. Everything else with x64 and .NET remoting does "just work".

So, maybe the question is, is there a security provider that is compatible with x64? Possibly we just need to change the version (currently 2.0.18.0 in the example) to something more recent?

Basically, there is no point in running the code on a X64 machine (and we do need to) if everything is running in x32 mode.
ken-ca-98045
Hi Ken,

Without your code, I don't know your scenario. Several days ago, I learned Managed DirectX. I also encounter the same exception. Also based on your scenario, I thought that this is one issue :64bit process calls 32bit component.

Please have a look at this article about migration from 32bit to 64bit.
Please check which component is 32bit in this scenario.
http://msdn.microsoft.com/en-us/library/ms973190.aspx


Best regards,
Riquel
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
Riquel_Dong
Hi Ken,

Without your code, I don't know your scenario. Several days ago, I learned Managed DirectX. I also encounter the same exception. Also based on your scenario, I thought that this is one issue :64bit process calls 32bit component.

Please have a look at this article about migration from 32bit to 64bit.
Please check which component is 32bit in this scenario.
http://msdn.microsoft.com/en-us/library/ms973190.aspx


Best regards,
Riquel
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.

Well, as I said I do suspect that there is 64 bit .net remoting code calling into a 32 bit security module. However, the real question is: "How do I get .net remoting to work securely with 64 bit code?". Surely somebody out there is doing this. I guess I'll start a new thread specifically asking that question.
ken-ca-98045

You can use google to search for other answers

Custom Search

More Threads

• A remote countdown clock?
• RemotingConfiguration.Configure ensureSecurity parameter
• passing an array of (marshalbyref)-objects gives parser error
• How to redirect/reroute 'nonresponsive' remoting method call to another remoting service.
• Serializable Error
• Accessing ActiveX dll in Server
• Remoting
• Business Objects - Please help!
• Messenger Like Functionality
• Second change Access Violation in Remoting / Class System.Collections.IEnumerator System.Collections. Since windows 2003 Sp2.