Hello,
I've just started a new job and my first task is to migrate an AutoCAD application written in .Net Framework / VB.NET to Autocad 2025 and therefore .Net 8.
This application is quite old and a large portion of the code still uses COM interop classes rather than managed classes. A line like
Dim blocTemps As New AcadBlockReference
works in .Net Framework but no longer works in .Net 8 : BC30517 Overload resolution failed because no 'New' is accessible.
Has anyone ever encountered this problem and could give me some advice on how to solve it?
Thanks in advance
Solved! Go to Solution.
Solved by _gile. Go to Solution.
Yes, I am using the NuGet packages AutoCAd.NET (25.0.1)
and AutoCAD.NET.Interop (2025.25.0.58).
Visual Studio does recognize AutoCAD types.
You should provide more informations. For example, did you start a new project from scratch or upgrade an existing .NET Framework project with the .NET Upgrade Assistant? In the second case, you could read this topic.
I did use the .NET Upgrade Assistant extension to update my projects.
But your comment was interesting. I tried to make a new project in .Net 4.7 and .Net 8.
I used this time NuGet packages to reference the classic AutoCAD libraries and local references for the interop libraries (because AutoCAD.NET.Interop is not an official package).
I read your doc but it didn't give me any clues, but thanks for that.
Sorry, I'm not familiar with VB specifics and I try to avoid using COM interop in .NET plugins, but the code you posted doesn't make sense to me (i.e. creating an AcadBlockReference with New). As far as I know, you can only create a new AcadBlock reference with the InsertBlock method.
I'm a C# guy too and I don't really like VB. but it's historical in the project where VBA code was migrated to VB.NET with interop.
I also wondered if it made sense to do a New. Maybe the New is useless because the reference is overwritten later and just declaring a variable of type AcadBlockReference without the new would be sufficient.
My project is big and I have many errors of this type to correct but I can try...
Thanks for your help.
I would never write code that has a dependence on COM Interop.
I have code that uses the COM API (e.g., AcadDocument), but does so via late-binding using System.Dynamic.
Do you start development by referencing COM.Interop, just to get Intelisense and then switch to late binding when you're done?
@ActivistInvestor wrote:
@ed57gmc wrote:
Do you start development by referencing COM.Interop, just to get Intelisense and then switch to late binding when you're done?
No, I go from memory, and I don't really do use COM very much to begin with, so not having Intellisense isn't really an issue.
Thx. My memory isn't as good. So I have a shortcut to the help file. 🙂 However, if @s3b79 isn't familiar with the COM api and needs Intellisense, they should know that they have the option to set a reference to AutoCAD.COM.Interop and remove it before they compile for Release.
As I said above, I have just taken over the maintenance of a project. This project uses interop classes (in addition to managed classes...). And it's not a choice, it's a fact.
I'm a developer and my knowledge of Autocad and its APi is very limited. @_gile's answer about the fact that the code I posted didn't make sense was very pertinent. I simply deleted the New and the code compiled.
I can't say that the migration to .Net 8 is complete, but this particular point seems to have been resolved.
Thanks to all.
Can't find what you're looking for? Ask the community or share your knowledge.