Automapper Exception. Unmapped members were found - automapper

I have the following inner exception being returned from automapper:
AutoMapper.AutoMapperConfigurationException was unhandled by user code
HResult=-2146233088
Message= Unmapped members were found. Review the types and members
below. add a custom mapping expression, ignore, add a custom resolver,
or modify the source/destination type
CreateAndEditCustomer -> Customer (Destination member list)
App.Web.Mvc.Models.Customer.CreateAndEditCustomer ->
App.Model.Customer (Destination member list)
Deleted
Does anyone know what Deleted means?
How can I discover which members have not been mapped?

Related

Property 'stageid' is of an unrecognized EdmPropertyKind. Entity new_test has duplicate navigation property names

I am using CRM2016
I created a test entity to replicate the issue
I did not do any customization on it. I created a new record with default fields and form. Then I tried to access the webapi for it
http://localhost/CRMDataBase/api/data/v8.0/new_test(bgcs0249-0a06-e611-941a-003002djlnc)
It worked fine and brought the record. Then I deleted the records and created a business process flow for it, with just one stage and one step
I activated it and added a new test record and tried to access the webapi url and it threw the below error
{ "error":{
"code":"","message":"Property 'stageid' is of an unrecognized EdmPropertyKind. Entity new_test has duplicate navigation property
names. All property names (Navigation and Structural property) must be
unique in an Entity ","innererror":{
"message":"Property 'stageid' is of an unrecognized EdmPropertyKind. Entity new_test has duplicate navigation property
names. All property names (Navigation and Structural property) must be
unique in an Entity
","type":"Microsoft.Crm.CrmHttpException","stacktrace":" at
Microsoft.Crm.Extensibility.OData.CrmODataEntityTypeSerializer.CreateSelectExpandNode(EntityInstanceContext
entityInstanceContext)\r\n at
System.Web.OData.Formatter.Serialization.ODataEntityTypeSerializer.WriteEntry(Object
graph, ODataWriter writer, ODataSerializerContext writeContext)\r\n
at
System.Web.OData.Formatter.Serialization.ODataFeedSerializer.WriteFeed(IEnumerable
enumerable, IEdmTypeReference feedType, ODataWriter writer,
ODataSerializerContext writeContext)\r\n at
Microsoft.Crm.Extensibility.OData.CrmODataFeedSerializer.WriteObject(Object
graph, Type type, ODataMessageWriter messageWriter,
ODataSerializerContext writeContext)\r\n at
System.Web.OData.Formatter.ODataMediaTypeFormatter.WriteToStream(Type
type, Object value, Stream writeStream, HttpContent content,
HttpContentHeaders contentHeaders)\r\n at
System.Web.OData.Formatter.ODataMediaTypeFormatter.WriteToStreamAsync(Type
type, Object value, Stream writeStream, HttpContent content,
TransportContext transportContext, CancellationToken
cancellationToken)\r\n--- End of stack trace from previous location
where exception was thrown ---\r\n at
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task
task)\r\n at
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
task)\r\n at
System.Web.Http.WebHost.HttpControllerHandler.d__1b.MoveNext()","internalexception":{
"message":"Property 'stageid' is of an unrecognized EdmPropertyKind.","type":"Microsoft.OData.Core.ODataException","stacktrace":"
at
Microsoft.OData.Core.UriParser.Parsers.SelectPathSegmentTokenBinder.ConvertNonTypeTokenToSegment(PathSegmentToken
tokenIn, IEdmModel model, IEdmStructuredType edmType, ODataUriResolver
resolver)\r\n at
Microsoft.OData.Core.UriParser.Visitors.SelectPropertyVisitor.ProcessTokenAsPath(NonSystemToken
tokenIn)\r\n at
Microsoft.OData.Core.UriParser.Visitors.SelectPropertyVisitor.Visit(NonSystemToken
tokenIn)\r\n at
Microsoft.OData.Core.UriParser.Parsers.SelectBinder.Bind(SelectToken
tokenIn)\r\n at
Microsoft.OData.Core.UriParser.Parsers.SelectExpandBinder.Bind(ExpandToken
tokenIn)\r\n at
Microsoft.OData.Core.UriParser.Parsers.SelectExpandSemanticBinder.Bind(IEdmStructuredType
elementType, IEdmNavigationSource navigationSource, ExpandToken
expandToken, SelectToken selectToken, ODataUriParserConfiguration
configuration)\r\n at
Microsoft.OData.Core.UriParser.ODataQueryOptionParser.ParseSelectAndExpand()\r\n
at
Microsoft.Crm.Extensibility.OData.CrmODataEntityTypeSerializer.CreateSelectExpandNode(EntityInstanceContext
entityInstanceContext)"
}
} } }
If I delete all the records-> deactivate business process -> add new data and then check the webapi, it is working fine. But when I activate the business process and add new data I am getting the above error
P.S: I have not done any coding/customization to business process flow and the entity. But I am still getting this error
What can be done to resolve this?
Looks like a bug in Web API endpoint. Community forums also reference the same issue...
The Web API endpoint still has some limitations and it doesn't fully mimic the OrganizationService behavior so, which will be for the next version (9.x.x) so if you are stuck maybe try applying an update (and then use v8.1 in the url) as, or raise a MS Support case.
If you are still stuck, just try the same using OData / OrganizationService maybe.

