将生产项目从.net 2.0升级到4.0后,我收到了System.Security.SecurityException。我可以传递基类型,例如通用数据集,就好了。但是,对于特定类型的数据集(XSD),我得到:
System.Reflection.TargetInvocationException occurred
HResult=-2146232828
Message=Exception has been thrown by the target of an invocation.
Source=mscorlib
StackTrace:
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)
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)
at System.Runtime.Remoting.Channels.SoapServerFormatterSink.ProcessMessage(IServerChannelSinkStack sinkStack, IMessage requestMsg, ITransportHeaders requestHeaders, Stream requestStream, IMessage& responseMsg, ITransportHeaders& responseHeaders, Stream& responseStream)
Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at DataBridgeWS.Admin.SaveJobData(DataSet jobds)
at IEDataBridge.Main.SaveJob() in C:\Source\IED\3.2\IEDataBridge\Main.vb:line 2733
InnerException: System.Security.SecurityException
GrantedSet=""
HResult=-2146233078
Message=Request failed.
PermissionState=<PermissionSet class="System.Security.PermissionSet"
version="1"
Unrestricted="true"/>
RefusedSet=""
Source=mscorlib
Url=""
StackTrace:
at System.Array.InternalCreate(Void* elementType, Int32 rank, Int32* pLengths, Int32* pLowerBounds)
at System.Array.CreateInstance(Type elementType, Int32 length)
at System.Data.DataTable.NewRowArray(Int32 size)
at System.Data.Index.GetRows(Range range)
at System.Data.DataColumn.IsNotAllowDBNullViolated()
at System.Data.DataSet.EnableConstraints()
at System.Data.DataSet.set_EnforceConstraints(Boolean value)
at System.Data.Merger.MergeDataSet(DataSet source)
at System.Data.DataSet.Merge(DataSet dataSet, Boolean preserveChanges, MissingSchemaAction missingSchemaAction)
at DataBridgeJobs.JobData..ctor(SerializationInfo info, StreamingContext context) in C:\Source\IED\3.2\DataBridgeJobs\JobData.Designer.vb:line 280
InnerException:
显然,.net 4安全性的变化导致了这个问题 - 但经过大量搜索和尝试不同的方法之后,我有点卡住了。除非绝对必要,否则我不想转移到WCF - 这是遗留产品。
我正在通过.config文件使用声明性设置。客户端和服务器都有:
此应用程序在Intranet上运行,后端托管在IIS中。所以它可以(并且是)一个完整的信任应用程序。)
以下是客户端exe.config的相关部分:
<system.runtime.remoting>
<application>
<channels>
<channel ref="http">
<serverProviders>
<formatter ref="binary" typeFilterLevel="Full"/>
</serverProviders>
</channel>
</channels>
</application>
</system.runtime.remoting>
这是服务器的web.config:
<system.runtime.remoting>
<application>
<channels>
<channel ref="http" machineName="localhost">
<clientProviders>
<formatter ref="binary" typeFilterLevel="Full"/>
</clientProviders>
</channel>
</channels>
<service>
<wellknown mode="SingleCall" type="DataBridgeWS.Admin, DataBridgeWS" objectUri="Admin.rem" />
<wellknown mode="SingleCall" type="DataBridgeWS.IEVData, DataBridgeWS" objectUri="IEVData.rem" />
</service>
</application>
</system.runtime.remoting>
任何指针都将非常感谢!