Cannot modify object via API "StartUnitOfWork"

Hi all,

I tried to modify an attribute of the person object via the API in system debugger with the following code :

dbPerson = Session.Source.Get("Person", "38d611af-e1aa-4ffd-b4b4-79672d2cc21e")

' Update CustomProperty09 (Person)
dbPerson.PutValue("CustomProperty10", "test")

' Save person to database
Using uow As IUnitOfWork = Session.StartUnitOfWork()
    uow.Put(dbPerson)
    uow.Commit()
End Using

But i get always an error at line uow.put(dbPerson)

{"Error during execution of 'OnLoaded' in logic module 'VI.DB.Entities.EntityScriptLogic'."}

{"Could not load type 'DynScripts.Tables' from assembly 'Tables, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'.":"DynScripts.Tables"}

Do you know how to resolve this ?

Regards,

Truc

Parents
  • Sounds like you haven't compiled the database correctly (Scripts including all dependencies). This error points to the typed-wrapper assemblies that are built during the compilation.

    By the way, which version are you using?

  • My version is OIM 8.0.2., here the detailed error on system debugger :

    Exception has been thrown by the target of an invocation.
    	at SystemDebugger.Controls.ScriptDebugControl.StartScript(MethodInfo script, Boolean bDebugStop, Boolean bTransaction)
    	at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)
    	at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
    	at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
    	at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
    Thread was being aborted.
    	at VI.DB.Entities.EntityBase.GetDebuggerDisplay()
    	at VI.DB.Entities.EntityBase.get_Display()
    	at VI.Base.SyncActions.Do[T](Func`1 function)
    	at System.Threading.Tasks.Task`1.get_Result()
    	at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)
    	at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
    	at System.Threading.Tasks.Task.GetExceptions(Boolean includeTaskCanceledExceptions)
    	at System.Threading.Tasks.TaskExceptionHolder.CreateExceptionObject(Boolean calledFromFinalizer, Exception includeThisException)
    	at System.Environment.GetResourceFromDefault(String key)
    	
    ....
    
    2020-04-14 13:56:27	SqlLog	(3 ms) - select 1 where exists (select 1 from PersonInAERole where (UID_AERole = 'QER-AEROLE-AEADMIN'))
    2020-04-14 13:56:27	ObjectLog	Run statement and fetch data done in 4ms.
    2020-04-14 13:56:27	ObjectLog	Session variable: Setting QER.Customizer.Person.AdminUserExists to True.
    2020-04-14 13:56:27	ObjectLog	Result: CreateAdminUser(VI.DB.Entities.ISession, VI.DB.Entities.IEntity, System.Threading.CancellationToken) MethodEnabled = False
    2020-04-14 13:56:27	ObjectLog	Action on CreateAdminUser(VI.DB.Entities.ISession, VI.DB.Entities.IEntity, System.Threading.CancellationToken) MethodVisible depends on _AdminUserExists
    2020-04-14 13:56:27	ObjectLog	Result: CreateAdminUser(VI.DB.Entities.ISession, VI.DB.Entities.IEntity, System.Threading.CancellationToken) MethodVisible = False
    2020-04-14 13:56:27	ObjectLog	Old state: Loaded, LogicInitialize, New state: Loaded
    2020-04-14 13:56:27	StopWatch	Getting PolicyColumns/global from cache. done in 11ms.....
    2020-04-14 13:56:27	ObjectLog	Old state: Loaded, New state: Loaded, LogicInitialize
    2020-04-14 13:56:27	ObjectLog	Person: Initializing Customizer
    2020-04-14 13:56:27	ObjectLog	Action on ComplianceCheckSimple(VI.DB.Entities.ISession, VI.DB.Entities.IEntity, System.Threading.CancellationToken) MethodEnabled depends on [IsLoaded], Config(QER\ComplianceCheck\SimpleMode)
    2020-04-14 13:56:27	ObjectLog	Result: ComplianceCheckSimple(VI.DB.Entities.ISession, VI.DB.Entities.IEntity, System.Threading.CancellationToken) MethodEnabled = True
    2020-04-14 13:56:27	ObjectLog	Old state: Loaded, LogicInitialize, New state: Loaded
    2020-04-14 13:56:27	ObjectLog	Executing OnLoaded...
    2020-04-14 13:56:28	ObjectLog	Rollback transaction in read/write entity
    2020-04-14 13:56:28	SqlLog	(7 ms) - Reading BLOB from table Person, column 

    And when i compiled the database i did not see any error on designer :

    https://github.com/sieutruc/thp2/blob/master/iga_script_compile.jpg

    I can give you all the information necessary.

  • Did you try to re-create the system library including just the system scripts and updating the project references?

  • Thank you for you help,

    I found the problem. 

    I reload all the scripts from the database and i found an error when compiling the script. And i iuse designer to modify and commit the change to db. AFter that i can modify the object as shown on your videos.

    I juste have a questions , my developer creates something like the following : 

    ' VI-KEY(<Key><T>DialogScript</T><P>CCC-C60CC6B5321296498AF0BA3E719BEC2E</P></Key>, CCC_Button)
    
        <BaseObjectTypeAttribute("UNSAccountB")> _
        Public Function CCC_Button_Insert(ByVal dbObject As ISingleDbObject) As String
            Return CCC_Button_Mail(dbObject, "Insert")
        End Function
    
        <BaseObjectTypeAttribute("UNSAccountB")> _
        Public Function CCC_Button_Update(ByVal dbObject As ISingleDbObject) As String
            Return CCC_Button_Mail(dbObject, "Update")
        End Function
    
        <BaseObjectTypeAttribute("UNSAccountB")> _
        Public Function CCC_Button_Update_Password(ByVal dbObject As ISingleDbObject) As String
            Return CCC_Button_Mail(dbObject, "UpdatePassword")
        End Function
    
        <BaseObjectTypeAttribute("UNSAccountB")> _
        Public Function CCC_Button_Delete(ByVal dbObject As ISingleDbObject) As String
            Return CCC_Button_Mail(dbObject, "Delete")
        End Function
    
        Private Function CCC_Button_Mail(ByVal dbObject As ISingleDbObject, ByVal strDecisionType As String) As String
            Dim strSubject As String = String.Empty
            Dim strbodyText As New System.Text.StringBuilder
            ...
        End Function

    I do not know that one VI-KEY can contain several functions (in your video you did not say about this). And when one function does not compile, i do not see any error when compiing the database and even in the logs, until i reload them in system debugger.

    And in the system debugger it does not show the function name that contains the error. I have to use designer to correct that function.

    So how can i get the log of this compilation error ? to know exactly where it is when doing on designer or object browser ?

