我目前在IIS下运行Framework 2上的.Net Remoting应用程序。我必须将其升级到Framework 4才能使用一些新组件。我已经能够在Framework 2上对所有东西都进行平滑的运行,但是一旦我更改为Framework 4,当我尝试调用远程对象的某个函数时,会出现以下异常。将.Net Remoting从Framework 2迁移到4的问题
The input stream is not a valid binary format.
The starting contents (in bytes) are:
53-79-73-74-65-6D-2E-52-75-6E-74-69-6D-65-2E-52-65 ...
此错误是不是真正的错误,它是由以下事实远程对象被抛出异常,和IIS包裹在XML除外,其抛出的BinaryFormatter关闭引起。 See this for more info on the bug。
这是因为我看不出是什么原因造成的例外,从来没有使用过任何Remoting是很不幸的,我没有太多的想法,从哪里开始调试。在执行代码之前,似乎抛出了异常,因为我做了大量的日志记录,而且没有任何一次触发。
基本上,我正在寻找从人们一些线索或指针遇到类似的问题:
- 什么引起的异常时,没有代码除了 编译从.net 2到.NET 4变?
- 如何获取返回的完整异常消息?
这里是获取远程对象
Dim clientProvider As BinaryClientFormatterSinkProvider = New BinaryClientFormatterSinkProvider()
Dim serverProvider As BinaryServerFormatterSinkProvider = New BinaryServerFormatterSinkProvider()
serverProvider.TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full
tsChannelName = System.Guid.NewGuid().ToString()
Dim props As IDictionary = New Hashtable()
props("port") = 0
props("name") = tsChannelName
props("typeFilterLevel") = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full
props("secure") = True
props("useDefaultCredentials") = True
Dim Channel As HttpChannel = New HttpChannel(props, clientProvider, serverProvider)
ChannelServices.RegisterChannel(Channel, False)
//Get the object on the Server
Dim rtnComm As I_CMQCComm = Activator.GetObject(GetType(I_CMQCComm), server)
//Knock knock
rtnComm.IsAlive() 'Exception is thrown here
我可以提供更多的信息,如所需要的代码。
您是否也编译过.NET 4的客户端代码? – 2012-02-29 20:48:20
是的!还改变IIS在ASP.NET 4上运行。我设法通过将我的格式化器更改为肥皂来查看确切的错误。我刚刚设法解决了这个问题,我会发表一个答案:) – Alexandre 2012-02-29 21:11:56