0

I have a C# wrapper over C library. In C lib I have function which takes callback as input. In C# I have exposed callback like delegate.

Everything works fine in normal mode but when I try to call same function in remoting mode it gives exception like Could not load file or assembly. My scenario for remoting is like

1)SharedLib: I have a c# shared lib which has functions which are wrapper over C functions. All functions are defined in this lib.

2)Server Console Application: Role of server is to get session from Shredlib and open a port so that client ask server for Session

3)Client Console application: Client listen to port opened by server and get session object from server.It defines a functions having same signature as delegate in sharedlib On session object client calls method from sharedLib which take callback as input. Client pass address of method having same signature like delegate to method from sharedLib which expects callback as input.

After this I got exception like "Could not load file or assembly."

If I pass null to parameter which take callback as input then everything works fine in remoting mode also. So can anybody help in using callback in remoting mode.

1 Answers1

0

Three suggestions:

1) Are the different AppDomains running at the same trust level? The second domain may not have permissions to load assemblies if the trust level is lower.

2) The remote application doesn't have all of the dependencies required available to it in the directories it loads assemblies from.

3) Are both applications running under the same version of .NET? If one is .NET 4.5 and one is .NET 3.5 and there's a .NET 4.0 assembly there, then the second process would not be able to run it.

You could try turning on Fusion assembly binding logging to see if there's a more detailed reason why the load fails.

Martin Costello
  • 9,672
  • 5
  • 60
  • 72
  • Detailed exception is Could not load file or assembly 'select_bodies_with_class_selection_and_filter_callback, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'or one of its dependencies. The system cannot find the file specified. Exception has been thrown by the target of an invocation. Server stack trace: at System.RuntimeMethodHandle.SerializationInvoke(IRuntimeMethodInfo method, Object target, SerializationInfo info, StreamingContext& context) at System.Runtime.Serialization.ObjectManager.CompleteISerializableObject(Object obj, SerializationInfo info, StreamingContext context) – user1305218 Apr 01 '14 at 12:02
  • at System.Runtime.Serialization.ObjectManager.FixupSpecialObject(ObjectHolder holder) at System.Runtime.Serialization.ObjectManager.DoFixups() at System.Runtime.Serialization.Formatters.Soap.ObjectReader.Deserialize(HeaderHandler handler, ISerParser serParser) at System.Runtime.Serialization.Formatters.Soap.SoapFormatter.Deserialize(Stream serializationStream, HeaderHandler handler) at System.Runtime.Remoting.Channels.CoreChannel.DeserializeSoapRequestMessage(Stream inputStream, Header[] h, Boolean bStrictBinding, TypeFilterLevel securityLevel) – user1305218 Apr 01 '14 at 12:03
  • at System.Runtime.Remoting.Channels.SoapServerFormatterSink.ProcessMessage(IServerChannelSinkStack sinkStack, IMessage requestMsg, ITransportHeaders requestHeaders, Stream requestStream, IMessage& responseMsg, ITransportHeaders& responseHeaders, Stream& responseStream) – user1305218 Apr 01 '14 at 12:03
  • "select_bodies_with_class_selection_and_filter_callback, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'" looks like some kind of anonymous type generated in a temporary assembly (the 0.0.0.0 version is suspicious). Compiler-generated types aren't decorated as [Serializable], so can't be remoted. Maybe that's where your problem lies. – Martin Costello Apr 01 '14 at 13:00