.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

.net migration to 2014 issue

24 REPLIES 24
Reply
Message 1 of 25
jorgemontalvo
938 Views, 24 Replies

.net migration to 2014 issue

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

Tags (1)
24 REPLIES 24
Message 2 of 25
_gile
in reply to: jorgemontalvo

Message 3 of 25
jorgemontalvo
in reply to: _gile

I've done what the guide says:

 

  1. Change your project’s settings to target .NET 4 (if it doesn’t already)
  2. Add an assembly reference to AcCoreMgd.dll
  3. Fix your code to compile properly, which may mean:
    • Changing property and method names, as per the migration guide
    • Adding namespace references (Imports or using statements) to a few new namespaces

but i dont know if I need to change any methods or properties, well I dont understand to what migration guide are they referencing. 

Message 4 of 25


@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 ?

http://docs.autodesk.com/ACD/2014/ENU/index.html?url=files/GUID-C6DCBFE5-25F6-4387-BD02-B021FA06E3FD...

 

I tried with your code and AutoCAD is recognizing the command.

Message 5 of 25

Mr. 

 

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

Message 6 of 25
norman.yuan
in reply to: jorgemontalvo

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

Drive CAD With Code

EESignature

Message 7 of 25

when I use safemode, its in readonly mode, but its value is 0. But I'm still trying and it doesn't recognize the comand.
Message 8 of 25

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
Attachments:
error.jpg ‏314 KB
Message 9 of 25

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

Spoiler
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?

Message 10 of 25

After retriving a code before the changes... I do get an echo message as shown in the attaxhed file.

Message 11 of 25

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:

  • acmgd.dll
  • acdbmgd.dll
  • accoremgd.dll

are pointing to the DLL's exactly for your AutoCAD-version + make sure that these are set to "Copy local = false".

 

Good luck, - alfred -

------------------------------------------------------------------------------------
Alfred NESWADBA
Ingenieur Studio HOLLAUS ... www.hollaus.at ... blog.hollaus.at ... CDay 2024
------------------------------------------------------------------------------------
(not an Autodesk consultant)
Message 12 of 25

Thanks Alfred,

 

I've double checked that and seems ok. 

 

Look at the attachment. 

 

Thanks, 

 

Jorge

 

 

Message 13 of 25

Hi,

 

Can you try to reference the files within your AutoCAD-installation directory? Just to try.

 

- alfred -

------------------------------------------------------------------------------------
Alfred NESWADBA
Ingenieur Studio HOLLAUS ... www.hollaus.at ... blog.hollaus.at ... CDay 2024
------------------------------------------------------------------------------------
(not an Autodesk consultant)
Message 14 of 25

Hi alfred, 

 

Same results,

 

Thanks, 

 

Jorge

Message 15 of 25

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 -

------------------------------------------------------------------------------------
Alfred NESWADBA
Ingenieur Studio HOLLAUS ... www.hollaus.at ... blog.hollaus.at ... CDay 2024
------------------------------------------------------------------------------------
(not an Autodesk consultant)
Message 16 of 25
Mikko
in reply to: Alfred.NESWADBA

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.

Message 17 of 25

Here I send the file requested. 

 

THANKS!!

 

Edited by
Discussion_Admin

Message 18 of 25

IMPORTANT: read your pm!

 

- alfred -

------------------------------------------------------------------------------------
Alfred NESWADBA
Ingenieur Studio HOLLAUS ... www.hollaus.at ... blog.hollaus.at ... CDay 2024
------------------------------------------------------------------------------------
(not an Autodesk consultant)
Message 19 of 25

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]

------------------------------------------------------------------------------------
Alfred NESWADBA
Ingenieur Studio HOLLAUS ... www.hollaus.at ... blog.hollaus.at ... CDay 2024
------------------------------------------------------------------------------------
(not an Autodesk consultant)
Message 20 of 25

HI alfred, thankyou very much for your concern, but i dont get the option to delete the messege 😞 . I will try the code Ajilal.Vijayan says to see if it works, just as a hello message. Where do you see the reference missing? You can see my references in the the error2.png file and I see it there, but I'm not sure If i need to put it somewhere else.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost