Discover errors in your .NET app you never knew were happening and use detailed error reports to squash them with ease. Make your app Exceptionless!
Sign up for FREE!
I just installed the full eval copy of CodeSmith and I am trying to run the NetTiers template. I created my database connection (SQL 2005) and tested it with no errors. I select the tables I want to use then click run. I am getting the following error and cannot seem to find any solutions in other posts.
System.TypeLoadException: Could not load type 'System.DateTimeOffset' from assembly 'mscorlib, Version=184.108.40.206, Culture=neutral, PublicKeyToken=b77a5c561934e089'. at SchemaExplorer.SchemaUtility.GetSystemType(DbType type) at SchemaExplorer.DataObjectBase.get_SystemType() at MoM.Templates.CommonSqlCode.GetCSType(DataObjectBase field, Boolean nullable) in e:\CodeSmith\Samples\v5.0\Templates\Frameworks\NetTiers\TemplateLib\CommonSqlCode.cs:line 3559 at MoM.Templates.CommonSqlCode.GetCSType(DataObjectBase field) in e:\CodeSmith\Samples\v5.0\Templates\Frameworks\NetTiers\TemplateLib\CommonSqlCode.cs:line 3507 at _CodeSmith.NetTiers_cst.MappingInstance.__RenderMethod1(TextWriter writer, Control control) in e:\CodeSmith\Samples\v5.0\Templates\Frameworks\NetTiers\SchemaMapping\NetTiersMapInstance.Internal.cst:line 25 at CodeSmith.Engine.DelegateControl.Render(TextWriter writer) at CodeSmith.Engine.Control.RenderChildren(TextWriter writer) at CodeSmith.Engine.Control.Render(TextWriter writer) at CodeSmith.Engine.CodeTemplate.Render(TextWriter writer) at _CodeSmith.NetTiers_cst.MappingInstance.Render(TextWriter writer) in e:\CodeSmith\Samples\v5.0\Templates\Frameworks\NetTiers\SchemaMapping\NetTiersMapInstance.Internal.cst:line 51 at _CodeSmith.NetTiers_cst.Go() in e:\CodeSmith\Samples\v5.0\Templates\Frameworks\NetTiers\NetTiers.cst:line 995 at _CodeSmith.NetTiers_cst.__RenderMethod1(TextWriter writer, Control control) in e:\CodeSmith\Samples\v5.0\Templates\Frameworks\NetTiers\NetTiers.cst:line 4620 at CodeSmith.Engine.DelegateControl.Render(TextWriter writer) at CodeSmith.Engine.Control.RenderChildren(TextWriter writer) at CodeSmith.Engine.Control.Render(TextWriter writer) at CodeSmith.Engine.CodeTemplate.Render(TextWriter writer) at CodeSmith.Engine.CodeTemplate.RenderToString() at CodeSmith.Gui.CodeTemplateGenerator.f(Object A_0, EventArgs A_1)
Any thoughts or suggestions would be greatly appreciated.
Are you using a Mappiing File? Is the path to the Mapping file valid? The line number above points to it trying to create a mapping file or something to do with the mapping file.
Also, silly question, but you do have the Framework 2.0 installed. I am assuming you do, but since the error is could not load type, I figure I would make sure. Not sure if it is a pre-req of codesmith 5 or not.
This is definetely an error I have not seen before.
---------------------------------------------------------------------- Member of the .NetTiers team | Visit http://www.nettiers.com----------------------------------------------------------------------
I am new to CodeSmith and NetTiers so please bear with my ignorance...
I do have Framework 2.0 installed (v2.0.50727) as well as 1.1 and 3.0.
When I look at the mapping file specified in the parameter "MappingFile", it looks like it gets partially created.
Here is what is in the mapping file once i receive the error:
<?xml version="1.0" encoding="utf-8"?><NetTiersMap xmlns="http://www.nettiers.com/NetTiersMap.xsd"> <Table Id="CHANGE_DETAIL" EntityName="ChangeDetail" Owner="dbo" PropertyName="ChangeDetail" FieldName="_changeDetail" FriendlyName="Change Detail" IncludeInOutput="true"> <Column Id="CHANGE_DETAIL_ID" CSType="
The column that it stopped on is just an int identity field. Even if I change the tables that it uses, I still get the error and the same output in the mapping file (except that the table and fieldnames are different.).
That datatype you are using is new to .net 3.5.
"System.DateTimeOffset: DateTimeOffset is a new date time data structure
that specifies an exact point in time relative to the UTC time zone".
I would set the .net version in the .netTiers template to .net 3.5, vs2008, and enterprise library to v4, delete the corrupt mapping file, and Download .net 3.5 (with service pack 1).
CodeSmith Tools, LLC. Software Development Engineer
.NetTiers team | Visit http://www.nettiers.net
Why do we have the option of using .net 2.0, vs2005 then if it only works with .net 3.5? I do not use vs2008 or .net 3.5. I want the code generated for .net 2.0 and vs2005. I have all the parameters in CodeSmith set to v2 and vs2005.
We give users the choice of what they want to use. However, that is totally dependent on what your targeting (schema wise, etc....) For example you wouldn't necessarily generate a SQL Server 2008 specific database and target .net 1.1...
I would attach a debugger at the following line and see why it is blowing up...
at MoM.Templates.CommonSqlCode.GetCSType(DataObjectBase field,
Boolean nullable) in
If you are unable to find the cause please send me the version of .netTiers you are using and your .csp, and sql schema and I will take a look at this issue.
I downloaded the latest version (2.2) and still get the same error. I attached the debugger and stopped at the section of code where the error occurs...
The code is trying to get "field.SystemType.ToString()" where field is a variable of type "SchemaExplorer.DataObjectBase". Here is what the variable field contains :
field.AllowDBNull = false
field.DataType = Int32
field.NativeType = "int"
field.Precision = 10
field.Scale = 0
field.Size = 4
field.SystemType = Throws the "System.TypeLoadException"
Obviously, this is where the problem is, but how can I look at the definition of the field.SystemType to see why it is failing?
You can't step into that really because you don't have the CodeSmith source code. If you send me your sql schema I will take a look and debug this issue. Could you please attach or email (BNiemyjski@codesmithtools.com) the schema to me along with your break point information.Thanks-Blake Niemyjski
I have built another test database and it works perfectly. I am currently trying to determine what is different between the databases.
Please keep me updated on what the cause of the issue was.Thanks-Blake Niemyjski
I'm getting the same error. Has anyone been able to resolve the problem?
Thanks in advance!
When I try to run nettiers in codesmith professional 5.0, I get the following error:
System.TypeLoadException: Could not load type 'System.DateTimeOffset' from assembly
Has anyone also had the same problem and been able to solve it?
Help would be very much appreciated!
I've been really trying to resolve this error but I can't repo it on any machine. Can you tell what operating system your using. The version of CodeSmith, .netTiers and SQL Server you are using. Also what versions of the .Net framework do you have installed? Any chance of you emailing me your sql schema so I can see if I can repo this with your schema. Thanks-Blake Niemyjski
If you send me your sql schema I will take a look. Could you please attach or email
I've been away for a long weekend, so it's a bit of a late reaction :-)
It's codesmith Professional 5.0, netTiers-2.2.0, SQL Server 2005 SP2 and .Net Framework 2.0 (with visual studio 2005).
When I run codesmith, the mappingfile stops at the first (data)row of the first table to generate. And the first field is not even a datetime field!
I will see what I can do for the schema... Thanks in advance for your efforts!