New Posts New Posts RSS Feed: Strange error using ASPNet security
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Strange error using ASPNet security

 Post Reply Post Reply
Author
smi-mark View Drop Down
DevForce MVP
DevForce MVP
Avatar

Joined: 24-Feb-2009
Location: Dallas, Texas
Posts: 343
Post Options Post Options   Quote smi-mark Quote  Post ReplyReply Direct Link To This Post Topic: Strange error using ASPNet security
    Posted: 19-Feb-2011 at 2:22pm
I am experiencing a very strange error after integrating ASPNet security into my application. It does not matter if I use Forms or Windows, I get the same thing.

I am utilizing the IAuthenticationManager interface to link the querying EntityManager back to the one that provides authentication. There is nothing of note in the server debug log. The entity is called 'Employee' but as you can see it has a strange string appended to it.


Error: Unhandled Error in Silverlight Application
Code: 4004   
Category: ManagedRuntimeError      
Message: IdeaBlade.EntityModel.EntityServerException: There was an error while trying to serialize parameter http://ideablade.com/EntityModel:entityQuerySurrogate. The InnerException message was 'Type 'IdeaBlade.EntityModel.EntityQueryProxy`1[[FrameworkTest.Models.Northwind.Employee, FrameworkTest.Models.Northwind.SL, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]' with data contract name 'EntityQueryProxyOfEmployeeuAEoYKSe:http://ideablade.com/EntityModel' is not expected. Add any types not known statically to the list of known types - for example, by using the KnownTypeAttribute attribute or by adding them to the list of known types passed to DataContractSerializer.'.  Please see InnerException for more details. ---> System.ServiceModel.CommunicationException: There was an error while trying to serialize parameter http://ideablade.com/EntityModel:entityQuerySurrogate. The InnerException message was 'Type 'IdeaBlade.EntityModel.EntityQueryProxy`1[[FrameworkTest.Models.Northwind.Employee, FrameworkTest.Models.Northwind.SL, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]' with data contract name 'EntityQueryProxyOfEmployeeuAEoYKSe:http://ideablade.com/EntityModel' is not expected. Add any types not known statically to the list of known types - for example, by using the KnownTypeAttribute attribute or by adding them to the list of known types passed to DataContractSerializer.'.  Please see InnerException for more details. ---> System.Runtime.Serialization.SerializationException: Type 'IdeaBlade.EntityModel.EntityQueryProxy`1[[FrameworkTest.Models.Northwind.Employee, FrameworkTest.Models.Northwind.SL, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]' with data contract name 'EntityQueryProxyOfEmployeeuAEoYKSe:http://ideablade.com/EntityModel' is not expected. Add any types not known statically to the list of known types - for example, by using the KnownTypeAttribute attribute or by adding them to the list of known types passed to DataContractSerializer.
   at System.Runtime.Serialization.XmlObjectSerializerWriteContext.SerializeAndVerifyType(DataContract dataContract, XmlWriterDelegator xmlWriter, Object obj, Boolean verifyKnownType, RuntimeTypeHandle declaredTypeHandle)
   at System.Runtime.Serialization.XmlObjectSerializerWriteContext.SerializeWithXsiType(XmlWriterDelegator xmlWriter, Object obj, RuntimeTypeHandle objectTypeHandle, Type objectType, Int32 declaredTypeID, RuntimeTypeHandle declaredTypeHandle, Type declaredType)
   at System.Runtime.Serialization.XmlObjectSerializerWriteContext.InternalSerialize(XmlWriterDelegator xmlWriter, Object obj, Boolean isDeclaredType, Boolean writeXsiType, Int32 declaredTypeID, RuntimeTypeHandle declaredTypeHandle)
   at WriteConstantExpressionBlockToXml(XmlWriterDelegator , Object , XmlObjectSerializerWriteContext , ClassDataContract )
   at System.Runtime.Serialization.ClassDataContract.WriteXmlValue(XmlWriterDelegator xmlWriter, Object obj, XmlObjectSerializerWriteContext context)
   at System.Runtime.Serialization.XmlObjectSerializerWriteContext.WriteDataContractValue(DataContract dataContract, XmlWriterDelegator xmlWriter, Object obj, RuntimeTypeHandle declaredTypeHandle)
   at System.Runtime.Serialization.XmlObjectSerializerWriteContext.SerializeAndVerifyType(DataContract dataContract, XmlWriterDelegator xmlWriter, Object obj, Boolean verifyKnownType, RuntimeTypeHandle declaredTypeHandle)
   at System.Runtime.Serialization.XmlObjectSerializerWriteContext.SerializeWithXsiType(XmlWriterDelegator xmlWriter, Object obj, RuntimeTypeHandle objectTypeHandle, Type objectType, Int32 declaredTypeID, RuntimeTypeHandle declaredTypeHandle, Type declaredType)
   at System.Runtime.Serialization.XmlObjectSerializerWriteContext.InternalSerialize(XmlWriterDelegator xmlWriter, Object obj, Boolean isDeclaredType, Boolean writeXsiType, Int32 declaredTypeID, RuntimeTypeHandle declaredTypeHandle)
   at WriteSerializedExpressionToXml(XmlWriterDelegator , Object , XmlObjectSerializerWriteContext , ClassDataContract )
   at System.Runtime.Serialization.ClassDataContract.WriteXmlValue(XmlWriterDelegator xmlWriter, Object obj, XmlObjectSerializerWriteContext context)
   at System.Runtime.Serialization.XmlObjectSerializerWriteContext.WriteDataContractValue(DataContract dataContract, XmlWriterDelegator xmlWriter, Object obj, RuntimeTypeHandle declaredTypeHandle)
   at System.Runtime.Serialization.XmlObjectSerializerWriteContext.SerializeWithoutXsiType(DataContract dataContract, XmlWriterDelegator xmlWriter, Object obj, RuntimeTypeHandle declaredTypeHandle)
   at System.Runtime.Serialization.XmlObjectSerializerWriteContext.InternalSerialize(XmlWriterDelegator xmlWriter, Object obj, Boolean isDeclaredType, Boolean writeXsiType, Int32 declaredTypeID, RuntimeTypeHandle declaredTypeHandle)
   at WriteEntityQuerySurrogateToXml(XmlWriterDelegator , Object , XmlObjectSerializerWriteContext , ClassDataContract )
   at System.Runtime.Serialization.ClassDataContract.WriteXmlValue(XmlWriterDelegator xmlWriter, Object obj, XmlObjectSerializerWriteContext context)
   at System.Runtime.Serialization.XmlObjectSerializerWriteContext.WriteDataContractValue(DataContract dataContract, XmlWriterDelegator xmlWriter, Object obj, RuntimeTypeHandle declaredTypeHandle)
   at System.Runtime.Serialization.XmlObjectSerializerWriteContext.SerializeAndVerifyType(DataContract dataContract, XmlWriterDelegator xmlWriter, Object obj, Boolean verifyKnownType, RuntimeTypeHandle declaredTypeHandle)
   at System.Runtime.Serialization.XmlObjectSerializerWriteContext.SerializeWithXsiTypeAtTopLevel(DataContract dataContract, XmlWriterDelegator xmlWriter, Object obj, RuntimeTypeHandle originalDeclaredTypeHandle)
   at System.Runtime.Serialization.DataContractSerializer.InternalWriteObjectContent(XmlWriterDelegator writer, Object graph)
   at System.Runtime.Serialization.DataContractSerializer.InternalWriteObject(XmlWriterDelegator writer, Object graph)
   at System.Runtime.Serialization.XmlObjectSerializer.WriteObjectHandleExceptions(XmlWriterDelegator writer, Object graph)
   at System.Runtime.Serialization.XmlObjectSerializer.WriteObject(XmlDictionaryWriter writer, Object graph)
   at System.ServiceModel.Dispatcher.DataContractSerializerOperationFormatter.SerializeParameterPart(XmlDictionaryWriter writer, PartInfo part, Object graph)
   --- End of inner exception stack trace ---
   at IdeaBlade.EntityModel.EntityServerProxy.Fetch(SessionBundle bundle, IEntityQuerySurrogate query)
   at IdeaBlade.EntityModel.EntityManager.AsyncFetchWorker(AsyncEventArgs state)
   --- End of inner exception stack trace ---
   at IdeaBlade.EntityModel.AsyncProcessor`1.<>c__DisplayClass2.<.ctor>b__0(TArgs args)
   at IdeaBlade.EntityModel.AsyncProcessor`1.Signal()
   at IdeaBlade.EntityModel.AsyncProcessor`1.<Execute>b__5(Object x)    

Source File: http://localhost:8686/FrameworkTestTestPage.aspx
Line: 56
Back to Top
smi-mark View Drop Down
DevForce MVP
DevForce MVP
Avatar

Joined: 24-Feb-2009
Location: Dallas, Texas
Posts: 343
Post Options Post Options   Quote smi-mark Quote  Post ReplyReply Direct Link To This Post Posted: 19-Feb-2011 at 2:37pm
It is interesting to note that when I enable windows authentication and disable my loginmanager, the NorthwindEntityManager logs in fine (Obviously using null)

When my login manager (EntityManager) logs in first, the Northwind model throws the above error, even when not linking for authentication. Very odd behavior.
Back to Top
kimj View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 09-May-2007
Posts: 1391
Post Options Post Options   Quote kimj Quote  Post ReplyReply Direct Link To This Post Posted: 21-Feb-2011 at 8:35am

This looks like there's been a problem with DevForce initialization of its "parts catalog".   A known type issue with a type from your model would indicate that your model assembly was either never probed or failed probing, likely on the client.  I think you found another problem with the ordering of assemblies in the XAP and have a workaround, is it possible your workaround isn't being used when you turn on the IAuthenticationManager?   

Back to Top
smi-mark View Drop Down
DevForce MVP
DevForce MVP
Avatar

Joined: 24-Feb-2009
Location: Dallas, Texas
Posts: 343
Post Options Post Options   Quote smi-mark Quote  Post ReplyReply Direct Link To This Post Posted: 21-Feb-2011 at 9:10am
I think you're onto something there - If I turn off security DF is only initialized when I go into my module, and finds the references. When security is on, DF is initialized at the root level before any modules are added.

I'll do some playing around and see what I can find. Thanks!
Back to Top
smi-mark View Drop Down
DevForce MVP
DevForce MVP
Avatar

Joined: 24-Feb-2009
Location: Dallas, Texas
Posts: 343
Post Options Post Options   Quote smi-mark Quote  Post ReplyReply Direct Link To This Post Posted: 22-Feb-2011 at 3:56pm
Hi Kim,

I've done some testing and I can confirm the the assembly is being added to the probe assemblies list, is there anywhere else it has to exist?

CompositionHost.Add(new AssemblyCatalog(typeof(Category).Assembly));
var containsAssembly = CompositionHost.Instance.ProbeAssemblies.Contains(typeof(Category).Assembly);

that evaluates to true. This should indicate that DevForce should be probing this assembly, but something is not working quite right.

I get the same error whether or not I call CompositionHost.Add. It is odd though that it works fine if I don't use the LoginManager.

Edit:

It is not related to LoginManager, it only happens when DF is initialized first and then extra assemblies are added later.

I can make it work by either:

1) Adding a reference to model to the shell project
2) Disabling all my login code, so that DF is only first initialized when my module loads, which is at the point it is added to the probe assembly


Edited by smi-mark - 22-Feb-2011 at 4:31pm
Back to Top
smi-mark View Drop Down
DevForce MVP
DevForce MVP
Avatar

Joined: 24-Feb-2009
Location: Dallas, Texas
Posts: 343
Post Options Post Options   Quote smi-mark Quote  Post ReplyReply Direct Link To This Post Posted: 22-Feb-2011 at 4:44pm
Here are the two debug logs, the first one has the reference in the shell, the second doesn't.

Reference in shell and module (This works)

http://privatepaste.com/ca434b5351

Reference only in module (This does NOT work)

http://privatepaste.com/3bc44a5774

They BOTH see "FrameworkTest.Models.Northwind.SL, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" in the second time it dumps the probe assemblies ( this is done by me when the module loads )

It seems there is something not working right if it is not initially referenced.


Edited by smi-mark - 22-Feb-2011 at 4:45pm
Back to Top
kimj View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 09-May-2007
Posts: 1391
Post Options Post Options   Quote kimj Quote  Post ReplyReply Direct Link To This Post Posted: 23-Feb-2011 at 8:12am
The problem in the second case is that DevForce did not see the FrameworkTest.Models.Northwind.SL assembly when it initialized the catalog.   Right now - and this will be fixed in the next release - the catalog will not "recompose" when an AssemblyCatalog is added late.  Currently, recomposition works correctly only with a DeploymentCatalog or on-demand XAP.
Back to Top
smi-mark View Drop Down
DevForce MVP
DevForce MVP
Avatar

Joined: 24-Feb-2009
Location: Dallas, Texas
Posts: 343
Post Options Post Options   Quote smi-mark Quote  Post ReplyReply Direct Link To This Post Posted: 23-Feb-2011 at 9:04am
Makes sense :) For now I have a workaround. After I reverse through the probe assemblies (To workaround the previous bug) I just pass the DynamicXap to CompositionHost.Add and it works.
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down