Hi @_gile I updated your tutorial for AutoCAD 2023 and Visual Studio 2022. See attached.
For others, this tutorial is based upon one that @_gile created on his website. It is also helpful for learning how to create a new project, since it contains the code for the classes necessary for a plugin to work. After you create your template, you can use it to create your first plugin.
**Updated for 2024.
Solved! Go to Solution.
Solved by ed57gmc. Go to Solution.
Thanks @_gile I looked at it again with fresh eyes and I added some more. I sent you a copy to review.
One thing I noticed while updating this doc, I noticed that with the newer VS, there are 2 templates for classes. The first one in the list (called "Class") is probably the one new users chose, but it only allows you to target .NET 5.0 and above. That's probably why we are getting a lot of questions from users not targeting 4.8. The correct template is "Class (.NET Framework)".
I updated the attachment in the first post.
Hi Ed,
There are quite a few references to years other than the ones Targeted.
You may need to make some snapshots using VS2022 as well to save confusion for someone new to this.
Thanks for the effort, I'm certain it will be appreciated.
Regards,
Kerry
// Called Kerry in my other life.
Everything will work just as you expect it to, unless your expectations are incorrect.
Sometimes the question is more important than the answer.
class keyThumper<T> : Lazy<T>; another Swamper
Hi @kdub_nz I'm not sure I understand. I thought I updated all the references. Do you have an example? The screen shots I used were from VS 2022 Community version.
Hi Ed,
Refer attached.
I think this is all.
Regards,
Kerry
// Called Kerry in my other life.
Everything will work just as you expect it to, unless your expectations are incorrect.
Sometimes the question is more important than the answer.
class keyThumper<T> : Lazy<T>; another Swamper
Thanks @kdub_nz for proofreading it. I sure thought I got everything. I added some more info. While creating the dialogs, I discovered how to edit template tags, so that your project template get filtered in the dialog. I updated the file in the first post.
This exact thing happened to me. Took me hours to figure out the mistake.
The Magical Disappearing Template. If I make changes, or do anything to the zip file, it disappears from the list of available templates in visual studio 2022 when starting a project. Also the one time I managed to start a project with the new template, start.cr still pointed to the old template name rather then the new project name.
Any help would be much appreciated.
Regards
AutoCad Template file attached if your interested to see what I've made.
Hi,
Zipping the directory is not mandatory, Visual Studio also accepts unzipped directories in the ProjectTemplate folder.
You can also start from this template and edit the files to suit your needs.
@Yehoshua18 wrote:
This exact thing happened to me. Took me hours to figure out the mistake.
What exact thing?
Thanks! Good to know.
My template actually works, It just is not classified as anything, and it's dead last in a list of all templates. I set sort order to 0001, and added the language and project type tag to the .vstemplate. Any idea why it's not working? Also start.scr still refuses to automatically update with the new project name.
Thanks for the assistance.
<VSTemplate Version="3.0.0" xmlns="http://schemas.microsoft.com/developer/vstemplate/2005" Type="Project">
<TemplateData>
<Name>Acad2021Plugin</Name>
<Description>Template for AutoCAD 2021</Description>
<RequiredFrameworkVersion>4.8</RequiredFrameworkVersion>
<ProjectType>CSharp</ProjectType>
<ProjectSubType>
</ProjectSubType>
<LanguageTag>CSharp</LanguageTag>
<PlatformTag>Windows</PlatformTag>
<ProjectTypeTag>Library</ProjectTypeTag>
<SortOrder>0001</SortOrder>
<CreateNewFolder>true</CreateNewFolder>
<DefaultName>Acad2021Plugin</DefaultName>
<ProvideDefaultName>true</ProvideDefaultName>
<LocationField>Enabled</LocationField>
<EnableLocationBrowseButton>true</EnableLocationBrowseButton>
<Icon>__TemplateIcon.ico</Icon>
</TemplateData>
<TemplateContent>
<Project TargetFileName="Acad2021Plugin.csproj" File="Acad2021Plugin.csproj" ReplaceParameters="true">
<ProjectItem ReplaceParameters="true" TargetFileName="Commands.cs">Commands.cs</ProjectItem>
<Folder Name="Properties" TargetFolderName="Properties">
<ProjectItem ReplaceParameters="true" TargetFileName="AssemblyInfo.cs">AssemblyInfo.cs</ProjectItem>
</Folder>
<ProjectItem ReplaceParameters="true" TargetFileName="start.scr">start.scr</ProjectItem>
</Project>
</TemplateContent>
</VSTemplate>
Hi. All of a sudden I started getting this error when starting debugging. AutoCad Closes without giving me the opportunity to load the dll. And this error shows up.
The program '[228] acad.exe: Program Trace' has exited with code 0 (0x0).
The program '[228] acad.exe' has exited with code 3221225477 (0xc0000005) 'Access violation'.
Full Debug output is below.
Any ideas on how to fix this?
Thanks!
'acad.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_64\mscorlib\v4.0_4.0.0.0__b77a5c561934e089\mscorlib.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'acad.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'C:\Program Files\Autodesk\AutoCAD 2021\Acdbmgd.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'acad.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System\v4.0_4.0.0.0__b77a5c561934e089\System.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'acad.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Core\v4.0_4.0.0.0__b77a5c561934e089\System.Core.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'acad.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'C:\Program Files\Autodesk\AutoCAD 2021\AdApplicationFrame.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'acad.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'C:\Program Files\Autodesk\AutoCAD 2021\adui24.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'acad.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'C:\Program Files\Autodesk\AutoCAD 2021\AdUiPalettes.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'acad.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\WindowsBase\v4.0_4.0.0.0__31bf3856ad364e35\WindowsBase.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'acad.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_64\PresentationCore\v4.0_4.0.0.0__31bf3856ad364e35\PresentationCore.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'acad.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\PresentationFramework\v4.0_4.0.0.0__31bf3856ad364e35\PresentationFramework.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'acad.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Xaml\v4.0_4.0.0.0__b77a5c561934e089\System.Xaml.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'acad.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Configuration\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Configuration.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'acad.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Xml\v4.0_4.0.0.0__b77a5c561934e089\System.Xml.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'acad.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'C:\Program Files\Autodesk\AutoCAD 2021\AdUIMgd.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'acad.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'C:\Program Files\Autodesk\AutoCAD 2021\AdWindows.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'acad.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\WindowsFormsIntegration\v4.0_4.0.0.0__31bf3856ad364e35\WindowsFormsIntegration.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'acad.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\PresentationFramework.Aero2\v4.0_4.0.0.0__31bf3856ad364e35\PresentationFramework.Aero2.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'acad.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'c:\program files\microsoft visual studio\2022\enterprise\common7\ide\commonextensions\microsoft\xamldiagnostics\Framework\x64\Microsoft.VisualStudio.DesignTools.WpfTap.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'acad.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Runtime.Serialization\v4.0_4.0.0.0__b77a5c561934e089\System.Runtime.Serialization.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'acad.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\SMDiagnostics\v4.0_4.0.0.0__b77a5c561934e089\SMDiagnostics.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'acad.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.ServiceModel.Internals\v4.0_4.0.0.0__31bf3856ad364e35\System.ServiceModel.Internals.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'acad.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'C:\Program Files\Autodesk\AutoCAD 2021\accoremgd.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'acad.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'C:\Program Files\Autodesk\AutoCAD 2021\acmgd.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'acad.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'C:\Program Files\Autodesk\AutoCAD 2021\AcWindows.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'acad.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'C:\Program Files\Autodesk\AutoCAD 2021\en-US\AcWindows.resources.dll'. Module was built without symbols.
'acad.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'C:\Program Files\Autodesk\AutoCAD 2021\AcCui.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'acad.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\PresentationFramework-SystemXml\v4.0_4.0.0.0__b77a5c561934e089\PresentationFramework-SystemXml.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'acad.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\PresentationFramework.Aero\v4.0_4.0.0.0__31bf3856ad364e35\PresentationFramework.Aero.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'acad.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Drawing\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Drawing.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'acad.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\PresentationUI\v4.0_4.0.0.0__31bf3856ad364e35\PresentationUI.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'acad.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Xml.Linq\v4.0_4.0.0.0__b77a5c561934e089\System.Xml.Linq.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'acad.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Windows.Forms\v4.0_4.0.0.0__b77a5c561934e089\System.Windows.Forms.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'acad.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\PresentationFramework-SystemXmlLinq\v4.0_4.0.0.0__b77a5c561934e089\PresentationFramework-SystemXmlLinq.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'acad.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'C:\program files\autodesk\autodesk vehicle tracking 2021\atrc240_arx.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'acad.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'C:\program files\autodesk\autodesk vehicle tracking 2021\atrc240_crx.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'acad.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'C:\Program Files\Autodesk\AutoCAD 2021\C3D\EmbeddedSQLiteLoader.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'acad.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'c:\program files\autodesk\autocad 2021\map\bin\gisplatform\AcMapHiPPIUtility.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'acad.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'c:\program files\autodesk\autocad 2021\map\AcMapResourceManagement.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'acad.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'c:\program files\autodesk\autocad 2021\map\acmaploader.arx'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'acad.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'C:\Program Files\Autodesk\AutoCAD 2021\Map\ConvertText.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'acad.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'C:\Program Files\Autodesk\AutoCAD 2021\Map\MapPublishImp.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'acad.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'C:\Program Files\Autodesk\AutoCAD 2021\Map\bin\GisPlatform\OSGeo.MapGuide.PlatformBase.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'acad.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'C:\Program Files\Autodesk\AutoCAD 2021\Map\bin\GisPlatform\OSGeo.MapGuide.Foundation.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'acad.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'C:\Program Files\Autodesk\AutoCAD 2021\Map\Autodesk.Map.Platform.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'acad.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'C:\Program Files\Autodesk\AutoCAD 2021\Map\Autodesk.MapGuide.Studio.Site.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'acad.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'C:\Program Files\Autodesk\AutoCAD 2021\Map\AcMapFeatureEntityTooltipsManager.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'acad.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'c:\program files\autodesk\autocad 2021\map\AcMapPaletteTheme.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'acad.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'C:\Program Files\Autodesk\AutoCAD 2021\Map\AcMapThemeFactory.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'acad.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'C:\Program Files\Autodesk\AutoCAD 2021\Map\ResourceManagerRdfImp.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'acad.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_64\System.Data\v4.0_4.0.0.0__b77a5c561934e089\System.Data.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'acad.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Numerics\v4.0_4.0.0.0__b77a5c561934e089\System.Numerics.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'acad.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'C:\Program Files\Autodesk\AutoCAD 2021\Map\bin\AcWorkspaceSelector.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
The program '[44740] acad.exe: Program Trace' has exited with code 0 (0x0).
The program '[44740] acad.exe' has exited with code 3221225477 (0xc0000005) 'Access violation'.
What do you mean, "all of a sudden"? What changes did you make since the last time you debugged the solution? If you rebuild the solution, do you get any compile errors? or failures listed in the Output window?
P.S., you should have started a new thread. Your question doesn't have anything to do with this thread. I've asked the moderator to move these posts to a new thread. Keep an eye out.
Good question. I made plenty of changes to the code of the current project. But now, any project I used the template for will not allow AutoCad to stay loaded. It always crashes with that error. Even new projects. I have not made any changes to the Template I created. I was wondering if anyone has seen that error before, and knows how to fix it. I thought it might be something about administer privilege's, but I don't think that's the issue.
What steps are you taking to start debugging? Can you build the project and simply netload it?
Can't find what you're looking for? Ask the community or share your knowledge.