Creating datatype from code

Topics: Troubleshooting
Jun 22, 2011 at 6:41 PM
Edited Jun 22, 2011 at 6:41 PM

Hi ,

I've created a custom C# function that u use for creating a datatype object called "Spiller".

This is the code i'm using:

Spiller user = DataFacade.BuildNew<Spiller>();
        user.Id = Guid.NewGuid();
        user.Name = name;
        user.CreatedDate = DateTime.Now;
        user.Username = username;
        user.Password = Cryptographer.Encrypt( password );
        user.Email = username;
        user.Group = "Spillere";
        DataFacade.AddNew<Spiller>( user, true );
This code has workied, but after updating to 
Composite C1 2.1
Build no. 2.1.4087.22991
 
This code does not work anymore.
This is the error i get now:
 

0 writeable data providers exists for data 'Volleyball.Data.Spiller'.

Beskrivelse: Der opstod en undtagelse, der ikke blev behandlet, under udførelse af den aktuelle webanmodning. Se staksporingen for at få flere oplysninger om fejlen, og hvor den kom fra i koden. 

Detaljer om undtagelse: System.InvalidOperationException: 0 writeable data providers exists for data 'Volleyball.Data.Spiller'.

Kildefejl: 

Der blev oprettet en undtagelse, der ikke blev behandlet,  under kørsel af den aktuelle webanmodning. Du kan finde oplysninger om undtagelsens oprindelse og placering ved hjælp af nedenstående staksporing af undtagelser.

Staksporing: 

[InvalidOperationException: 0 writeable data providers exists for data 'Volleyball.Data.Spiller'.]
   Composite.Data.DataFacadeImpl.AddNew(IEnumerable`1 datas, Boolean allowStoreCreation, Boolean suppressEventing, Boolean performForeignKeyIntegrityCheck, Boolean performeValidation, List`1 writeableProviders) +806
   Composite.Data.DataFacadeImpl.AddNew(IEnumerable`1 datas, Boolean allowStoreCreation, Boolean suppressEventing, Boolean performForeignKeyIntegrityCheck, Boolean performeValidation, List`1 writeableProviders) +454
   Composite.Data.DataFacade.AddNew(T data, Boolean performForeignKeyIntegrityCheck) +164
   UserControls.WebUserControl1.Create_Click(Object sender, EventArgs e) +2519
   System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +154
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3691
 What could be wrong?

Regards
 Martin
Jun 22, 2011 at 6:54 PM

The upgrade may have caused an effect, where your datatype live in two assemblies - one instance in ~/bin/Composite.Generated.dll (this is the type that your ASP.NET code see) and another instance in a freshly compiled assembly, living below  ~/App_Data/Composite/Cache/Assemblies (the one that the C1 data core sees).

First check if a simple app restart fix your issue - if fresh type compilations exist, the ~/bin/Composite.Generated.dll assembly will be refreshed when you restart the app, and your type now live there from this point on.

If this does not fix your problem, something is likely blocking the generation ~/bin/Composite.Generated.dll - you can veryfy this by seeing that the time stamp of this file do not refresh. If this should be your issue, see napernik's "how to fix the cache" here.

Jun 22, 2011 at 7:27 PM

Restarting the application recreated Composite.Generated.dll, but i still get the error.

I haven't tried napernik's guide, since it's only for when your suggestion disn't work? Or..`?

Jun 22, 2011 at 7:53 PM

Check the Composite C1 server log - there might be some good explanation in it. If nothing is there, I'd grab a backup and try the cache clean.

Jun 24, 2011 at 1:07 AM

@boedlen were you able to solve the issue or are you still experiencing it?