Configuring AutoCAD's use of the .NET Framework via acad.exe.config

Thanks to Fernando Malard for suggesting part of this topic in response to an issue he submitted through ADN support.

Windows applications that make use of the .NET Framework can be configured via a ".config" XML file found in their executable's main directory (for more specifics, please see this MSDN article). In AutoCAD's case, this file is called acad.exe.config, and is found in c:\Program Files\AutoCAD 2007 (for instance).

The default contents of this file for AutoCAD 2007 are:

<configuration>

  <startup>

<!--We always use the latest version of the framework installed on the computer. If you

are having problems then explicitly specify .NET 2.0 by uncommenting the following line.

  <supportedRuntime version="v2.0.50727"/>

-->

  </startup>

</configuration>

This indicates a comment in an XML file: <!—this is a comment -->, so you can see that the "supportedRuntime" element is actually commented out. This means that AutoCAD will pick up the latest version of the .NET Framework on startup. There are circumstances where you might need to "downgrade" to a previous version of the .NET Framework. Here are a couple of examples of when this is needed:

  1. You install Visual Studio 2005 on your system but still wish to use Visual Studio 2003 to debug… VS 2005 installs the .NET Framework 2.0 and VS 2003 will not be able to debug applications using that version of the framework (see here for more details).
  2. You install Autodesk Map 3D 2007 side-by-side with Autodesk Map 3D 2006, and suddenly your Feature Data Objects (FDO) data sources no longer function. This is because Autodesk Map 3D 2007 installs the .NET Framework 2.0 but FDO in Map 3D 2006 apparently requires the .NET Framework 1.1 (see here for more details).

I think you see the pattern: a particular app has a requirement on a specific version of the framework (whether this was intended when it was built or not), and installing an application that uses a more recent version of the framework causes the first app to use this new version by default. Changing the "supportedRuntime" element to point to a specific version of the .NET Framework via its "version" attribute allows your first app to function as designed.

To specify the 2.0 version of the .NET Framework, use:

<supportedRuntime version="v2.0.50727"/>

And for the 1.1 version, use:

<supportedRuntime version="v1.1.4322"/>

Interestingly, there's some other cool stuff that can be controlled via acad.exe.config (this is the piece that Fernando felt was worth sharing). As mentioned in this previous entry, there are sometimes issues with .NET modules being located outside of AutoCAD's main executable folder. Aside from the ways already mentioned to avoid the issues, you can also make use of the "codeBase" element and the "probing" element in the acad.exe.config, to point AutoCAD to your various application folders.

Very simply, "codeBase" does the following (from MSDN): Specifies where the common language runtime can find an assembly.

<configuration>

  <startup>

<!--We always use the latest version of the framework installed on the computer. If you

are having problems then explicitly specify .NET 2.0 by uncommenting the following line.

  <supportedRuntime version="v2.0.50727"/>

-->

  </startup>

  <runtime>

    <assemblyBinding>

<!-- one dependentAssembly per unique assembly name -->

      <dependentAssembly>

        <assemblyIdentity name="KeansModule" />

<!-- one codeBase per version -->

        <codeBase version="1.0.0.0" href="file://C:/Program Files/Kean's Company/Kean's Application/KeansModule.dll"/>

      </dependentAssembly>

    </assemblyBinding>

  </runtime>

</configuration>

The "probing" element does something similar (from MSDN): Specifies application base subdirectories for the common language runtime to search when loading assemblies.

It seems, though, that this is not specific to particular assemblies, and so I'm guessing this might cause issues if multiple applications use it. For more information on the use of both "codeBase" and "probing", see this .NET Framework Developer's Guide section on MSDN.

7 responses to “Configuring AutoCAD's use of the .NET Framework via acad.exe.config”

  1. You can use the probing element to specify a sub directory under the main exe folder for the framework to search. Note that you can not specify an arbitrary directory only ones under the exe dir. If you use you registered dev symbol to prefix the folder then you should be able to avoid conflicts with other apps.

    Albert

  2. You can use the probing element to specify a sub directory under the main exe folder for the framework to search. Note that you can not specify an arbitrary directory only ones under the exe dir. If you use you registered dev symbol to prefix the folder then you should be able to avoid conflicts with other apps.

    Albert

  3. Thanks, Albert.

    The concern I had was more around people replacing the singleton "probing" element with their own. As long as the new directories get appended to the "privatePath" attribute, rather than the element being replaced, then that concern is eliminated.

    Kean

  4. I can't open AutoCAD 2006 a message appears:

    "acad.exe - entry point not found"

    The procedure entry point adsw_acadMainWnd could not be located in the dynamic library ACAD.EXE.

    I look everywhere on the net but I couln't find an answer. Can you please help me.
    Thank you very much.

  5. Sorry, I don't know why this is happening. Please post your question - with as much supporting information as possible regarding the circumstances of the error - to the relevant discussion group on discussion.autodesk.com.

  6. I don't see that the line <supportedruntime version="v1.1.4322"/> is commented out. Actually, it appears that it is uncommented, as commenting is ( )

    Am I wrong on this? Please explain how to uncomment this line.

  7. Commenting is in XML, as far as I recall.

    Kean

Leave a Reply to Glenn Cancel reply

Your email address will not be published. Required fields are marked *