vrakeshreddy / mb-unit

Automatically exported from code.google.com/p/mb-unit
0 stars 0 forks source link

Linq and DataContext NullReference Exception #640

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Summary: When I run a test which uses a Linq DataContext I get an 
NullReferenceException.

My web project was in Visual Studio 2005, ASP.NET 2.0. I converted the 
project to Visual Studio 2008 and added Linq DLLs into the project.

I wrote code to select and add records to some tables using the Linq 
DataContext. This code works just fine when I run the project normally.

I wrote some MbUnit tests to test the Linq related code. The first thing I 
do in the test is instantiate the Linq DataContext:

Dc = new DataClasses1DataContext()

I ran the test from Gallio and I get an exception on the constructor in the 
Linq data context:

        public DataClasses1DataContext() : 

base(global::System.Configuration.ConfigurationManager.ConnectionStrings["u
sagreencardConnectionString"].ConnectionString, mappingSource)
        {
            OnCreated();
        }

I'm assuming the ConfigurationManager is not available in the Gallio 
context.

I've attached a screenshot of the Gallio execution log.

Gallio 3.0.6

Ed

Original issue reported on code.google.com by FlyFloat...@gmail.com on 18 Mar 2010 at 4:50

Attachments:

GoogleCodeExporter commented 9 years ago
Create a configuration file called UsaGreenCardWeb.dll.config with the 
configuration
strings.

Also, I highly recommend upgrading to Gallio v3.1.  The performance is much 
improved.

Original comment by jeff.br...@gmail.com on 18 Mar 2010 at 10:20

GoogleCodeExporter commented 9 years ago
Jeff,

re: UsaGreenCardWeb.dll.config. What is the format of this config file? Same as 
web.config? Can you provide a small example or point me to some docs?

Original comment by FlyFloat...@gmail.com on 19 Mar 2010 at 2:40

GoogleCodeExporter commented 9 years ago
Yes, the format is exactly the same as for a web.config or exe.config file.

Original comment by grahamr...@gmail.com on 30 Mar 2010 at 4:42