Autocad Oracle

Autocad Oracle

ghwels
Explorer Explorer
560 Views
9 Replies
Message 1 of 10

Autocad Oracle

ghwels
Explorer
Explorer

I want to use Oracle from AC 2025. I installed "Oracle.ManagedDataAccess.Core 23.7.0"

ghwels_1-1738178007476.png

 


but when i want to connect to the database, i get an error

 

ghwels_0-1738177969207.png

 

0 Likes
561 Views
9 Replies
Replies (9)
Message 2 of 10

norman.yuan
Mentor
Mentor

Open *.csproj file, see if you have the 2 lines of red-circled configuration:

normanyuan_0-1738181434948.png

You can also look at the plugin DLL folder to verify whether at least the 2 dependency DLLs exist:

 

Oracle.ManagedDataAccess.dll

System.DirectoryServices.Protocols.dll

 

Norman Yuan

Drive CAD With Code

EESignature

0 Likes
Message 3 of 10

ghwels
Explorer
Explorer

ghwels_0-1738188238868.png

 

ghwels_1-1738188261086.png

 

0 Likes
Message 4 of 10

norman.yuan
Mentor
Mentor

You want also make sure this is included:

<RuntimeIdentifier>win-x64</RuntimeIdentifier>

Norman Yuan

Drive CAD With Code

EESignature

0 Likes
Message 5 of 10

ghwels
Explorer
Explorer

ghwels_0-1738216413464.png

 

0 Likes
Message 6 of 10

norman.yuan
Mentor
Mentor

OK, I did a quick code test, shown below:

    public class OracleDbUtils
    {
        public static bool IsConnected()
        {
            try
            {
                using (var conn=new Oracle.ManagedDataAccess.Client.OracleConnection())
                {
                    conn.ConnectionString = "xxxxxxxxxxxxxxxxxxxxxx";
                }

                return true;
            }
            catch
            {
                return false;
            }
        }
    }

Since I do not have access to a Oracle database server, as you can see, I only wrote extremely simple code: as long as the execution passes the line

 var conn = new OracleConnection()

then it means the Oracle DLLs are loaded successful. Here is the CommandMethod to call it:

        [CommandMethod("TestDbConnection")]
        public static void RunDocumentCommand()
        {
            var dwg = CadApp.DocumentManager.MdiActiveDocument;
            var ed = dwg.Editor;

            var connected = OracleDbUtils.IsConnected();
            ed.WriteMessage(
                $"Is AutoCAD connected to the database: {connected.ToString()}");
        }

The code runs OK, meaning the Oracle DLLs from the NuGet Package is loaded into my AutoCAD 2025 successfully.

 

So, it seems that there could be other things being the source of the error.

 

It might be because of you somehow targeting Windows 10/Window SDK (Not sure if WinRT.runtime.dll even be compatible with AutoCAD)?

 

I'd suggest you create a pure Acad2025 plugin project and add the Oracle Nuget package (as I did) and verify the Oracle DLLs can be loaded. Then you gradually add other references.

 

 

Norman Yuan

Drive CAD With Code

EESignature

0 Likes
Message 7 of 10

ghwels
Explorer
Explorer
[cid:image001.png@01DB7352.C4838DF0]

Thank you for your help. Unfortunately, the result is the same.

I usually program in Vb.net, but I deliberately created the program in C# this time.

I installed the package "Oracle.ManagedDataAccess.Core 23.7" via nuget and the autocad "accoremgd, AcCui, Acgbmgd, acmgd".

Operating system Windows 11 up to date.



If I test the same code not as a DLL but as a form application on the same computer, the database is opened correctly.

If I start the DLL on another computer, the same error occurs!
0 Likes
Message 8 of 10

norman.yuan
Mentor
Mentor

Sorry, can't help more since the Oracle DLLs loaded with my Acad2025 plugin Ok.

 

Norman Yuan

Drive CAD With Code

EESignature

0 Likes
Message 9 of 10

ghwels
Explorer
Explorer

Unfortunately, I still can't access the data from Autocad via Oracle.

This is probably because we are still running version Ora 21c on our server, but Net8 already requires version 23.
Nevertheless, many thanks from Austria.

0 Likes
Message 10 of 10

norman.yuan
Mentor
Mentor

Maybe it is time to catch up the technology trend to expose the data vis HTTP services, so AutoCAD does not need to know what the database server is and only need a HTTP client to access the serviced data. These days, most database server administrators do not want/do not allow a user client app to have direct access to the database server. The last time I wrote a CAD app that reached a database server directly was more than 15 years ago

Norman Yuan

Drive CAD With Code

EESignature

0 Likes