Running Transformation: System.NullReferenceException

Nov 4, 2010 at 9:57 PM

I just started using this tool today.  I am having trouble using it.  I have done this several times...

Here's what I did:

  1. I made a simple project (classlibrary). 
  2. Inserted a new Model.edmx
  3. Added one entity
  4. Added property to entity
  5. Adjusted the CSLA parameters (namespaces and templates)
  6. Build -build succeeded
  7. Inserted a new CslaExtension
  8. Build -build succeeded
  9. Adjusted Model.edmx -added another property
  10. Build -build succeeded with error ??
  11. Error:

Error Running transformation: System.NullReferenceException: Object reference not set to an instance of an object.
   at Microsoft.VisualStudio.TextTemplating56F38FC271C56283C647EF4813BF3059.GeneratedTextTransformation.Property.Create(EdmProperty entityProperty, Boolean isKey, MetadataContext ctx, Model model, Entity entity) in e:\Visual Studio 2010\Projects\ClassLibrary\ClassLibrary\CslaExtension1.tt:line 1902
   at Microsoft.VisualStudio.TextTemplating56F38FC271C56283C647EF4813BF3059.GeneratedTextTransformation.Entity.Create(EntitySet entitySet, MetadataContext ctx, Model model) in e:\Visual Studio 2010\Projects\ClassLibrary\ClassLibrary\CslaExtension1.tt:line 1745
   at Microsoft.VisualStudio.TextTemplating56F38FC271C56283C647EF4813BF3059.GeneratedTextTransformation.Model.Create(MetadataContext ctx) in e:\Visual Studio 2010\Projects\ClassLibrary\ClassLibrary\CslaExtension1.tt:line 1637
   at Microsoft.VisualStudio.TextTemplating56F38FC271C56283C647EF4813BF3059.GeneratedTextTransformation.Generate(String inputFileName) in e:\Visual Studio 2010\Projects\ClassLibrary\ClassLibrary\CslaExtension1.tt:line 41
   at Microsoft.VisualStudio.TextTemplating56F38FC271C56283C647EF4813BF3059.GeneratedTextTransformation.TransformText() in e:\Visual Studio 2010\Projects\ClassLibrary\ClassLibrary\CslaExtension1.tt:line 28
   at Microsoft.VisualStudio.TextTemplating.TransformationRunner.RunTransformation(TemplateProcessingSession session, String source, ITextTemplatingEngineHost host, String& result)  1 

This error stays in the solution until i restart VS.  The CslaExtension wont generate classes.  So I restart with a fresh project...

  1. I made a simple project (classlibrary). 
  2. Inserted a new Model.edmx
  3. Added one entity
  4. Added property to entity
  5. Adjusted the CSLA parameters (namespaces and templates)
  6. Build -build succeeded
  7. Inserted a new CslaExtension
  8. Build -build succeeded with error ??
  9. Error: SAME AS ABOVE

I have to uninstall extension, shutdown VS, reinstall extension.  The cycle repeats itself starting from the top of this post.

What am I doing wrong?

Many thanks in advance!
 

Nov 4, 2010 at 10:07 PM

I feel stupid but figured out the problem.  I had to set the string Property of my Entity -> Facets -> Max Length = Max.

All is working well now.  This is a great tool!!

Thanks!

Nov 4, 2010 at 10:20 PM

Hi jayblaze.

Usually this error is connected to edmx file path in the T4 template. When you add a new CslaExtension.tt file, open the file and check path to the edmx file.

Regards,

Josip

Feb 7, 2012 at 4:02 PM

jayblaze

This may have been simple but you just saved me lots of time. 

Thanks!