ACCORECONSOLE - unable to load assembly

ACCORECONSOLE - unable to load assembly

fieldguy
Advisor Advisor
2,888 Views
15 Replies
Message 1 of 16

ACCORECONSOLE - unable to load assembly

fieldguy
Advisor
Advisor

I am having trouble loading an assembly with ACCORECONSOLE.  The development path (local drive F:) is included in the "trusted paths".  If I use "NETLOAD" in autocad 2018, there is no warning - that tells me trusted path is working.  I have also "trusted" the folder that contains my "SCR" file.  SECURELOAD is set to 1.

 

I also tried adding <loadFromRemoteSources enabled="true"/> to accoreconsole.exe.config but that does not help.

 

Everything works fine if I copy my dll to C:\Program Files\Autodesk\AutoCAD 2018.

Accepted solutions (1)
2,889 Views
15 Replies
Replies (15)
Message 2 of 16

BlackBox_
Advisor
Advisor

What Profile are you using in full AutoCAD (where the Trusted Path is added), and is that the same Profile being supplied as parameter when calling Core Console?


"How we think determines what we do, and what we do determines what we get."

Sincpac C3D ~ Autodesk Exchange Apps

Message 3 of 16

fieldguy
Advisor
Advisor

ty! I have never worked with profiles. I added a profile, set it current, and exported it - the trusted folders are in the arg file and correct.  I added the profile to accoreconsole with /p but my dll would still not load from F: drive.

0 Likes
Message 4 of 16

BlackBox_
Advisor
Advisor

You've not posted your code calling Core Console or the Script, so hard to guess.

 

If you're now calling Core Console with the correct Profile, then just be mindful that Trusted Path != SFSP (Support File Search Path)... Adding the folder as Trusted Path does not mean that the file can be found (if full file path is not also provided). 

 

When an app is loaded via Autoloader .bundle, the app's required paths are appended to SFSP on startup. 

 

I just checked some of my own Core Console Scripts that NETLOAD assemblies and they all simply include the assembly's file name, which means that the file resides within a path that can be searched under SFSP:

 

 

NETLOAD "YourAssemblyNameHere.dll"
YourCustomCommandHere

 

 


"How we think determines what we do, and what we do determines what we get."

Sincpac C3D ~ Autodesk Exchange Apps

0 Likes
Message 5 of 16

fieldguy
Advisor
Advisor
Accepted solution

I got this to work by setting "TRUSTEDPATHS" in the core console to the path of my development folder.  Adding the /profile C3D_Metric switch did not work.

The core console remembers the new "TRUSTEDPATHS" value but I could not find where.  I tried to set the TRUSTEDPATHS value in the script but that did not work either.  

Message 6 of 16

FlorisvdG
Advocate
Advocate

Could you please tell us how you set this ""TRUSTEDPATHS" in AcCoreConsole?

0 Likes
Message 7 of 16

fieldguy
Advisor
Advisor

sorry for the late reply.  you can use the command line in accoreconsole the same as acad.

 

SETVAR <enter>

TRUSTEDPATHS <enter>

"the path you want to set"

 

I just looked at this again in C3D 2023 and creating a profile in acad is the way to go. I also discovered the "LEGACYCODESEARCH" variable but have not tested that.

Message 8 of 16

FlorisvdG
Advocate
Advocate

Ah, Thanks. I forgot about my question actually.

I was unable to do it manually, so I figured out a way to do it in the registry using Powershell.
Here's the script in case anybody else wants to use it:

$trustedPathsRegistryValue = "d:\..." 
$autocadKeys = Get-ChildItem "Registry::HKEY_CURRENT_USER\SOFTWARE\Autodesk\AutoCAD" -Recurse | Where-Object { $_.PSIsContainer -eq $true }
foreach ($key in $autocadKeys) {
    if($key.Name.Contains("Profiles") -and $key.Name.EndsWith("Variables"))
    {
        $path = ${key}.Name       
        $path = $path.Replace("HKEY_CURRENT_USER", "HKCU:")

        Write-Host "Setting Registry key: $path"

        Set-ItemProperty -Path $path -Name "TrustedPaths" -Value $trustedPathsRegistryValue
    }        
}

 

 

0 Likes
Message 9 of 16

Ed__Jobe
Mentor
Mentor

