This is a migrated thread and some comments may be shown as answers.

scope problem

1 Answer 30 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
amir sherafatian
Top achievements
Rank 1
amir sherafatian asked on 19 Apr 2010, 08:54 AM

hi
i have "Object reference not set to an instance of an object." exception on adding new object. how to solve it ?

Detail :
i have 2 class library (EandE.ISOConvertor and EandE.DocumentControl.BSL) and one windows application
in "EandE.ISOConvertor" classlibrary i use the forward mapping and in "EandE.DocumentControl.BSL" class library i use reverse mapping

my senario is fetch data from ISODatabase by "EandE.ISOConvertor" classribrary and convert old object that is fecthed to new object in intermediate windows application and after, add by using "EandE.DocumentControl.BSL" classlibrary

i enable openaccess for my 2 class library and one windows application and connected them to own database like this :

"EandE.ISOConvertor" classribrary connected to (ISODataBase)
intermediate windows application connected to (eeOptimizerDataBase)
"EandE.DocumentControl.BSL" classribrary connected to (eeOptimizerDataBase)

in "EandE.ISOConvertor" class library i only need to fetch data using instance of iobjectscopequery, so i use the property for getting scope,i define property in my class manager in "EandE.ISOConvertor" class library like this:

private IObjectScope _scope;
public IObjectScope scope
        {
            get
            {
                if (_scope == null)
                {
                    ObjectScopeProvider1.AdjustForDynamicLoad();
                    _scope = Database.Get("DatabaseConnectionISO").GetObjectScope();
                }
                return _scope;
            }
            set
            {
                _scope = value;
            }
        }

and for returning data in all methods that i have in "EandE.ISOConvertor" class library i use this property

also i have a property in my intermediate windows application to get scope,and passing it to the registration methods , my property definition is :

private IObjectScope _scope;
public IObjectScope scope
        {
            get
            {
                if (_scope == null)
                    _scope = Database.Get("DatabaseConnectionEEOptimizer").GetObjectScope();
                return _scope;
            }
            set
            {
                _scope = value;
            }
        }

when i fetch data i convert object that i fected to new object that is in "EandE.DocumentControl.BSL"class library in intermediate windows application,after converting i call the registration method and pass the new object and new scope(i get scope from property define in windows application) to it;

but in line "scope.add(newObject)" i have "Object reference not set to an instance of an object." exception
and my stack trace is :

   at Telerik.OpenAccess.SPI.Backends.ThrowException(Exception e)
   at Telerik.OpenAccess.RT.ExceptionWrapper.Throw()
   at OpenAccessRuntime.DataObjects.OpenAccessPersistenceManagerImp.handleException(Exception x)
   at OpenAccessRuntime.DataObjects.OpenAccessPersistenceManagerImp.makePersistent(Object o)
   at OpenAccessRuntime.DataObjects.UnsynchronizedPMProxy.makePersistent(Object o)
   at Telerik.OpenAccess.RT.ObjectScope.Add(Object pc)
   at EandE.DocumentControl.BSL.Managers.DCGroupManager.RegisterNewDCGroup(DCGroup group, Boolean commitOnEnd, IObjectScope scope) in D:\Sherafatian\EandEOptimizer2010\EE\BSL\EandE.DocumentControl.BSL\Managers\DCGroupManager.cs:line 131

i`m sure that i fill all property of newobject,and aslo i`m sure all object that i use in my algorithm fill before using

probably the problem is in scope,

do you have any idea for solving my problem

1 Answer, 1 is accepted

Sort by
0
amir sherafatian
Top achievements
Rank 1
answered on 20 Apr 2010, 06:53 AM
can any body help me?
Tags
General Discussions
Asked by
amir sherafatian
Top achievements
Rank 1
Answers by
amir sherafatian
Top achievements
Rank 1
Share this question
or