I'm having problems to update this working code with visual basic .net and autocad 2012 to autocad 2014. In this version it doesnt recognize the command when I call it from the command window, but in the visual basic it compiles normally. I've followed the instructions to migrate from 2012 to 2014, but cant get this part of the code to work. PLEASE HELP!!
Imports Autodesk.AutoCAD.Runtime
Imports Autodesk.AutoCAD.ApplicationServices
Public Class Commands
Dim frLog As Login
Dim frInicial As frmInic
'Dim WithEvents Timer As System.Timers.Timer
Dim cont As Integer
' Define command 'Asdkcmd1'
<CommandMethod("carpro")> _
Public Sub carpro()
Dim elTime As Double
Dim elap As Double
elTime = Timer()
elap = Timer()
Dim frPres As Presentacion = New Presentacion
frPres.Show()
While elap < elTime + 2
elap = Timer()
End While
frPres.Close()
frLog = New Login
frLog.Init(Me)
frLog.Show()
'General.PruebaPlot()
'MsgBox("impreso")
'General.WindowPlot()
End Sub
Public Sub Inic(ByVal idUsu As Integer)
frLog.Close()
frInicial = New frmInic(idUsu, Me)
MostrarInic()
End Sub
'Private Sub Timer_Elapsed(ByVal sender As Object, ByVal e As System.Timers.ElapsedEventArgs) Handles Timer.Elapsed
' Debug.Print("Suceso: " & cont)
' cont += 1
'End Sub
Public Sub MostrarInic()
frInicial.Show()
End Sub
End Class
Hi,
Have a look here:
I've done what the guide says:
but i dont know if I need to change any methods or properties, well I dont understand to what migration guide are they referencing.
@jorgemontalvo wrote:I'm having problems to update this working code with visual basic .net and autocad 2012 to autocad 2014. In this version it doesnt recognize the command when I call it from the command window, but in the visual basic it compiles normally.
Does this mean the dll is not loaded becuase of the new security features ?
I tried with your code and AutoCAD is recognizing the command.
Mr. Ajilal.Vijayan
Thank you very much for your reply, I had no idea about the security changes, but just checked and they seem to disabled, (allowing execution). I'm attaching a printscreen of the problem so you see that it doesnt work. I'm running visual basic express 2010, but also tried in ultimate 2010, with the same results. Did you run the code without any changes?
Thanks again.
Jorge Montalvo
Is the code you showed the ALL code in your DLL project?
Do you see any message echoed at command line after "NETLOAD" your DLL?
You also want to place
<Assembly: CommandClass(GetType(Commands))>
between "Imports ..." and your class declaration
Norman Yuan
Hi,
I managed to run the command by using the below code.
I created these 3 forms [Login,frmInic & Presentacion]
And didnt use the highlighted 2 lines while compiling as it was giving error.
Code in here
Imports Autodesk.AutoCAD.Runtime Imports Autodesk.AutoCAD.ApplicationServices Public Class Commands1 Dim frLog As Login Dim frInicial As frmInic 'Dim WithEvents Timer As System.Timers.Timer Dim cont As Integer ' Define command 'Asdkcmd1' <CommandMethod("carpro")> _ Public Sub carpro() Dim elTime As Double Dim elap As Double elTime = Timer() elap = Timer() Dim frPres As Presentacion = New Presentacion frPres.Show() While elap < elTime + 2 elap = Timer() End While frPres.Close() frLog = New Login '---I didnt use this line------>frLog.Init(Me) frLog.Show() 'General.PruebaPlot() 'MsgBox("impreso") 'General.WindowPlot() End Sub Public Sub Inic(ByVal idUsu As Integer) frLog.Close() '---I didnt use this line------>frInicial = New frmInic(idUsu, Me) MostrarInic() End Sub 'Private Sub Timer_Elapsed(ByVal sender As Object, ByVal e As System.Timers.ElapsedEventArgs) Handles Timer.Elapsed ' Debug.Print("Suceso: " & cont) ' cont += 1 'End Sub Public Sub MostrarInic() frInicial.Show() End Sub End Class
As norman.yuan asked
Do you see any message echoed at command line after "NETLOAD" your DLL?
After retriving a code before the changes... I do get an echo message as shown in the attaxhed file.
Hi,
>> I do get an echo message
That gives you the info that your project references a "admgd.dll" that is not compatible with the AutoCAD version you are working with.
So go to references in your VS-project, make sure that the references to:
are pointing to the DLL's exactly for your AutoCAD-version + make sure that these are set to "Copy local = false".
Good luck, - alfred -
Thanks Alfred,
I've double checked that and seems ok.
Look at the attachment.
Thanks,
Jorge
Hi,
Can you try to reference the files within your AutoCAD-installation directory? Just to try.
- alfred -
Hi,
can you load any other .NET-app?
If you create a helloworld-app with just that 3 references and try to load that into AutoCAD, does that work?
If not I guess a repair of AutoCAD might be needed.
The other thing I'm not sure about is the Interop.AutoCAD.dll ==> that is not loaded from any AutoCAD-specific path. That must not be wrong, it's just for me not clear and might be worth to verify that.
Last but not least, you have a warning in your last screenshot with version conflicts (don't know your language, so might be wrong) ... can you try to clean up the references to the minimum needed.
Good luck, - alfred -
just a thought, might want to check what cad version you are targeting, 32bit or 64bit, I think you need to target one or the other not any if thats what your doing.
IMPORTANT: read your pm!
- alfred -
Hi,
besides of the pm ... I will not open a DLL from an unknown source and I don't want to analyse the code now before (missed time for that).
What I see is that you are connecting to an MDB ==> have you installed the 64bit driver for that? (as I think you are running with 64bit AutoCAD?)
At least: have you tried my suggestion with the Hello-World project to make sure it's not AutoCAD that needs to be repaired?
- alfred -
[EDIT] if I see that right: you have not referenced acmgd.dll [/EDIT]