I'm having the same problem, but nothing I've tried works. My dll loads into a running session of acad, but not core console.

Here's the scr I'm running.

 

TRUSTEDPATHS "C:\AcadCustom\Support_GS;C:\AcadCustom\Scripts"
NETLOAD "C:\AcadCustom\Support_GS\MeridianDrawingExtraction.dll" 
ExtractDataToCSV

 

Here's a bat I'm using to test it.

 

"C:\Program Files\Autodesk\AutoCAD 2023\AcCoreConsole.exe" /i Drawing2.dwg /s "C:\AcadCustom\Scripts\start.scr" /p C:\AcadCustom\Support_GS\AcCoreConsole.arg

 

 

Ed


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
How to post your code.

EESignature

0 Likes
Message 10 of 16

norman.yuan
Mentor
Mentor

@Ed__Jobe ,

 

Shouldn't the DLL's path used for NETLOAD command in the script (start.scr) use "/" or "\\" to separate folder/file names?

 

Norman Yuan

Drive CAD With Code

EESignature

0 Likes
Message 11 of 16

Ed__Jobe
Mentor
Mentor

Thanks @norman.yuan 

I tried that originally, but it didn't work. I just tried it again and it fails to load. NETLOAD just keeps prompting for a filepath and tries to netload the next command. I'm stumped.

Ed


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
How to post your code.

EESignature

0 Likes
Message 12 of 16

norman.yuan
Mentor
Mentor

OK, I think the second line of your script should be:

 

NETLOAD C:/AcadCustom/Support_GS/MeridianDrawingExtraction.dll 

 

notice: no quote marks wrapping the path, because it is script input. 

Norman Yuan

Drive CAD With Code

EESignature

0 Likes
Message 13 of 16

Ed__Jobe
Mentor
Mentor

No, I tried that before too, but it doesn't matter what path I supply. I commented out the netload line and did (findfile "MeridianDrawingExtraction.dll") and it spit out the full path. I also tried netloading another dll I've been using for years and it won't load either.

 

I also added (getvar "trustedpaths") to the script and the paths are not what the profile has. It seems that the profile is not having any effect.

 

All this is just to try and debug. I wasn't able to get the command line arguments in Debug config to work either.

@norman.yuan @BlackBox_ 

 

I altered my script and verified that the trustedpaths and SFSP is getting set. So it's something to do with permissions still and not file location.

Ed


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
How to post your code.

EESignature

0 Likes
Message 14 of 16

Ed__Jobe
Mentor
Mentor

@norman.yuan 

I ran (setvar "secureload" 0) and it worked, but there must be a way to get it to run when secureload is set to 2.

Ed


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
How to post your code.

EESignature

0 Likes
Message 15 of 16

norman.yuan
Mentor
Mentor

I have used core console often, and always use /p switch to specify a profile to use and and trusted locations to load DLLs from are included in the profile. Never needed to set "secureload" to 0.

 

I do see your startup argument includes the /p switch. So, the questions are:

 

1. does the DLL folder path is in the trusted locations? (I assume it is).

2. which is the profile available for the user account that used to run the core console? In my case, I create the profile in AutoCAD desktop, then I run an EXE app that drives the core console (using Process.Start()), obviously the EXE, and then the core console, started by the EXE, runs with my user account.

 

Norman Yuan

Drive CAD With Code

EESignature

0 Likes
Message 16 of 16

Ed__Jobe
Mentor
Mentor

@norman.yuan wrote:

1. does the DLL folder path is in the trusted locations? (I assume it is). Yes, and SFSP too.

 

2. which is the profile available for the user account that used to run the core console? I've been running the console from a bat file directly in a cmd window. I haven't been too confident that the /p profile settings are being honored. Although checking CPROFILE verified that it was active. I wanted to use a bat file because I want to just drag/drop files onto it for batch processing. I've been successful doing it this way when the script just executed lisp. But this time I want to use .NET instead of lisp.

 

In my case, I create the profile in AutoCAD desktop, then I run an EXE app that drives the core console (using Process.Start()), obviously the EXE, and then the core console, started by the EXE, runs with my user account. I've been running the cmd window with my user account, which does not have admin rights.

 


With SECURELOAD set to 0, I can now run the code in debug. I'm still doing research to see if there's a way to run with SECURELOAD set to 2.

Ed


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
How to post your code.

EESignature

0 Likes