Kean Walmsley

July 2009

Sun Mon Tue Wed Thu Fri Sat
      1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31  

Twitter Updates

    follow me on Twitter



    « A quick Visual Studio tip - automatically implement interfaces in C# | Main | Blocking AutoCAD commands from .NET »

    October 27, 2006

    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.

    TrackBack

    TrackBack URL for this entry:
    http://www.typepad.com/services/trackback/6a00d83452464869e200d8341f0c9b53ef

    Listed below are links to weblogs that reference Configuring AutoCAD's use of the .NET Framework via acad.exe.config:

    Comments

    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

    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

    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

    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.

    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 http://discussion.autodesk.com.

    I don't see that the line 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.

    Commenting is in XML, as far as I recall.

    Kean

    Verify your Comment

    Previewing your Comment

    This is only a preview. Your comment has not yet been posted.

    Working...
    Your comment could not be posted. Error type:
    Your comment has been posted. Post another comment

    The letters and numbers you entered did not match the image. Please try again.

    As a final step before posting your comment, enter the letters and numbers you see in the image below. This prevents automated programs from posting comments.

    Having trouble reading this image? View an alternate.

    Working...

    Post a comment

    Feed & Share

    Search