AutoMapper Maps mix when Mapping Objects

I'm getting the following exception when using AutoMapper:
AutoMapper.AutoMapperMappingException was unhandled by user code
HResult=-2146233088
Message=Missing type map configuration or unsupported mapping.
The two models are:
OperationSpecification
DayofTheWeek (enum)
OpenTime (string)
CloseTime (string)
OperationalScheduling
DayofTheWeek (enum)
OpenTime (string)
CloseTime (string)
Both models have the same properties (spelled the same and in the same case)
Upon the start of the project I have a class that is called and defines all the mappings.
Mapper.CreateMap<OperationSpecification, OperationalScheduling>();
I verified the AutoMapper maps by using
var stuff = Mapper.GetAllTypeMaps();
Putting a watch on "stuff" verifies there is a "OperationSpecification" -> "OperationalScheduling" map.
When I run the following line:
Mapper.Map<OperationSpecification, OperationalScheduling>(anObject);
I get the above error. If I look into the error details I see the following:
Context: Trying to map OperationSpecification to DayType (an enum in the project)
SourceType: Name = "OperationSpecification"
DestinationType: Name = "DayType"
There is no mapping of this type specified in the Mapper.GetAllTypeMaps() method.
I ran Mapper.AssertConfigurationIsValid() and confirmed the mapping.
This shifting of maps is also occurring with other mappings and objects in the project. My coworker also has the same issue. We've tried rebuilding and deleting and fetching the project from Visual Studio Online without any positive results.
Any thoughts as to what we can do to resolve this?
Many thanks!

Kentico v8 Uniselector not selecting custom document types

