views:

206

answers:

1

I’m doing maintenance on an asp.net web app that uses remoting to call a remote server object to order a credit report. The call “works on my machine” but throws an exception “could not load file or assembly ‘choicepointClue’” when run from the production server (which is running the 64 bit version of the .net framework).

I resolved the issue by copying choicepointClue.dll to the bin directory of the web app. But I don’t understand why it needs to be there as it’s a dependency of the remote server library not the client.

The dependency tree looks like this:

Web app --> choicepointClueClient --> choicepointRemoteAgent --> choicepointClue

There is no interface defined for the class in the choicepointRemoteAgent library (as there should be) so it is referenced directly by choicepointClueClient.

A class from choicepointRemoteAgent is instantiated using Activator.GetObject(). It’s at this point that I would expect choicepointClue.dll to be loaded on the remote server instead of the runtime trying to load it from the bin directory of the web app.

One crackpot theory that crossed my mind is that there is a difference between how assemblies are loaded on x64 vs x86.

So on x64 it tries to load choicepointClue as soon as it loads choicepointRemoteAgent, where on x86 it doesn’t try to load chiocepointClue until it’s explicitly called?

Obviously I have no idea what’s going on here. Can anyone shed some light on this?

+2  A: 

If the type being used is defined in choicepointClue.dll, it will need to exist on both the client and the server side of remoting.

The client needs to know the type information for what is being constructed, in order to work with it. The doesn't mean that it's being instantiated on the client - but in order to know how to work with the object (even remotely) the basic interfaces will need to be known on both ends.

Reed Copsey
The classes in choicepointClue.dll are used by choicepointRemoteAgent on the remote server. It seems to me that the client should only need to know the type information for choicepointRemoteAgent. Otherwise why would it work on my local machine without choicepointClue.dll? At first I thought it must be finding it somewhere other than the bin directory but I've verified that it doesn't exist anywhere locally.
Seth Reno
Where are the types used by choicePointClient defined? Normally, you need the "shared" interfaces/classes to be in a separate assembly, because those types need to be available to both client + server.
Reed Copsey
The types used by the client are defined in choicepointRemoteAgent. There is no shared interface in a separate assembly as you would expect. The choicepointRemoteAgent.dll exists on both the client and server.
Seth Reno
That's the problem. choicePointClient needs to load choicePointRemoteAgent.dll in order to understand and work with the types. In order to load choicePointRemoteAgent, the depdencies of that DLL must be available and loaded (including choicepointClue.dll).
Reed Copsey
I guess I would agree with that. I'm confused though because it works on my development pc w/o choicepointClue.dll. How do you explain that?
Seth Reno
No idea - Technically, I wouldn't expect it to work. .NET delay loads things, though, so it shouldn't necessarily have to load the dependent DLL (choicepointClue.dll) until it's needed [which, technically, should not really happen on the client's side]. It's possible that the platform difference on x64 is causing the dependency to be loaded sooner. This is a very common issue with remoting, though - which is why most books recommend remoting to interfaces in a DLL that is nothing but the interfaces required.
Reed Copsey
The platform difference was the only thing I could think to explain it as well. But it's just a guess, wish I could find it documented somewhere.
Seth Reno