{"action":"created","issue":{"url":"https://api.github.com/repos/AutoMapper/AutoMapper/issues/620","labels_url":"https://api.github.com/repos/AutoMapper/AutoMapper/issues/620/labels{/name}","comments_url":"https://api.github.com/repos/AutoMapper/AutoMapper/issues/620/comments","events_url":"https://api.github.com/repos/AutoMapper/AutoMapper/issues/620/events","html_url":"https://github.com/AutoMapper/AutoMapper/issues/620","id":47851056,"number":620,"title":"Threading Issue when CreateMissingTypeMaps option is true","user":{"login":"adeel41","id":13577,"avatar_url":"https://avatars.githubusercontent.com/u/13577?v=3","gravatar_id":"","url":"https://api.github.com/users/adeel41","html_url":"https://github.com/adeel41","followers_url":"https://api.github.com/users/adeel41/followers","following_url":"https://api.github.com/users/adeel41/following{/other_user}","gists_url":"https://api.github.com/users/adeel41/gists{/gist_id}","starred_url":"https://api.github.com/users/adeel41/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adeel41/subscriptions","organizations_url":"https://api.github.com/users/adeel41/orgs","repos_url":"https://api.github.com/users/adeel41/repos","events_url":"https://api.github.com/users/adeel41/events{/privacy}","received_events_url":"https://api.github.com/users/adeel41/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/AutoMapper/AutoMapper/milestones/11","html_url":"https://github.com/AutoMapper/AutoMapper/milestones/4.0.0","labels_url":"https://api.github.com/repos/AutoMapper/AutoMapper/milestones/11/labels","id":900207,"number":11,"title":"4.0.0","description":"New config model\r\nDeleting the Formatters completely\r\netc","creator":{"login":"jbogard","id":104498,"avatar_url":"https://avatars.githubusercontent.com/u/104498?v=3","gravatar_id":"","url":"https://api.github.com/users/jbogard","html_url":"https://github.com/jbogard","followers_url":"https://api.github.com/users/jbogard/followers","following_url":"https://api.github.com/users/jbogard/following{/other_user}","gists_url":"https://api.github.com/users/jbogard/gists{/gist_id}","starred_url":"https://api.github.com/users/jbogard/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jbogard/subscriptions","organizations_url":"https://api.github.com/users/jbogard/orgs","repos_url":"https://api.github.com/users/jbogard/repos","events_url":"https://api.github.com/users/jbogard/events{/privacy}","received_events_url":"https://api.github.com/users/jbogard/received_events","type":"User","site_admin":false},"open_issues":60,"closed_issues":9,"state":"open","created_at":"2014-12-11T09:25:43Z","updated_at":"2015-07-08T20:47:37Z","due_on":null,"closed_at":null},"comments":2,"created_at":"2014-11-05T15:51:27Z","updated_at":"2015-07-13T12:45:03Z","closed_at":null,"body":"Hi,\r\nJust spotted an issue in automapper. When you are mapping and also specified CreateMissionTypeMaps = true then sometimes it causes an issue and throws AutoMapperMappingException. I am posting the source code as well so that you can replicate the issue on your machine. since this is a threading issue so it happens sometimes so you need to execute the code few times in order to see the error message. FYI  I installed AutoMapper v3.2.1 from package manager console.\r\n\r\n```\r\n\r\nusing System;\r\nusing System.Threading;\r\n\r\nnamespace AutoMapperDynamicMappingIssue\r\n{\r\n\tpublic class UserViewModel\r\n\t{\r\n\t\tpublic string EmailAddress { get; set; }\r\n\r\n\t\tpublic string LastName { get; set; }\r\n\r\n\t\tpublic string FirstName { get; set; }\r\n\r\n\t\tpublic int Id { get; set; }\r\n\r\n\t\tpublic UserViewModel()\r\n\t\t{\r\n\t\t\tId = 1;\r\n\t\t\tFirstName = \"Dummy\";\r\n\t\t\tLastName = \"User\";\r\n\t\t\tEmailAddress = \"dummy.user@testing.co.uk\";\r\n\t\t}\r\n\t}\r\n\r\n\tpublic class UserDto\r\n\t{\r\n\t\tpublic string EmailAddress { get; set; }\r\n\r\n\t\tpublic string LastName { get; set; }\r\n\r\n\t\tpublic string FirstName { get; set; }\r\n\r\n\t\tpublic int Id { get; set; }\r\n\t}\r\n\r\n\r\n\tinternal class Program\r\n\t{\r\n\t\tprivate static void Main( string[] args )\r\n\t\t{\r\n\t\t\tvar startTime = DateTime.Now;\r\n\t\t\tvar endTime = startTime.AddSeconds( 2 );\r\n\r\n\t\t\twhile ( endTime.Ticks > DateTime.Now.Ticks )\r\n\t\t\t{\r\n\t\t\t\tfor ( var i = 0; i < 200; i++ )\r\n\t\t\t\t{\r\n\t\t\t\t\t//Works fine\r\n\t\t\t\t\t//AutoMapper.Mapper.Map<UserViewModel, UserDto>( new UserViewModel(), opt => opt.CreateMissingTypeMaps = true );\r\n\r\n\r\n\t\t\t\t\t// Threading issue.\r\n\t\t\t\t\tnew Thread( () => AutoMapper.Mapper.Map<UserViewModel, UserDto>( new UserViewModel(), opt => opt.CreateMissingTypeMaps = true ) ).Start();\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\tConsole.WriteLine( \"Enter anything to quit\" );\r\n\t\t\tConsole.Read();\r\n\t\t}\r\n\t}\r\n}\r\n\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/AutoMapper/AutoMapper/issues/comments/120916432","html_url":"https://github.com/AutoMapper/AutoMapper/issues/620#issuecomment-120916432","issue_url":"https://api.github.com/repos/AutoMapper/AutoMapper/issues/620","id":120916432,"user":{"login":"lbargaoanu","id":4517428,"avatar_url":"https://avatars.githubusercontent.com/u/4517428?v=3","gravatar_id":"","url":"https://api.github.com/users/lbargaoanu","html_url":"https://github.com/lbargaoanu","followers_url":"https://api.github.com/users/lbargaoanu/followers","following_url":"https://api.github.com/users/lbargaoanu/following{/other_user}","gists_url":"https://api.github.com/users/lbargaoanu/gists{/gist_id}","starred_url":"https://api.github.com/users/lbargaoanu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lbargaoanu/subscriptions","organizations_url":"https://api.github.com/users/lbargaoanu/orgs","repos_url":"https://api.github.com/users/lbargaoanu/repos","events_url":"https://api.github.com/users/lbargaoanu/events{/privacy}","received_events_url":"https://api.github.com/users/lbargaoanu/received_events","type":"User","site_admin":false},"created_at":"2015-07-13T12:45:03Z","updated_at":"2015-07-13T12:45:03Z","body":"On my machine it complains with a NullReferenceException [here](https://github.com/AutoMapper/AutoMapper/blob/587ce3fc38d6319f1d9050d5b73b7fd7e0fc6bd8/src/AutoMapper/Mappers/TypeMapMapper.cs#L17). This is related to #781. In that branch it works. The cache needs updating when we create the new map."}}