{"action":"created","issue":{"url":"https://api.github.com/repos/castleproject/Core/issues/63","labels_url":"https://api.github.com/repos/castleproject/Core/issues/63/labels{/name}","comments_url":"https://api.github.com/repos/castleproject/Core/issues/63/comments","events_url":"https://api.github.com/repos/castleproject/Core/issues/63/events","html_url":"https://github.com/castleproject/Core/issues/63","id":41925352,"number":63,"title":"Parameterless Constructor not needed ","user":{"login":"janschmidmaier","id":8654978,"avatar_url":"https://avatars.githubusercontent.com/u/8654978?v=3","gravatar_id":"","url":"https://api.github.com/users/janschmidmaier","html_url":"https://github.com/janschmidmaier","followers_url":"https://api.github.com/users/janschmidmaier/followers","following_url":"https://api.github.com/users/janschmidmaier/following{/other_user}","gists_url":"https://api.github.com/users/janschmidmaier/gists{/gist_id}","starred_url":"https://api.github.com/users/janschmidmaier/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/janschmidmaier/subscriptions","organizations_url":"https://api.github.com/users/janschmidmaier/orgs","repos_url":"https://api.github.com/users/janschmidmaier/repos","events_url":"https://api.github.com/users/janschmidmaier/events{/privacy}","received_events_url":"https://api.github.com/users/janschmidmaier/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":6,"created_at":"2014-09-04T11:34:20Z","updated_at":"2015-09-10T06:51:48Z","closed_at":null,"body":"When Creating a Proxy using `CreateClassProxyWithTarget` the Target must have a parameterless Constructor.\r\nFrom my point of view, it would be easy sometimes, to be able to create a non initialized object, by calling\r\n`object newObject = FormatterServices.GetUninitializedObject(type);`\r\n\r\n```csharp\r\nprotected object CreateClassProxyInstance(Type proxyType, List<object> proxyArguments, Type classToProxy, object[] constructorArguments)\r\n{\r\n  try\r\n  {\r\n      if (constructorArguments != null && constructorArguments.Length != 0)\r\n        return Activator.CreateInstance(proxyType, proxyArguments.ToArray());\r\n\r\n      foreach (var ctor in proxyType.GetConstructors())\r\n        if (!ctor.GetParameters().Any())\r\n          return Activator.CreateInstance(proxyType, proxyArguments.ToArray());\r\n\r\n      return FormatterServices.GetUninitializedObject(proxyType)\r\n  }\r\n  catch (MissingMethodException ex)\r\n  {\r\n    StringBuilder stringBuilder = new StringBuilder();\r\n    stringBuilder.AppendFormat(\"Can not instantiate proxy of class: {0}.\", (object) classToProxy.FullName);\r\n    stringBuilder.AppendLine();\r\n    if (constructorArguments == null || constructorArguments.Length == 0)\r\n    {\r\n      stringBuilder.Append(\"Could not find a parameterless constructor.\");\r\n    }\r\n    else\r\n    {\r\n      stringBuilder.AppendLine(\"Could not find a constructor that would match given arguments:\");\r\n      foreach (object obj in constructorArguments)\r\n      {\r\n        string str = obj == null ? \"<null>\" : obj.GetType().ToString();\r\n        stringBuilder.AppendLine(str);\r\n      }\r\n    }\r\n    throw new InvalidProxyConstructorArgumentsException(((object) stringBuilder).ToString(), proxyType, classToProxy);\r\n  }\r\n}\r\n```"},"comment":{"url":"https://api.github.com/repos/castleproject/Core/issues/comments/139132360","html_url":"https://github.com/castleproject/Core/issues/63#issuecomment-139132360","issue_url":"https://api.github.com/repos/castleproject/Core/issues/63","id":139132360,"user":{"login":"kkozmic","id":117943,"avatar_url":"https://avatars.githubusercontent.com/u/117943?v=3","gravatar_id":"","url":"https://api.github.com/users/kkozmic","html_url":"https://github.com/kkozmic","followers_url":"https://api.github.com/users/kkozmic/followers","following_url":"https://api.github.com/users/kkozmic/following{/other_user}","gists_url":"https://api.github.com/users/kkozmic/gists{/gist_id}","starred_url":"https://api.github.com/users/kkozmic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kkozmic/subscriptions","organizations_url":"https://api.github.com/users/kkozmic/orgs","repos_url":"https://api.github.com/users/kkozmic/repos","events_url":"https://api.github.com/users/kkozmic/events{/privacy}","received_events_url":"https://api.github.com/users/kkozmic/received_events","type":"User","site_admin":false},"created_at":"2015-09-10T06:51:48Z","updated_at":"2015-09-10T06:51:48Z","body":"Right, I see.\r\n\r\nWhat would be a scenario where that's preferable?"}}