- Home
- LLBLGen Pro
- LLBLGen Pro Runtime Framework
SecurityException after upgrading to .net 4
Joined: 11-Feb-2008
I have a client/server app with the server running in a console app. Both client and server are started from VS2010 F5. Remoting over HTTP is used for communication. I believe this was running ok under .net 3.5 but I've just upgraded to .net 4.0 and now, after some random time (typically 1 minute) it throws an exception on a remoting call. The same call works fine a number of times, and then something happens, like maybe a GC, and I get this exception:
[System.Security.SecurityException] {"Request failed."}
StackTrace from $exception:
at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck)
at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache)
at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipVisibilityChecks, Boolean skipCheckThis, Boolean fillCache)
at System.Activator.CreateInstance(Type type, Boolean nonPublic)
at System.Activator.CreateInstance(Type type)
at SD.LLBLGen.Pro.ORMSupportClasses.EntityFactoryCache2.GetEntityFactory(Type factoryType)
Console app stack trace:
> TheHub.Entities.dll!TheHub.Entities.EntityClasses.WorkflowEventEntity CreateEntityFactory() Line 487 + 0x22 bytes C#
SD.LLBLGen.Pro.ORMSupportClasses.NET20.dll!SD.LLBLGen.Pro.ORMSupportClasses. EntityBase2.EntityBase2(System.Runtime.Serialization.SerializationInfo info = {System.Runtime.Serialization.SerializationInfo}, System.Runtime.Serialization.StreamingContext context = {System.Runtime.Serialization.StreamingContext}) Line 286 + 0x17 bytes C#
TheHub.Entities.dll!TheHub.Entities.EntityClasses.CommonEntityBase. CommonEntityBase( System.Runtime.Serialization.SerializationInfo info = {System.Runtime.Serialization.SerializationInfo}, System.Runtime.Serialization.StreamingContext context = {System.Runtime.Serialization.StreamingContext}) Line 49 + 0x14 bytes C#
TheHub.Entities.dll!TheHub.Entities.EntityClasses.WorkflowEventEntity. WorkflowEventEntity(System.Runtime.Serialization.SerializationInfo info = {System.Runtime.Serialization.SerializationInfo}, System.Runtime.Serialization.StreamingContext context = {System.Runtime.Serialization.StreamingContext}) Line 123 + 0x13 bytes C#
[Native to Managed Transition]
[Managed to Native Transition]
mscorlib.dll!System.Runtime.Serialization.ObjectManager.CompleteISerializableObject( object obj, System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) + 0x189 bytes
mscorlib.dll!System.Runtime.Serialization.ObjectManager.FixupSpecialObject( System.Runtime.Serialization.ObjectHolder holder = {System.Runtime.Serialization.ObjectHolder}) + 0x30 bytes
mscorlib.dll!System.Runtime.Serialization.ObjectManager.DoFixups() + 0xc2 bytes
mscorlib.dll!System.Runtime.Serialization.Formatters.Binary.ObjectReader.Deserialize( System.Runtime.Remoting.Messaging.HeaderHandler handler = {Method = {System.Reflection.RuntimeMethodInfo}}, System.Runtime.Serialization.Formatters.Binary.__BinaryParser serParser, bool fCheck, bool isCrossAppDomain, System.Runtime.Remoting.Messaging.IMethodCallMessage methodCallMessage = null) + 0xc6 bytes
mscorlib.dll!System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize( System.IO.Stream serializationStream, System.Runtime.Remoting.Messaging.HeaderHandler handler, bool fCheck, bool isCrossAppDomain, System.Runtime.Remoting.Messaging.IMethodCallMessage methodCallMessage) + 0xcf bytes
mscorlib.dll!System.Runtime.Serialization.Formatters.Binary.BinaryFormatter. UnsafeDeserialize(System.IO.Stream serializationStream, System.Runtime.Remoting.Messaging.HeaderHandler handler) + 0x11 bytes
System.Runtime.Remoting.dll!System.Runtime.Remoting.Channels.CoreChannel. DeserializeBinaryRequestMessage(string objectUri = "/IWorkflowService.rem", System.IO.Stream inputStream = {System.Runtime.Remoting.Channels.Http.HttpFixedLengthReadingStream}, bool bStrictBinding = false, System.Runtime.Serialization.Formatters.TypeFilterLevel securityLevel = Low) + 0x98 bytes
System.Runtime.Remoting.dll!System.Runtime.Remoting.Channels. BinaryServerFormatterSink.ProcessMessage(System.Runtime.Remoting.Channels. IServerChannelSinkStack sinkStack = {System.Runtime.Remoting.Channels.ServerChannelSinkStack}, System.Runtime.Remoting.Messaging.IMessage requestMsg = null, System.Runtime.Remoting.Channels.ITransportHeaders requestHeaders = {System.Runtime.Remoting.Channels.BaseTransportHeaders}, System.IO.Stream requestStream = {System.Runtime.Remoting.Channels.Http.HttpFixedLengthReadingStream}, out System.Runtime.Remoting.Messaging.IMessage responseMsg = null, out System.Runtime.Remoting.Channels.ITransportHeaders responseHeaders = null, out System.IO.Stream responseStream = null) + 0x6ce bytes
System.Runtime.Remoting.dll!System.Runtime.Remoting.Channels.Http. HttpServerTransportSink.ServiceRequest(object state = {System.Runtime.Remoting.Channels.Http.HttpServerSocketHandler}) + 0x139 bytes
System.Runtime.Remoting.dll!System.Runtime.Remoting.Channels.SocketHandler. ProcessRequestNow() + 0x54 bytes
System.Runtime.Remoting.dll!System.Runtime.Remoting.Channels.RequestQueue. ProcessNextRequest(System.Runtime.Remoting.Channels.SocketHandler sh = {System.Runtime.Remoting.Channels.Http.HttpServerSocketHandler}) + 0x40 bytes
System.Runtime.Remoting.dll!System.Runtime.Remoting.Channels.SocketHandler .BeginReadMessageCallback(System.IAsyncResult ar = {System.Net.Sockets.OverlappedAsyncResult}) + 0xd6 bytes
System.dll!System.Net.LazyAsyncResult.Complete(System.IntPtr userToken) + 0x6c bytes
System.dll!System.Net.ContextAwareResult.CompleteCallback(object state) + 0x1a bytes
mscorlib.dll!System.Threading.ExecutionContext.runTryCode(object userData) + 0x51 bytes
[Native to Managed Transition]
[Managed to Native Transition]
mscorlib.dll!System.Threading.ExecutionContext.RunInternal(System.Threading. ExecutionContext executionContext, System.Threading.ContextCallback callback, object state) + 0x6a bytes
mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading. ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool ignoreSyncCtx) + 0x7e bytes
mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading. ExecutionContext executionContext, System.Threading.ContextCallback callback, object state) + 0x2c bytes
System.dll!System.Net.ContextAwareResult.Complete(System.IntPtr userToken) + 0x91 bytes
System.dll!System.Net.LazyAsyncResult.ProtectedInvokeCallback(object result, System.IntPtr userToken) + 0xbb bytes
System.dll!System.Net.Sockets.BaseOverlappedAsyncResult. CompletionPortCallback( uint errorCode, uint numBytes, System.Threading.NativeOverlapped* nativeOverlapped) + 0xb5 bytes
mscorlib.dll!System.Threading._IOCompletionCallback.PerformIOCompletionCallback( uint errorCode, uint numBytes, System.Threading.NativeOverlapped* pOVERLAP) + 0x74 bytes
[Native to Managed Transition]
Looking at the exception reveals this in m_debugString:
The action that failed was:
Demand
The type of the first permission that failed was:
System.Security.PermissionSet
The demand was for:
<PermissionSet class="System.Security.PermissionSet"
version="1"
Unrestricted="true"/>
The only permitted permissions were:
<PermissionSet class="System.Security.PermissionSet"
version="1">
<IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
version="1"
Flags="SerializationFormatter"/>
</PermissionSet>
The method that caused the failure was:
System.Runtime.Remoting.Channels.ServerProcessing ProcessMessage(System.Runtime.Remoting.Channels.IServerChannelSinkStack, System.Runtime.Remoting.Messaging.IMessage, System.Runtime.Remoting.Channels.ITransportHeaders, System.IO.Stream, System.Runtime.Remoting.Messaging.IMessage ByRef, System.Runtime.Remoting.Channels.ITransportHeaders ByRef, System.IO.Stream ByRef)
My App.config for the console app looks like this:
<?xml version="1.0"?>
<configuration>
<configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,log4net"/>
<section name="dependencyInjectionInformation" type="SD.LLBLGen.Pro.ORMSupportClasses.DependencyInjectionSectionHandler, SD.LLBLGen.Pro.ORMSupportClasses.NET20, Version=3.0.0.0, Culture=neutral, PublicKeyToken=ca73b74ba4e3ff27"/>
<section name="sqlServerCatalogNameOverwrites" type="System.Configuration.NameValueSectionHandler"/>
</configSections>
<appSettings>
<add key="connectionString" value="Server=localhost;Database=TBH;User Id=xxxx;Password=xxxx"/>
<add key="Environment" value="dev"/>
</appSettings>
<sqlServerCatalogNameOverwrites>
<add key="TBH" value=""/>
</sqlServerCatalogNameOverwrites>
<system.runtime.remoting>
<application>
<channels>
<channel ref="http" port="2223">
<serverProviders>
<formatter ref="binary"/>
<provider type="ServerObjects.Remoting.ErrorLoggerSinkProvider, ServerObjects"/>
<provider type="ServerObjects.Remoting.UserServerChannelSinkProvider, ServerObjects"/>
</serverProviders>
</channel>
</channels>
</application>
</system.runtime.remoting>
<dependencyInjectionInformation>
<additionalAssemblies>
<assembly fullName="TheHub.Shared, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"/>
</additionalAssemblies>
<instanceTypeFilters>
<instanceTypeFilter namespace="TheHub.Shared.Workflow"/>
</instanceTypeFilters>
</dependencyInjectionInformation>
<log4net>
<root>
<level value="INFO"/>
<appender-ref ref="ConsoleAppender"/>
<appender-ref ref="RollingFileAppender"/>
</root>
<appender name="ConsoleAppender" type="log4net.Appender.ConsoleAppender">
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date [%thread] %-5level %logger [%property{NDC}] - %message%newline"/>
</layout>
</appender>
<appender name="RollingFileAppender" type="log4net.Appender.RollingFileAppender">
<file value="log.txt"/>
<appendToFile value="true"/>
<rollingStyle value="Size"/>
<maxSizeRollBackups value="10"/>
<maximumFileSize value="100KB"/>
<staticLogFileName value="true"/>
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date [%thread] %-5level %logger [%property{NDC}] - %message%newline"/>
</layout>
</appender>
</log4net>
<system.web>
<httpModules>
<add name="ASPxHttpHandlerModule" type="DevExpress.Web.ASPxClasses.ASPxHttpHandlerModule, DevExpress.Web.v10.1, Version=10.1.5.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"/>
</httpModules>
</system.web>
<system.webServer>
<modules>
<add name="ASPxHttpHandlerModule" type="DevExpress.Web.ASPxClasses.ASPxHttpHandlerModule, DevExpress.Web.v10.1, Version=10.1.5.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"/>
</modules>
</system.webServer>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup></configuration>
As you can its failing before any of my code (at least server side) so I've not posted any.
This is .Net 4 in 64bit Windows 7. LLBLGen v3.0.10.1201 . SQL Server 2008.
Joined: 11-Feb-2008
I dont understand it either. I tried with fast serialization and its different in so much as it fails consistently at the same earlier point. I get 2 remoting calls successful (returning EntityCollections) and then it fails on the next one, which happens to have some prefetch details and a SortExpression. Stack trace is different to reflect the fastserializer, otherwise the error is the same:
mscorlib.dll!System.RuntimeType.CreateInstanceSlow(bool publicOnly, bool skipCheckThis, bool fillCache = true) + 0x63 bytes
mscorlib.dll!System.Activator.CreateInstance(System.Type type, bool nonPublic) + 0x46 bytes
SD.LLBLGen.Pro.ORMSupportClasses.NET20.dll!SD.LLBLGen.Pro.ORMSupportClasses.SerializationReader.ProcessObject(
SD.LLBLGen.Pro.ORMSupportClasses.SerializedType typeCode = SingleInstanceType) Line 1881 + 0xd bytes C#
SD.LLBLGen.Pro.ORMSupportClasses.NET20.dll!SD.LLBLGen.Pro.ORMSupportClasses.SerializationReader.ReadObject() Line 230 + 0x20 bytes C#
SD.LLBLGen.Pro.ORMSupportClasses.NET20.dll!SD.LLBLGen.Pro.ORMSupportClasses.SerializationReader.ReadTokenizedObject() Line 1538 + 0x9 bytes C#
SD.LLBLGen.Pro.ORMSupportClasses.NET20.dll!SD.LLBLGen.Pro.ORMSupportClasses.EntityCollectionBase2<TheHub.
Entities.EntityClasses.ShipLinkCountEntity>.DeserializeOwnedData(SD.LLBLGen.Pro.ORMSupportClasses.SerializationReader reader = {SD.LLBLGen.Pro.ORMSupportClasses.SerializationReader}, object context = {System.Collections.Specialized.BitVector32}) Line 1967 + 0x11 bytes C#
SD.LLBLGen.Pro.ORMSupportClasses.NET20.dll!SD.LLBLGen.Pro.ORMSupportClasses.EntityCollectionBase2<TheHub.
Entities.EntityClasses.ShipLinkCountEntity>.SD.LLBLGen.Pro.ORMSupportClasses.IOwnedDataSerializable.
DeserializeOwnedData(SD.LLBLGen.Pro.ORMSupportClasses.SerializationReader reader = {SD.LLBLGen.Pro.ORMSupportClasses.SerializationReader},
object context = {System.Collections.Specialized.BitVector32}) Line 2065 C#
SD.LLBLGen.Pro.ORMSupportClasses.NET20.dll!SD.LLBLGen.Pro.ORMSupportClasses.FastDeserializer.ReadCollection(
SD.LLBLGen.Pro.ORMSupportClasses.IFastSerializableEntityCollection2 collection = {TheHub.Entities.HelperClasses.EntityCollection<TheHub.Entities.EntityClasses.ShipLinkCountEntity>}, System.Collections.Specialized.BitVector32 serializationFlags = {System.Collections.Specialized.BitVector32}) Line 225 C#
SD.LLBLGen.Pro.ORMSupportClasses.NET20.dll!SD.LLBLGen.Pro.ORMSupportClasses.FastDeserializer.Deserialize(
SD.LLBLGen.Pro.ORMSupportClasses.IFastSerializableEntityCollection2 collection = {TheHub.Entities.HelperClasses.EntityCollection<TheHub.Entities.EntityClasses.ShipLinkCountEntity>}) Line 173 C#
SD.LLBLGen.Pro.ORMSupportClasses.NET20.dll!SD.LLBLGen.Pro.ORMSupportClasses.FastDeserializer.Deserialize(
byte[] serializedData = {byte[147]}, object root = {TheHub.Entities.HelperClasses.EntityCollection<TheHub.Entities.EntityClasses.ShipLinkCountEntity>}) Line 91 + 0x18 bytes C#
SD.LLBLGen.Pro.ORMSupportClasses.NET20.dll!SD.LLBLGen.Pro.ORMSupportClasses.SerializationHelper.Deserialize(
SD.LLBLGen.Pro.ORMSupportClasses.IEntityCollection2 entityCollection = {TheHub.Entities.HelperClasses.EntityCollection<TheHub.Entities.EntityClasses.ShipLinkCountEntity>}, System.Runtime.Serialization.SerializationInfo info = {System.Runtime.Serialization.SerializationInfo}, System.Runtime.Serialization.StreamingContext context = {System.Runtime.Serialization.StreamingContext}) Line 340 C#
SD.LLBLGen.Pro.ORMSupportClasses.NET20.dll!SD.LLBLGen.Pro.ORMSupportClasses.EntityCollectionBase2<
TheHub.Entities.EntityClasses.ShipLinkCountEntity>.EntityCollectionBase2(System.Runtime.Serialization.SerializationInfo info = {System.Runtime.Serialization.SerializationInfo}, System.Runtime.Serialization.StreamingContext context = {System.Runtime.Serialization.StreamingContext}) Line 152 C#
> TheHub.Entities.dll!TheHub.Entities.HelperClasses.EntityCollection<TheHub.Entities.EntityClasses.
ShipLinkCountEntity>.EntityCollection(System.Runtime.Serialization.SerializationInfo info = {System.Runtime.Serialization.SerializationInfo}, System.Runtime.Serialization.StreamingContext context = {System.Runtime.Serialization.StreamingContext}) Line 90 + 0x14 bytes C#
[Native to Managed Transition]
[Managed to Native Transition]
mscorlib.dll!System.Runtime.Serialization.ObjectManager.CompleteISerializableObject(object obj, System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) + 0x189 bytes
mscorlib.dll!System.Runtime.Serialization.ObjectManager.FixupSpecialObject(
System.Runtime.Serialization.ObjectHolder holder = {System.Runtime.Serialization.ObjectHolder}) + 0x30 bytes
mscorlib.dll!System.Runtime.Serialization.ObjectManager.DoFixups() + 0xc2 bytes
mscorlib.dll!System.Runtime.Serialization.Formatters.Binary.ObjectReader.Deserialize(
System.Runtime.Remoting.Messaging.HeaderHandler handler = {Method = {System.Reflection.RuntimeMethodInfo}}, System.Runtime.Serialization.Formatters.Binary.__BinaryParser serParser, bool fCheck, bool isCrossAppDomain, System.Runtime.Remoting.Messaging.IMethodCallMessage methodCallMessage = null) + 0xc6 bytes
mscorlib.dll!System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(
System.IO.Stream serializationStream, System.Runtime.Remoting.Messaging.HeaderHandler handler, bool fCheck, bool isCrossAppDomain, System.Runtime.Remoting.Messaging.IMethodCallMessage methodCallMessage) + 0xcf bytes
mscorlib.dll!System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.UnsafeDeserialize(
System.IO.Stream serializationStream, System.Runtime.Remoting.Messaging.HeaderHandler handler) + 0x11 bytes
System.Runtime.Remoting.dll!System.Runtime.Remoting.Channels.CoreChannel.DeserializeBinaryRequestMessage(
string objectUri = "/IDataService.rem", System.IO.Stream inputStream = {System.Runtime.Remoting.Channels.Http.HttpFixedLengthReadingStream}, bool bStrictBinding = false, System.Runtime.Serialization.Formatters.TypeFilterLevel securityLevel = Low) + 0x98 bytes
System.Runtime.Remoting.dll!System.Runtime.Remoting.Channels.BinaryServerFormatterSink.ProcessMessage(
System.Runtime.Remoting.Channels.IServerChannelSinkStack sinkStack = {System.Runtime.Remoting.Channels.ServerChannelSinkStack}, System.Runtime.Remoting.Messaging.IMessage requestMsg = null, System.Runtime.Remoting.Channels.ITransportHeaders requestHeaders = {System.Runtime.Remoting.Channels.BaseTransportHeaders}, System.IO.Stream requestStream = {System.Runtime.Remoting.Channels.Http.HttpFixedLengthReadingStream}, out System.Runtime.Remoting.Messaging.IMessage responseMsg = null, out System.Runtime.Remoting.Channels.ITransportHeaders responseHeaders = null, out System.IO.Stream responseStream = null) + 0x6ce bytes
System.Runtime.Remoting.dll!System.Runtime.Remoting.Channels.Http.HttpServerTransportSink.ServiceRequest(
object state = {System.Runtime.Remoting.Channels.Http.HttpServerSocketHandler}) + 0x139 bytes
System.Runtime.Remoting.dll!System.Runtime.Remoting.Channels.SocketHandler.ProcessRequestNow() + 0x54 bytes
System.Runtime.Remoting.dll!System.Runtime.Remoting.Channels.RequestQueue.ProcessNextRequest(
System.Runtime.Remoting.Channels.SocketHandler sh = {System.Runtime.Remoting.Channels.Http.HttpServerSocketHandler}) + 0x40 bytes
System.Runtime.Remoting.dll!System.Runtime.Remoting.Channels.SocketHandler.BeginReadMessageCallback(S
ystem.IAsyncResult ar = {System.Net.Sockets.OverlappedAsyncResult}) + 0xd6 bytes
System.dll!System.Net.LazyAsyncResult.Complete(System.IntPtr userToken) + 0x6c bytes
System.dll!System.Net.ContextAwareResult.CompleteCallback(object state) + 0x1a bytes
mscorlib.dll!System.Threading.ExecutionContext.runTryCode(object userData) + 0x51 bytes
[Native to Managed Transition]
[Managed to Native Transition]
mscorlib.dll!System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext executionContext,
System.Threading.ContextCallback callback, object state) + 0x6a bytes
mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext,
System.Threading.ContextCallback callback, object state, bool ignoreSyncCtx) + 0x7e bytes
mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state) + 0x2c bytes
System.dll!System.Net.ContextAwareResult.Complete(System.IntPtr userToken) + 0x91 bytes
System.dll!System.Net.LazyAsyncResult.ProtectedInvokeCallback(object result, System.IntPtr userToken) + 0xbb bytes
System.dll!System.Net.Sockets.BaseOverlappedAsyncResult.CompletionPortCallback(uint errorCode, uint numBytes,
System.Threading.NativeOverlapped* nativeOverlapped) + 0xb5 bytes
mscorlib.dll!System.Threading._IOCompletionCallback.PerformIOCompletionCallback(uint errorCode, uint numBytes,
System.Threading.NativeOverlapped* pOVERLAP) + 0x74 bytes
[Native to Managed Transition]
After several hours getting nowhere, I guess I'm not too worried: remoting seems to be deprecated in .net 4 in favour of WCF (goodbye generics and overloading :-() ) so I will switch to WCF and see if the problem just goes away.
Thanks for looking.
(please re-format stacktraces yourself next time -- Otis)