Reply
  • Thank you for you help,

    I found the problem. 

    I reload all the scripts from the database and i found an error when compiling the script. And i iuse designer to modify and commit the change to db. AFter that i can modify the object as shown on your videos.

    I juste have a questions , my developer creates something like the following : 

    ' VI-KEY(<Key><T>DialogScript</T><P>CCC-C60CC6B5321296498AF0BA3E719BEC2E</P></Key>, CCC_Button)
    
        <BaseObjectTypeAttribute("UNSAccountB")> _
        Public Function CCC_Button_Insert(ByVal dbObject As ISingleDbObject) As String
            Return CCC_Button_Mail(dbObject, "Insert")
        End Function
    
        <BaseObjectTypeAttribute("UNSAccountB")> _
        Public Function CCC_Button_Update(ByVal dbObject As ISingleDbObject) As String
            Return CCC_Button_Mail(dbObject, "Update")
        End Function
    
        <BaseObjectTypeAttribute("UNSAccountB")> _
        Public Function CCC_Button_Update_Password(ByVal dbObject As ISingleDbObject) As String
            Return CCC_Button_Mail(dbObject, "UpdatePassword")
        End Function
    
        <BaseObjectTypeAttribute("UNSAccountB")> _
        Public Function CCC_Button_Delete(ByVal dbObject As ISingleDbObject) As String
            Return CCC_Button_Mail(dbObject, "Delete")
        End Function
    
        Private Function CCC_Button_Mail(ByVal dbObject As ISingleDbObject, ByVal strDecisionType As String) As String
            Dim strSubject As String = String.Empty
            Dim strbodyText As New System.Text.StringBuilder
            ...
        End Function

    I do not know that one VI-KEY can contain several functions (in your video you did not say about this). And when one function does not compile, i do not see any error when compiing the database and even in the logs, until i reload them in system debugger.

    And in the system debugger it does not show the function name that contains the error. I have to use designer to correct that function.

    So how can i get the log of this compilation error ? to know exactly where it is when doing on designer or object browser ?

Children