What Object type do we need to enter to select custom document types in the Uniselector control in Kentico v8?
In Kentico v7.0.34 we are successfully using the UniSelector to select custom document types as follows;
Object type: customtableitem.custom.Course
Return column name: CourseID
Display name format: {%Name%}
Selection mode: Multiple
Order by: Name
However in Kentico v8.0.17 we are getting the following error when using the above values;
[CustomTableItemProvider.GetTypeInfo]: Class 'custom.course' is not custom table.
Server Error in '/' Application.
[CustomTableItemProvider.GetTypeInfo]: Class 'custom.course' is not custom table.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Exception: [CustomTableItemProvider.GetTypeInfo]: Class 'custom.course' is not custom table.
Source Error:
Line 1094: private void LoadObjects()
Line 1095: {
Line 1096: if (Object != null)
Line 1097: {
Line 1098: // Reset string builder
Source File: c:\Visual Studio\Projects\Kentico8\CMS\CMSAdminControls\UI\UniSelector\UniSelector.ascx.cs Line: 1096
We have tried changing the Object type as follows;
Object type: custom.Course
This results is the following error;
Object type 'custom.course' not found.
Server Error in '/' Application.
Object type 'custom.course' not found.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Exception: Object type 'custom.course' not found.
Source Error:
Line 1094: private void LoadObjects()
Line 1095: {
Line 1096: if (Object != null)
Line 1097: {
Line 1098: // Reset string builder
Source File: c:\Visual Studio\Projects\Kentico8\CMS\CMSAdminControls\UI\UniSelector\UniSelector.ascx.cs Line: 1096
I have read the documentation available here and for Object type it provides a Sample Value of "cms.user". Setting Object type to "cms.user" does work for selecting CMS Users.
I also created a custom table called "Test" and can confirm that setting Object type to "customtableitem.customtable.Test" does work for selecting custom table items.
I have also asked this on Kentico's dev.net Q&A site;
https://devnet.kentico.com/questions/uniselector-in-kentico-v8
Cheers,
Darren
Quick answer:
ObjectType: cms.documenttype
Return column name: ClassID
Display name format: {%ClassDisplayName%}
Long answer:
Document type definitions (as well as custom table and on-line form definitions) are located in the CMS_Class table. To retrieve them you can use either more general "cms.class" or rather specific "cms.documenttype" or "cms.customtable" object types. So you should be able to do the same using ObjectType: cms.class + Where condition: ClassIsDocumentType=1.
What you've been trying to do was to retrieve data rather than class definitions of the data. Data of so called "classes" are stored in their own tables. Each custom table has its own table, each on-line form has its own table and documents are stored in CMS_TreeNode/CMS_Document tables.
Btw - there is already a form control for selecting classes. Have a look at:
\CMS\CMSFormControls\Classes\SelectClassNames.ascx
To distinguish between custom and predefined classes I'd suggest to use some prefix for your objects and select them with ClassName LIKE "myprefix%" or simply use id condition ClassID > 4478.

WCF Comunication Exception when passing string array

I have a wcf service and i want to pass a string[] through it. I am receiving the below error. Can someone point me in the right direction ?
The error :
There was an error while trying to serialize parameter http://services.csssoftware.com/2.0/ComFacades:arParams. The InnerException message was 'Type 'System.String[]' with data contract name 'ArrayOfstring:http://schemas.microsoft.com/2003/10/Serialization/Arrays' is not expected. Consider using a DataContractResolver or 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.
If you need more data plese let me know and i will edit the question.
For others who get to the same error, the fix was to add :[ServiceKnownType(typeof(string[]))] in my interface class.
For more information about this problem you can read : HERE

Orchard CMS 1.4.2: Autoroute error and other errors

I have a new Orchard CMS 1.4.2 installation that I have added a custom module to.
The custom module has 3 custom parts that are basically copies of the bodypart ContentPart.
I don't know much about the bodypart (or Orchard...), and I note that the mycustompartrecord class derives from:
ContentPartVersionRecord
One question is that I don't know why.
The other question is that running the site, I get the following error after updating the text of one of the custom "bodypart" content parts.
2012-06-02 08:15:49,580 [21] Orchard.ContentManagement.DefaultContentManager - ArgumentOutOfRangeException thrown from IContentHandler by Orchard.Autoroute.Handlers.AutoroutePartHandler
System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
at System.ThrowHelper.ThrowArgumentOutOfRangeException()
at System.Collections.Generic.List`1.get_Item(Int32 index)
at System.Linq.Enumerable.ElementAt[TSource](IEnumerable`1 source, Int32 index)
at Orchard.Autoroute.Services.AutorouteService.GetDefaultPattern(String contentType)
at Orchard.Autoroute.Services.AutorouteService.GenerateAlias(AutoroutePart part)
at Orchard.Autoroute.Handlers.AutoroutePartHandler.PublishAlias(AutoroutePart part)
at Orchard.Autoroute.Handlers.AutoroutePartHandler.<.ctor>b__2(PublishContentContext ctx, AutoroutePart part)
at Orchard.ContentManagement.Handlers.ContentHandler.InlineStorageFilter`1.Published(PublishContentContext context, TPart instance) in C:\Users\Andrew\Documents\Dox\Webs\Orchard\src\Orchard\ContentManagement\Handlers\ContentHandler.cs:line 156
at Orchard.ContentManagement.Handlers.StorageFilterBase`1.Orchard.ContentManagement.Handlers.IContentStorageFilter.Published(PublishContentContext context) in C:\Users\Andrew\Documents\Dox\Webs\Orchard\src\Orchard\ContentManagement\Handlers\StorageFilterBase.cs:line 81
at Orchard.ContentManagement.Handlers.ContentHandler.Orchard.ContentManagement.Handlers.IContentHandler.Published(PublishContentContext context) in C:\Users\Andrew\Documents\Dox\Webs\Orchard\src\Orchard\ContentManagement\Handlers\ContentHandler.cs:line 274
at Orchard.ContentManagement.DefaultContentManager.<>c__DisplayClass3d.<Publish>b__3b(IContentHandler handler) in C:\Users\Andrew\Documents\Dox\Webs\Orchard\src\Orchard\ContentManagement\DefaultContentManager.cs:line 342
at Orchard.InvokeExtensions.Invoke[TEvents](IEnumerable`1 events, Action`1 dispatch, ILogger logger) in C:\Users\Andrew\Documents\Dox\Webs\Orchard\src\Orchard\InvokeExtensions.cs:line 19
I really have no idea what is the cause of this. It seems to have no negative effect, on adding content. I suspect it is something to do with the way I am using these bodypart copies, but I am not sure.
NOTE:
As discussed in a previous thread (See details here), I have previously had another error, when using a CLEAN source code installation (ie, no modules, nothing custom) of Orchard v.1.4.2. The error is as follows:
Before installing any modules, and with a clean install, I was getting the following error:
2012-05-31 17:59:43,876 [9] NHibernate.AdoNet.AbstractBatcher - Could not execute query: SELECT this_.Id as Id13_0_, this_.SerialNumber as SerialNu2_13_0_ FROM Settings_ShellDescriptorRecord this_ WHERE 1=1
System.Data.SqlServerCe.SqlCeException (0x80004005): The specified table does not exist. [ Settings_ShellDescriptorRecord ]
at System.Data.SqlServerCe.SqlCeCommand.ProcessResults(Int32 hr)
at System.Data.SqlServerCe.SqlCeCommand.CompileQueryPlan()
at System.Data.SqlServerCe.SqlCeCommand.ExecuteCommand(CommandBehavior behavior, String method, ResultSetOptions options)
at System.Data.SqlServerCe.SqlCeCommand.ExecuteReader(CommandBehavior behavior)
at System.Data.SqlServerCe.SqlCeCommand.ExecuteDbDataReader(CommandBehavior behavior)
at System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader()
at NHibernate.AdoNet.AbstractBatcher.ExecuteReader(IDbCommand cmd)
2012-05-31 17:59:43,892 [9] NHibernate.Util.ADOExceptionReporter - The specified table does not exist. [ Settings_ShellDescriptorRecord ]
2012-05-31 17:59:43,907 [9] NHibernate.Util.ADOExceptionReporter - The specified table does not exist. [ Settings_ShellDescriptorRecord ]
The error has only appeared once in the logs, and doesn't seem to affect the system thereafter. Don't know if this is relevant to the autoroutepart error.
Unfortunately I can't answer your main question.
As for ContentPartVersionRecord: when you need a part to be versioned (i.e. saving a new copy of its content with every modification), you need to use this. BodyPart is a case of versioned content parts.
The SQL exception you're getting is I think completely harmless, as it's expected on setup. This query is used to check if the DB was already set up or not - if it fails, then not.

Resources