System.Exception: Unknown driver "DEVART_POSTGRESQL.NET". How embed it?

According to this answer: http://connect.remobjects.com/discussion/comment/2946#Comment_2946 I add the DEVART_POSTGRESQL option to the daConfig file.

In the moment of deploy, if I put the file in the same folder as the exe, so far so good. However, if is executed in from a diferent path (or when try to run the exe from other exe, like for testing with TestDriven.NET) get the error

System.Exception: Unknown driver “DEVART_POSTGRESQL.NET”

So, I add the daConfig as a resource in the project. But that not work. Is possible to add in runtime the definition?

Hello.

To solve the problem please use .daConfig as an embedded resource as before but change Engine.cs file as follows:
from:


if (!RemObjects.DataAbstract.Server.Configuration.Loaded)
RemObjects.DataAbstract.Server.Configuration.Load();

to:

if (!RemObjects.DataAbstract.Server.Configuration.Loaded)
RemObjects.DataAbstract.Server.Configuration.LoadFromResource();
or:
RemObjects.DataAbstract.Server.Configuration.LoadFromResource();

It will allow to load drivers configuration directly from embedded .daConfig file.

Hope this helps.

Yep, that work - almost. The config is loaded but the error still happend. I don’t know if could be a issue with the licensing of the devart file.

Thanks for the help.

Hello.

Does the application work correctly if it start not under TestDriven.net? Also can you send us the code where you load driver configuration?

Thanks in advance.

Yes, it work. Also fail when run with Gallio.echo command-line test runner (so, I suspect if the exe call the server in a path different to the one used for VS to launch the exe, this happend).

This is my code, based in the Server sample:

       public ROServer()
        {
            InitializeComponent();
            // Load DB configurations and project connection configuration
            string lFolder = Path.GetDirectoryName(typeof(ROServer).Assembly.Location);
            DataFolder = Path.GetFullPath(Path.Combine(lFolder, "..", "Data"));
          
            //RemObjects.DataAbstract.Server.Configuration.Load();
            //if (!RemObjects.DataAbstract.Server.Configuration.Loaded)
            RemObjects.DataAbstract.Server.Configuration.LoadFromResource();

            ConnectionManager.LoadFromFile(Path.Combine(DataFolder, "BestSeller.daConnections"));

            foreach (ConnectionDefinition c in ConnectionManager.ConnectionDefinitions)
            {
                c.ConnectionString = c.ConnectionString.Replace('\\', Path.DirectorySeparatorChar);
                c.ConnectionString = c.ConnectionString.Replace("%SERVER%", lFolder);
            }
			JsonMessage.SessionIdAsId = true;
            HttpDirectoryDispatcher lPathDispatcher = new HttpDirectoryDispatcher();
            lPathDispatcher.Path = "/javascript";
            lPathDispatcher.Directory = Path.Combine(lFolder, "javascript");
            lPathDispatcher.Server = ServerChannel;
        }

Hello.

Does using

   RemObjects.DataAbstract.Server.Configuration.LoadFromResource()

returns the same result as using

   RemObjects.DataAbstract.Server.Configuration.LoadFromResource();

?

Thanks in advance.

No, igual result.

I can workaround it using Devart to build the schema and NPGSQL.NET for actual testing, but still is weird what is happening…

Hello.

Thank you for the testcase. This problem is related to getting standard .daConfig file from wrong assembly by DataAbstract that doesn’t include information about Devart driver. Please use the next solution:

       public ROServer()
        {
            InitializeComponent();
            // Load DB configurations and project connection configuration
            string lFolder = Path.GetDirectoryName(typeof(ROServer).Assembly.Location);
            DataFolder = Path.GetFullPath(Path.Combine(lFolder, "..", "Data"));
 
            //RemObjects.DataAbstract.Server.Configuration.Load();
            if (!RemObjects.DataAbstract.Server.Configuration.Loaded)
            {
                  //RemObjects.DataAbstract.Server.Configuration.LoadFromResource();  
                  RemObjects.DataAbstract.Server.ConfigurationAccess.RetrieveConfig("DataAbstract.daConfig",Assembly.GetExecutingAssembly(), out doc);
                   RemObjects.DataAbstract.Server.Configuration.LoadFromXml(doc);
            }   
 

            //ConnectionManager.LoadFromFile(Path.Combine(DataFolder, "BestSeller.daConnections"));
	    XmlDocument lConnectionsXml = new XmlDocument();
	    lConnectionsXml.Load(typeof(Engine).Assembly.GetManifestResourceStream(typeof(Engine).Assembly.GetName().Name + ".daConnections")); //argument - path to BestSeller.daConnections
    	    this.connectionManager.LoadFromXml(lConnectionsXml);
 
            foreach (ConnectionDefinition c in ConnectionManager.ConnectionDefinitions)
            {
                c.ConnectionString = c.ConnectionString.Replace('\\', Path.DirectorySeparatorChar);
                c.ConnectionString = c.ConnectionString.Replace("%SERVER%", lFolder);
            }

            JsonMessage.SessionIdAsId = true;
            HttpDirectoryDispatcher lPathDispatcher = new HttpDirectoryDispatcher();
            lPathDispatcher.Path = "/javascript";
            lPathDispatcher.Directory = Path.Combine(lFolder, "javascript");
            lPathDispatcher.Server = ServerChannel;
        }

Hope this helps.