codesmithtools / Templates

CodeSmith Generator Templates
http://www.codesmithtools.com/product/generator
54 stars 35 forks source link

from NHibernateMaster.cst to oplinqnh #708

Closed fssamu closed 7 years ago

fssamu commented 7 years ago

Hi, I must modify a project developed with codesmith 5.0 and nhibernate template. I try codesmith 7.1 but many thing are changed, and my business layer (many lines of code) is developed on the ManagerObjects. In 7.1 manager object are not present (now replaced by datacontex (I think)) I've try to use the 5.0 version in vs 2015, but don't work,,,, There are any sample of porting a project in 5.0 in 7.1 Regards Sam

niemyjski commented 7 years ago

You could continue to use your existing templates in 7.x, what errors are you seeing? As far as work arounds, there are two different patterns and really no easy clear cut way to upgrade from one pattern to the other automatically.

fssamu commented 7 years ago

When I try to open the template, I receive this error message: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.NullReferenceException: Object reference not set to an instance of an object. at CodeSmith.Engine.CodeTemplate..ctor() at NHibernateHelper.NHibernateHelper..ctor() at _CodeSmith.NHibernateMaster_cst..ctor() --- End of inner exception stack trace --- at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck) at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark) at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark) at System.Activator.CreateInstance(Type type, Boolean nonPublic) at System.Activator.CreateInstance(Type type) at CodeSmith.Engine.CompileTemplateResult.#DQb.#NVb() at CodeSmith.Core.Extensions.RetryUtil.Retry(Action action, Int32 attempts, Int32 retryTimeout) at CodeSmith.Engine.CompileTemplateResult.CreateTemplateInstance() at CodeSmith.Engine.CodeTemplateCompiler.CreateInstance() at CodeSmith.Gui.AddOutput.#rM(String #XBb)

I'm using the template NHibernateMaster.cst contained in NHibernate-v1.2.1.2125

Regards Sam

niemyjski commented 7 years ago

Your getting this error because the templates need to be recompiled as described here (https://codesmith.atlassian.net/wiki/display/Generator/Upgrading+CodeSmith+Generator+Templates) You'll need to open up the solution in the Source folder and rebuild it (CodeSmith.Engine reference needs to be updated to point to the v7 version). We changed the assembly binding version and this is why you get an error. Can you please try this and let me know if you are still running into any issues.