Can not create instance from static class

Can not create instance from static class

Postby mostafa_alshimi » Tue 23 Mar 2010 12:30

When i try to create new instance from the Context class provided from the entity developer it gives me an exception
"Cannot create an abstract class"
mostafa_alshimi
 
Posts: 1
Joined: Tue 23 Mar 2010 12:23

Postby AndreyR » Thu 25 Mar 2010 14:07

Could you please send me (support * devart * com, subject "LINQ: Cannot create an instance
of abstract class") a test project? I am unable to reproduce the problem.
AndreyR
Devart Team
 
Posts: 2919
Joined: Mon 07 Jul 2008 13:16

Cannot create an abstract class.

Postby r29003 » Wed 02 Jun 2010 04:47

Hello we are receiving this error, code below.
What we can do to solve this?

System.MissingMethodException: Cannot create an abstract class.
at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandle& ctor, Boolean& bNeedSecurityCheck)
at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean fillCache)
at System.RuntimeType.CreateInstanceImpl(Boolean publicOnly, Boolean skipVisibilityChecks, Boolean fillCache)
at System.Activator.CreateInstance(Type type, Boolean nonPublic)
at System.Activator.CreateInstance(Type type)
at Devart.Data.Linq.Mapping.i.h()
at Devart.Data.Linq.DataContext.a(Object A_0, MappingSource A_1, Type A_2)
at Devart.Data.Linq.DataContext..ctor(IDbConnection connection, MappingSource mapping)
at Hoteis.HoteisNet.Model..ctor(IDbConnection connection)
at Hoteis.HoteisNet.Business..ctor(String connectionName_)
at HoteisNetWS.Service..ctor() in E:\WebBusinessWorking\WSHoteisNetLinq\Service.asmx.cs:line 142

=====
using Devart.Data;
using Devart.Data.MySql;
using Devart.Data.Linq;

namespace Hoteis.HoteisNet
{
public partial class Model : Devart.Data.Linq.DataContext //DbLinq.Data.Linq.DataContext
{
private static System.Data.Linq.Mapping.MappingSource mappingSource = new Devart.Data.Linq.Mapping.AttributeMappingSource();

public Model(string connection) :
base(connection, new Devart.Data.Linq.Mapping.AttributeMappingSource() )
{

}
//Error happens here
public Model(System.Data.IDbConnection connection) :
base(connection, new Devart.Data.Linq.Mapping.AttributeMappingSource())
{

}
r29003
 
Posts: 2
Joined: Wed 02 Jun 2010 01:31
Location: Brasil

Postby AndreyR » Wed 02 Jun 2010 15:20

Could you please check that the generated code file contains the following attribute?
Code: Select all
[ProviderAttribute(typeof(Devart.Data.Oracle.Linq.Provider.OracleDataProvider))]
AndreyR
Devart Team
 
Posts: 2919
Joined: Mon 07 Jul 2008 13:16

Cannot create an abstract class.

Postby r29003 » Wed 02 Jun 2010 19:02

Hi, we do not have this file in our project. The project in question is a c# project for database access using mysql and LINQ that is compiled as a DLL and used in another project.

I have to generate the file DataContext.cs?

Regards
r29003
 
Posts: 2
Joined: Wed 02 Jun 2010 01:31
Location: Brasil

Postby AndreyR » Thu 03 Jun 2010 09:49

We have analyzed the call stack and the most obvious reason of this problem is the missing ProviderAttribute.
Could you please inspect the LINQ to MySQL-generated Business.Designer.cs file for this attribute?
If it's in place, please create a small test project illustrating the problem and send it to us (support * devart * com, subject "Cannot create instance of abstract class").
AndreyR
Devart Team
 
Posts: 2919
Joined: Mon 07 Jul 2008 13:16


Return to LinqConnect (LINQ to SQL support)