I'm running with problems with AppFabric Caching 1.1. Try google it but nothing came up (or using the wrong keywords)
There is the follow scenario:
We have the cluster with 2 hosts up and running
We have our dev server using the appfabric cluster with no problem
We do night builds to a testing server (with no problems, all the configs are right) and here the appfabric have problems
We have one cache for dev and another to test
The object that we have problems is a list of classes A, and the class A have some properties and a list of class B. Both classes have serialize attribute and datacontract plus datamember.
In dev everything work as expected. We store/retrieve/delete from cache.
In test we store, but when try to retrieve have an exception.
The exception is:
Error Message: Object reference not set to an instance of an object.
Stack Trace: at
System.Runtime.Serialization.TypeName.LoadTypeWithPartialName(ITypeName
typeNameInfo, Assembly initialAssembly, String fullTypeName) at
System.Runtime.Serialization.TypeName.LoadTypeWithPartialName(ITypeName
typeNameInfo, Assembly initialAssembly, String fullTypeName) at
System.Runtime.Serialization.TypeName.GetType(Assembly
initialAssembly, String fullTypeName) at
System.Runtime.Serialization.XmlObjectSerializerReadContextComplex.ResolveDataContractTypeInSharedTypeMode(String
assemblyName, String typeName, Assembly& assembly) at
System.Runtime.Serialization.XmlObjectSerializerReadContextComplex.ResolveDataContractInSharedTypeMode(String
assemblyName, String typeName, Assembly& assembly, Type& type) at
System.Runtime.Serialization.XmlObjectSerializerReadContextComplex.InternalDeserializeInSharedTypeMode(XmlReaderDelegator
xmlReader, Int32 declaredTypeID, Type declaredType, String name,
String ns) at
System.Runtime.Serialization.XmlObjectSerializerReadContextComplex.InternalDeserialize(XmlReaderDelegator
xmlReader, Type declaredType, String name, String ns) at
System.Runtime.Serialization.NetDataContractSerializer.InternalReadObject(XmlReaderDelegator
xmlReader, Boolean verifyObjectName) at
System.Runtime.Serialization.XmlObjectSerializer.ReadObjectHandleExceptions(XmlReaderDelegator
reader, Boolean verifyObjectName) at
Microsoft.ApplicationServer.Caching.Utility.Deserialize(Byte[][]
buffers, Boolean checkTypeToLoad, Object context, IEnumerable1
knownTypes) at
Microsoft.ApplicationServer.Caching.Utility.Deserialize(Byte[][]
buffers, Boolean checkTypeToLoad) at
Microsoft.ApplicationServer.Caching.RoutingClient.SendMsgAndWait(RequestBody
reqMsg, IRequestTracker& tracker) at
Microsoft.ApplicationServer.Caching.DataCache.SendReceive(RequestBody
reqMsg, IMonitoringListener listener) at
Microsoft.ApplicationServer.Caching.DataCache.InternalGet(String key,
DataCacheItemVersion& version, String region, IMonitoringListener
listener) at
Microsoft.ApplicationServer.Caching.DataCache.<>c__DisplayClass49.b__48()
at
Microsoft.ApplicationServer.Caching.MonitoringListenerFactory.EmptyListener.Microsoft.ApplicationServer.Caching.IMonitoringListener.Listen[TResult](Func`1
innerDelegate) at
Microsoft.ApplicationServer.Caching.DataCache.Get(String key)
EDIT:
The classes are decorate with Serialize and DataContract attributes. The properties are decorated with DataMember attribute
To sort it I use the Protocol Buffer and do the serialization myself.
When I open the dll's, I discover the AppFabric bypass if it is a byte array.
Related
I'm having problems debugging my assembly using the PluginProfiler supplied with the PluginRegistrationTool. Once I mark the step as profiling and trigger it (Create an account) it shows the following error message:
Unhandled Exception:
System.ServiceModel.FaultException`1[[Microsoft.Xrm.Sdk.OrganizationServiceFault, Microsoft.Xrm.Sdk, Version=8.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]: Unexpected Exception in the Plug-in ProfilerDetail:
<OrganizationServiceFault xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/xrm/2011/Contracts">
<ErrorCode>-2147220891</ErrorCode>
<ErrorDetails xmlns:d2p1="http://schemas.datacontract.org/2004/07/System.Collections.Generic">
<KeyValuePairOfstringanyType>
<d2p1:key>CallStack</d2p1:key>
<d2p1:value xmlns:d4p1="http://www.w3.org/2001/XMLSchema" i:type="d4p1:string"> at PluginProfiler.Plugins.ProfilerBase`1.InitializeProfiler(Dictionary`2 services, T operationContext, ProfilerPluginContext& context)
at PluginProfiler.Plugins.ProfilerPlugin.Execute(IServiceProvider serviceProvider)
at Microsoft.Crm.Sandbox.SandboxAppDomainHelper.<>c__DisplayClass8.<Execute>b__1()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Microsoft.Crm.Sandbox.SandboxAppDomainHelper.Execute(IOrganizationServiceFactory organizationServiceFactory, Dictionary`2 sandboxServices, String pluginTypeName, String pluginConfiguration, String pluginSecureConfig, IPluginExecutionContext requestContext, Boolean enablePluginStackTrace, Boolean chaosFailAppDomain)
at Microsoft.Crm.Sandbox.SandboxAppDomainHelper.Execute(IOrganizationServiceFactory organizationServiceFactory, Dictionary`2 sandboxServices, String pluginTypeName, String pluginConfiguration, String pluginSecureConfig, IPluginExecutionContext requestContext, Boolean enablePluginStackTrace, Boolean chaosFailAppDomain)
at Microsoft.Crm.Sandbox.SandboxWorker.Execute(SandboxCallInfo callInfo, SandboxPluginExecutionContext requestContext, Guid pluginAssemblyId, Int32 sourceHash, String assemblyName, Guid pluginTypeId, String pluginTypeName, String pluginConfiguration, String pluginSecureConfig, SandboxRequestCounter& workerCounter, Boolean returnTraceInfo)</d2p1:value>
</KeyValuePairOfstringanyType>
<KeyValuePairOfstringanyType>
<d2p1:key>OperationStatus</d2p1:key>
<d2p1:value xmlns:d4p1="http://www.w3.org/2001/XMLSchema" i:type="d4p1:string">3</d2p1:value>
</KeyValuePairOfstringanyType>
<KeyValuePairOfstringanyType>
<d2p1:key>SubErrorCode</d2p1:key>
<d2p1:value xmlns:d4p1="http://www.w3.org/2001/XMLSchema" i:type="d4p1:string">-2146233088</d2p1:value>
</KeyValuePairOfstringanyType>
</ErrorDetails>
<Message>Unexpected Exception in the Plug-in Profiler</Message>
<Timestamp>2017-09-20T11:11:16.7252255Z</Timestamp>
<ExceptionRetriable>false</ExceptionRetriable>
<ExceptionSource i:nil="true" />
<InnerFault i:nil="true" />
<OriginalException i:nil="true" />
<TraceText>
[PluginProfiler.Plugins: PluginProfiler.Plugins.ProfilerPlugin]
[585cb523-f29d-e711-81b0-000d3a22c45c: XXXXXXXX.Xrm.Plugins.BasicEntryPoints.GenericPlugin: Create of account (Profiler)]
An exception occurred during the initialization of the Plug-in Profiler.
Unhandled Exception: System.TypeLoadException: Inheritance security rules violated while overriding member: 'Castle.DynamicProxy.ProxyGenerationOptions.GetObjectData(System.Runtime.Serialization.SerializationInfo, System.Runtime.Serialization.StreamingContext)'. Security accessibility of the overriding method must match the security accessibility of the method being overriden.
at System.Reflection.RuntimeAssembly.GetExportedTypes(RuntimeAssembly assembly, ObjectHandleOnStack retTypes)
at System.Reflection.RuntimeAssembly.GetExportedTypes()
at Microsoft.Xrm.Sdk.KnownTypesProvider.get_KnownOrganizationRequestResponseTypes()
at Microsoft.Xrm.Sdk.KnownTypesResolver.ResolveName(String typeName, String typeNamespace, Type declaredType, DataContractResolver knownTypeResolver)
at System.Runtime.Serialization.XmlObjectSerializerContext.ResolveDataContractFromDataContractResolver(XmlQualifiedName typeName, Type declaredType)
at System.Runtime.Serialization.XmlObjectSerializerContext.ResolveDataContractFromKnownTypes(String typeName, String typeNs, DataContract memberTypeContract, Type declaredType)
at System.Runtime.Serialization.XmlObjectSerializerContext.IsKnownType(DataContract dataContract, Type declaredType)
at System.Runtime.Serialization.XmlObjectSerializerContext.IsKnownType(DataContract dataContract, Dictionary`2 knownDataContracts, Type declaredType)
at System.Runtime.Serialization.KnownTypeDataContractResolver.TryResolveType(Type type, Type declaredType, DataContractResolver knownTypeResolver, XmlDictionaryString& typeName, XmlDictionaryString& typeNamespace)
at Microsoft.Xrm.Sdk.KnownTypesResolver.TryResolveType(Type type, Type declaredType, DataContractResolver knownTypeResolver, XmlDictionaryString& typeName, XmlDictionaryString& typeNamespace)
at System.Runtime.Serialization.XmlObjectSerializerWriteContext.ResolveType(Type objectType, Type declaredType, XmlDictionaryString& typeName, XmlDictionaryString& typeNamespace)
at System.Runtime.Serialization.XmlObjectSerializerWriteContext.WriteTypeInfo(XmlWriterDelegator writer, DataContract contract, DataContract declaredContract)
at System.Runtime.Serialization.XmlObjectSerializerWriteContext.SerializeWithXsiTypeAtTopLevel(DataContract dataContract, XmlWriterDelegator xmlWriter, Object obj, RuntimeTypeHandle originalDeclaredTypeHandle, Type graphType)
at System.Runtime.Serialization.DataContractSerializer.InternalWriteObjectContent(XmlWriterDelegator writer, Object graph, DataContractResolver dataContractResolver)
at System.Runtime.Serialization.DataContractSerializer.InternalWriteObject(XmlWriterDelegator writer, Object graph, DataContractResolver dataContractResolver)
at System.Runtime.Serialization.XmlObjectSerializer.WriteObjectHandleExceptions(XmlWriterDelegator writer, Object graph, DataContractResolver dataContractResolver)
at System.Runtime.Serialization.XmlObjectSerializer.WriteObject(XmlDictionaryWriter writer, Object graph)
at Microsoft.Crm.Sandbox.SandboxUtility.SerializeDataContract[T](T dataContract, Assembly proxyTypesAssembly)
at Microsoft.Crm.Sandbox.SandboxOrganizationServiceWrapper.ExecuteInternal(OrganizationRequest request)
at Microsoft.Crm.Sandbox.SandboxOrganizationServiceWrapper.RetrieveInternal(String entityName, Guid id, ColumnSet columnSet)
at Microsoft.Crm.Sandbox.SandboxOrganizationServiceWrapper.Retrieve(String entityName, Guid entityId, ColumnSet columnSet)
at PluginProfiler.Plugins.PluginLoaderUtility.RefreshAssembly(IOrganizationService service, ProfilerConfiguration config, PluginInitializationContext context)
at PluginProfiler.Plugins.PluginLoaderUtility.RefreshPluginInitializationContext(IOrganizationServiceFactory factory, ProfilerConfiguration config, PluginInitializationContext currentContext)
at PluginProfiler.Plugins.ProfilerBase`1.InitializeProfiler(Dictionary`2 services, T operationContext, ProfilerPluginContext& context)
</TraceText>
</OrganizationServiceFault>
I'm using StructureMap as IoC container and StructureMap.AutoFactory, which requires Castle.Core. I'm using ILMerge to merge all assemblies into a single on. I'm using the following arguments to execute ILMerge:
/target:library
/out:"$outPath"
/log:"$logFile"
/keyfile:"${keyFile}"
/copyattrs
/wildcards
/targetplatform:"v4,${Env:ProgramFiles(x86)}\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.2"
and the following assemblies (left out my dlls):
"${targetDir}StructureMap.dll"
"${targetDir}StructureMap.AutoFactory.dll"
"${targetDir}Castle.Core.dll"
I'm really out of ideas and it would be great if someone finds the time to help me. Thanks in advance!
As per this article the Sandboxed environment in which plugins run prohibits the use of Reflection to access internal members. I'm not familiar with dynamics proxying per se, but it looks like creating types on the fly and potentially using reflection in the process may not be possible in the sandbox.
If you have an on-prem dev environment you could register the plugin outside the sandbox and see what happens.
I have a custom module in Sitecore which works fine if app pool session state is set to In process. When I change it to SQL Server I get error message saying that it is Unable to serialize the session state. All my classes I am using are serializable. My code is triggered by custom ribbon button and this error is thrown when I click on it. It is supposed to display dialog form but it shows error message instead. I thought it has sth to do with Sitecore DialogForm class which my class inherits, but it turned out that this is not the case.
When I debug the code error is thrown once Run(TranslateArgs args) method has finished executing - it is called from public override void Execute(CommandContext context) and is supposed to display dialog by calling SheerResponse.ShowModalDialog(str4.ToString(), true);
I also thought that it was because I used ClientPipelineArgs in Run method, but after creating custom class (and making it serializable) that inherits ClientPipelineArgs error didn't go away.
Any ideas what might be causing it?
Stack Trace:
[SerializationException: Type 'Sitecore.Data.Database' in Assembly 'Sitecore.Kernel, Version=7.0.0.0, Culture=neutral, PublicKeyToken=null' is not marked as serializable.]
System.Runtime.Serialization.FormatterServices.InternalGetSerializableMembers(RuntimeType type) +14210117
System.Runtime.Serialization.FormatterServices.GetSerializableMembers(Type type, StreamingContext context) +408
System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.InitMemberInfo() +420
System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.InitSerialize(Object obj, ISurrogateSelector surrogateSelector, StreamingContext context, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter, ObjectWriter objectWriter, SerializationBinder binder) +532
System.Runtime.Serialization.Formatters.Binary.ObjectWriter.Write(WriteObjectInfo objectInfo, NameInfo memberNameInfo, NameInfo typeNameInfo) +969
System.Runtime.Serialization.Formatters.Binary.ObjectWriter.Serialize(Object graph, Header[] inHeaders, __BinaryWriter serWriter, Boolean fCheck) +633
System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Serialize(Stream serializationStream, Object graph, Header[] headers, Boolean fCheck) +322
System.Web.Util.AltSerialization.WriteValueToStream(Object value, BinaryWriter writer) +1487
[HttpException (0x80004005): Unable to serialize the session state. In 'StateServer' and 'SQLServer' mode, ASP.NET will serialize the session state objects, and as a result non-serializable objects or MarshalByRef objects are not permitted. The same restriction applies if similar serialization is done by the custom session state store in 'Custom' mode.]
System.Web.Util.AltSerialization.WriteValueToStream(Object value, BinaryWriter writer) +2252727
System.Web.SessionState.SessionStateItemCollection.WriteValueToStreamWithAssert(Object value, BinaryWriter writer) +49
System.Web.SessionState.SessionStateItemCollection.Serialize(BinaryWriter writer) +729
System.Web.SessionState.SessionStateUtility.Serialize(SessionStateStoreData item, Stream stream) +336
System.Web.SessionState.SessionStateUtility.SerializeStoreData(SessionStateStoreData item, Int32 initialStreamSize, Byte[]& buf, Int32& length, Boolean compressionEnabled) +99
System.Web.SessionState.SqlSessionStateStore.SetAndReleaseItemExclusive(HttpContext context, String id, SessionStateStoreData item, Object lockId, Boolean newItem) +3538900
System.Web.SessionState.SessionStateModule.OnReleaseState(Object source, EventArgs eventArgs) +1021
System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +92
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +165
Well the stack trace tells us, that some code is trying to put a Sitecore.Data.Database onto SessionState, and that won't work. It has no public constructor, but that is the very least of the problems. It can happen if trying to put an instantiated Item onto SessionState as well.
The stack trace appears to be incomplete. It should show you, which line of code in your Run method, is the root source of the exception.
What isn't clear to me; which exact version of Sitecore are you on?
Currently out-of-process session state mode is experimental feature in Sitecore. InProc is the best option for the Client. Find more details here.
If you still think that out-of-process is the right way to go, make sure you set it in accordance with this article.
[Update] Out-of-process session states are not supported on Content Management instance anymore. Link.
Quickly to get a feeling on azure, I created a webapi project which uses EF and Local DB and it has some crud operations.
Then I signed up to Azure, created a WebApp and then downloaded the publish profile.
Using VS 2013, deployed the application to Azure. Navigated to index.html everything is working fine.
The problem is when I try to execute a simple HttpGet (which returns the value from the LocalDB), I am getting the below stack trace.
<Error>
<Message>An error has occurred.</Message>
<ExceptionMessage>
The 'ObjectContent`1' type failed to serialize the response body for content type 'application/xml; charset=utf-8'.
</ExceptionMessage>
<ExceptionType>System.InvalidOperationException</ExceptionType>
<StackTrace/>
<InnerException>
<Message>An error has occurred.</Message>
<ExceptionMessage>
Format of the initialization string does not conform to specification starting at index 0.
</ExceptionMessage>
<ExceptionType>System.ArgumentException</ExceptionType>
<StackTrace>
at System.Data.Common.DbConnectionOptions.GetKeyValuePair(String connectionString, Int32 currentPosition, StringBuilder buffer, Boolean useOdbcRules, String& keyname, String& keyvalue) at System.Data.Common.DbConnectionOptions.ParseInternal(Hashtable parsetable, String connectionString, Boolean buildChain, Hashtable synonyms, Boolean firstKey) at System.Data.Common.DbConnectionOptions..ctor(String connectionString, Hashtable synonyms, Boolean useOdbcRules) at System.Data.SqlClient.SqlConnectionString..ctor(String connectionString) at System.Data.SqlClient.SqlConnectionFactory.CreateConnectionOptions(String connectionString, DbConnectionOptions previous) at System.Data.ProviderBase.DbConnectionFactory.GetConnectionPoolGroup(DbConnectionPoolKey key, DbConnectionPoolGroupOptions poolOptions, DbConnectionOptions& userConnectionOptions) at System.Data.SqlClient.SqlConnection.ConnectionString_Set(DbConnectionPoolKey key) at System.Data.SqlClient.SqlConnection.set_ConnectionString(String value) at System.Data.Entity.Infrastructure.Interception.DbConnectionDispatcher.<SetConnectionString>b__18(DbConnection t, DbConnectionPropertyInterceptionContext`1 c) at System.Data.Entity.Infrastructure.Interception.InternalDispatcher`1.Dispatch[TTarget,TInterceptionContext](TTarget target, Action`2 operation, TInterceptionContext interceptionContext, Action`3 executing, Action`3 executed) at System.Data.Entity.Infrastructure.Interception.DbConnectionDispatcher.SetConnectionString(DbConnection connection, DbConnectionPropertyInterceptionContext`1 interceptionContext) at System.Data.Entity.Internal.LazyInternalConnection.InitializeFromConnectionStringSetting(ConnectionStringSettings appConfigConnection) at System.Data.Entity.Internal.LazyInternalConnection.Initialize() at System.Data.Entity.Internal.LazyInternalConnection.get_Connection() at System.Data.Entity.Internal.LazyInternalContext.get_Connection() at System.Data.Entity.Infrastructure.DbContextInfo..ctor(Type contextType, DbProviderInfo modelProviderInfo, AppConfig config, DbConnectionInfo connectionInfo, Func`1 resolver) at System.Data.Entity.Migrations.DbMigrator..ctor(DbMigrationsConfiguration configuration, DbContext usersContext, DatabaseExistenceState existenceState, Boolean calledByCreateDatabase) at System.Data.Entity.MigrateDatabaseToLatestVersion`2.InitializeDatabase(TContext context) at System.Data.Entity.Internal.InternalContext.<>c__DisplayClassf`1.<CreateInitializationAction>b__e() at System.Data.Entity.Internal.InternalContext.PerformInitializationAction(Action action) at System.Data.Entity.Internal.InternalContext.PerformDatabaseInitialization() at System.Data.Entity.Internal.LazyInternalContext.<InitializeDatabase>b__4(InternalContext c) at System.Data.Entity.Internal.RetryAction`1.PerformAction(TInput input) at System.Data.Entity.Internal.LazyInternalContext.InitializeDatabaseAction(Action`1 action) at System.Data.Entity.Internal.LazyInternalContext.InitializeDatabase() at System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(Type entityType) at System.Data.Entity.Internal.Linq.InternalSet`1.Initialize() at System.Data.Entity.Internal.Linq.InternalSet`1.GetEnumerator() at System.Data.Entity.Infrastructure.DbQuery`1.System.Collections.Generic.IEnumerable<TResult>.GetEnumerator() at WriteArrayOfBankModelToXml(XmlWriterDelegator , Object , XmlObjectSerializerWriteContext , CollectionDataContract ) at System.Runtime.Serialization.CollectionDataContract.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.DataContractSerializer.InternalWriteObjectContent(XmlWriterDelegator writer, Object graph, DataContractResolver dataContractResolver) at System.Runtime.Serialization.DataContractSerializer.InternalWriteObject(XmlWriterDelegator writer, Object graph, DataContractResolver dataContractResolver) at System.Runtime.Serialization.XmlObjectSerializer.WriteObjectHandleExceptions(XmlWriterDelegator writer, Object graph, DataContractResolver dataContractResolver) at System.Runtime.Serialization.DataContractSerializer.WriteObject(XmlWriter writer, Object graph) at System.Net.Http.Formatting.XmlMediaTypeFormatter.WriteToStream(Type type, Object value, Stream writeStream, HttpContent content) at System.Net.Http.Formatting.XmlMediaTypeFormatter.WriteToStreamAsync(Type type, Object value, Stream writeStream, HttpContent content, TransportContext transportContext, CancellationToken cancellationToken) --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Web.Http.WebHost.HttpControllerHandler.<WriteBufferedResponseContentAsync>d__1b.MoveNext()
</StackTrace>
</InnerException>
</Error>
I also see there are no options to create a LocalDb in Azure Website.
I initially guessed since I am using CodeFirst approach, Azure will automatically create the database for me.
EDIT: I have seeded the database and added some sample data to the localdb. The api works just fine in my local machine.
Any inputs on this please ?
You should use Azure SQL Database instead of local DB.
You will still use CodeFirst.
Here is how to do it :
Enable Migrations, create the database, add sample data and a data initializer
https://azure.microsoft.com/en-us/documentation/articles/web-sites-dotnet-rest-service-aspnet-api-sql-database/#enable-migrations-create-the-database-add-sample-data-and-a-data-initializer
If needed, you can jump to the top of the page to see the complete tuto starting from the Web API...
I'm having problems calling a method from a service. The error only occurs in .NET, Java seems to work fine. Most of the methods from the service work with .NET, so far 2 of them have thrown Exceptions. The service is open if you want to try and reproduce: http://radar.zhaw.ch/services/AirTrafficWebService.wsdl
Exception
System.ArgumentException occurred
Message=Das Objekt mit dem Typ "AirTrafficWcfWrapper.ServiceReference1.Airplane[]" kann nicht in den Typ "AirTrafficWcfWrapper.ServiceReference1.AirplaneTrackingPoint[]" konvertiert werden.
Source=mscorlib
StackTrace:
Server stack trace:
bei System.RuntimeType.TryChangeType(Object value, Binder binder, CultureInfo culture, Boolean needsSpecialCast)
bei System.RuntimeType.CheckValue(Object value, Binder binder, CultureInfo culture, BindingFlags invokeAttr)
bei System.Reflection.RtFieldInfo.InternalSetValue(Object obj, Object value, BindingFlags invokeAttr, Binder binder, CultureInfo culture, Boolean doVisibilityCheck, Boolean doCheckConsistency)
bei System.Reflection.RtFieldInfo.InternalSetValue(Object obj, Object value, BindingFlags invokeAttr, Binder binder, CultureInfo culture, Boolean doVisibilityCheck)
bei System.Reflection.RtFieldInfo.SetValue(Object obj, Object value, BindingFlags invokeAttr, Binder binder, CultureInfo culture)
bei System.Reflection.FieldInfo.SetValue(Object obj, Object value)
bei System.ServiceModel.Dispatcher.OperationFormatter.DeserializeReply(Message message, Object[] parameters)
bei System.ServiceModel.Dispatcher.ProxyOperationRuntime.AfterReply(ProxyRpc& rpc)
bei System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc& rpc)
bei System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
bei System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
bei System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
Exception rethrown at [0]:
bei System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
bei System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
bei AirTrafficWcfWrapper.ServiceReference1.AirTrafficWebService.getAirplaneTrackingPoints(getAirplaneTrackingPointsRequest request)
bei AirTrafficWcfWrapper.ServiceReference1.AirTrafficWebServiceClient.AirTrafficWcfWrapper.ServiceReference1.AirTrafficWebService.getAirplaneTrackingPoints(getAirplaneTrackingPointsRequest request) in D:\Projekte\C#\WP7\Airtraffic\Tests\SilverlightDesktop\AirTrafficWcfWrapper\Service References\ServiceReference1\Reference.cs:Zeile 1234.
InnerException:
It is thrown in a generated Reference.cs file like this:
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
AirTrafficWcfWrapper.ServiceReference1.getAirplaneTrackingPointsResponse AirTrafficWcfWrapper.ServiceReference1.AirTrafficWebService.getAirplaneTrackingPoints(AirTrafficWcfWrapper.ServiceReference1.getAirplaneTrackingPointsRequest request) {
return base.Channel.getAirplaneTrackingPoints(request); //<--HERE
}
.NET call:
AirplaneTrackingPoint[] tps = _airTrafficService.getAirplaneTrackingPoints(icao, 0, 0, false);
Java call:
List<AirplaneTrackingPoint> tps = service.getAirplaneTrackingPoints(icao, 0, 0, false).getItem();
EDIT:
The response seems to be made up out of a list containing a list of both an Airplane object and the single objects that AirplaneTrackingPoint is made of (e.g. [0] Airplane, [1] Latitude, [2] Longitude, [3] Bearing etc.). So it seems that .NET is taking the first element out of the element of the list and using that as a return value. Java seems to ignore the first element of the list in the list and instead makes an object out of the rest of the list.
Can anybody explain this behaviout?
Have you changed the service and forgot to update your service reference? Maybe earlier you returned a list of Airplane objects and some time you changed it to return your own new data structure. If you right-click on the service reference in your .NET project you can choose to update it, at which point the code that does everything for you (in Reference.cs) is recreated.
UPDATE: I can confirm that it's not working out of the box in VS2010.
I tried to run the client in .NET 4 and .NET 3.5. The first time I got some strange fault exception from the server with an SQL query string inside, now I'm only getting the cast error over and over. I followed standard VS2010 procedures to add a service reference, so there's either the service to blame or the WSDL doesn't work with svcutil (also a likely issue).
I got the following error when I changed the service reference to always generate message contracts and use these:
{"The top XML element 'return' from namespace '' references distinct types System.String and AirplaneTrackingTest.AirTraffic.Airplane[]. Use XML attributes to specify another XML name or namespace for the element or types."}
I would contact the service provider and ask for proper test parameters to their methods and if they have a reference client implementation in C#.
Hi you will need to add in a cast, presuming that the two types are compatible. You are returning an AirplaneTrackingPoints from the service and storing them as Airplanes, this sounds a little odd to me.
Your Java method calls getItem which is not present in your c# code could that be it?
I am in the sitaution where I need to use an external session state server, which requires all my sessions to be serialized. I have been trying to make all the classes I store in sessions serializable, by using the [Serializeable()] attribute.
However, I keep getting the following error:
Unable to serialize the session state.
In StateServer and SQLServer mode, ASP.NET will serialize the session state objects, and as a result non-serializable objects or MarshalByRef objects are not permitted. The same restriction applies if similar serialization is done by the custom session state store in 'Custom' mode.
More interesting is however the stack trace:
[SerializationException: Type 'ASP.useroverview_aspx' in Assembly 'App_Web_pwonykbc, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' is not marked as serializable.]
System.Runtime.Serialization.FormatterServices.InternalGetSerializableMembers(RuntimeType type) +9452985
System.Runtime.Serialization.FormatterServices.GetSerializableMembers(Type type, StreamingContext context) +247
System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.InitMemberInfo() +160
System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.InitSerialize(Object obj, ISurrogateSelector surrogateSelector, StreamingContext context, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter, ObjectWriter objectWriter, SerializationBinder binder) +218
System.Runtime.Serialization.Formatters.Binary.ObjectWriter.Write(WriteObjectInfo objectInfo, NameInfo memberNameInfo, NameInfo typeNameInfo) +388
System.Runtime.Serialization.Formatters.Binary.ObjectWriter.Serialize(Object graph, Header[] inHeaders, __BinaryWriter serWriter, Boolean fCheck) +444
System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Serialize(Stream serializationStream, Object graph, Header[] headers, Boolean fCheck) +133
System.Web.Util.AltSerialization.WriteValueToStream(Object value, BinaryWriter writer) +1708
The Type ASP.useroverview_aspx is as far as I know an ASPX page. The page I load is Useroverview.aspx. However, I don't try to store this page in a session. So this error makes me wonder quite a lot.
I tried to do the following in the code-behind:
[Serializable()]
public partial class UserOverview : Page
{
private static readonly int TimerInterval = HttpContext.Current.IsDebuggingEnabled ? 2000 : 750;
// ...
}
This did not help at all!
So I wonder if one could serialize an ASPX page? This don't know if this would make sense. I doubt it!
Thanks...
I found the answer.. And you guys were right: One of my objects had a reference to the page.
I had an object Player, which had a list of events. One of these events had the current page as a target, which let to the problem.
I gave the event the following non serializable attribute:
[field: NonSerialized]
Then everything worked fine. And they all lived happily ever after!