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

Tool palette: Why is there an end of statement & expression expected

26 REPLIES 26
Reply
Message 1 of 27
WPerciful
1146 Views, 26 Replies

Tool palette: Why is there an end of statement & expression expected

I've been using this code for years, and on the new SDK it now throws an end of statement expected and expression expected error. I'm not sure why this is now an issue whereas it hasn't been or how to resolve it.

 

    <CommandMethod("test")>
Public Sub test()
    Dim ps New Autodesk.AutoCAD.Windows.PaletteSet = Nothing
    ps = As New Autodesk.AutoCAD.Windows.PaletteSet("_")
    Dim dp As dtp = New dtp
    ps.Add("_", dp)
    ps.Visible = True
End Sub 



Wayne Perciful
Design Manager | Occidental Petroleum
Occidental Petroleum
Facebook | Twitter | LinkedIn

Tags (3)
26 REPLIES 26
Message 2 of 27


@WPerciful wrote:

I've been using this code for years, and on the new SDK it now throws an end of statement expected and expression expected error. I'm not sure why this is now an issue whereas it hasn't been or how to resolve it.

 

    <CommandMethod("test")>
Public Sub test()
    Dim ps New Autodesk.AutoCAD.Windows.PaletteSet = Nothing
    ps = As New Autodesk.AutoCAD.Windows.PaletteSet("_")
    Dim dp As dtp = New dtp
    ps.Add("_", dp)
    ps.Visible = True
End Sub 


I don't see how you could've been using that at all, because the New keyword that I've redded above doesn't belong there. It should be 'As' not 'New'.

The As operator that I've redded on the following line also should not be there.

Message 3 of 27

Correct,  I edited the code.  I was attempting to resolve this error: namespace autodesk.autocad.windows.paletteset not defined.  I've got all of the references in but I get that error.



Wayne Perciful
Design Manager | Occidental Petroleum
Occidental Petroleum
Facebook | Twitter | LinkedIn

Message 4 of 27
norman.yuan
in reply to: WPerciful

Did you have reference set to acmgd.dll in your project?

Norman Yuan

Drive CAD With Code

EESignature

Message 5 of 27
WPerciful
in reply to: norman.yuan

I loaded: AcCoreMDG, AcdbMgd and Acmgd.dll



Wayne Perciful
Design Manager | Occidental Petroleum
Occidental Petroleum
Facebook | Twitter | LinkedIn

Message 6 of 27
JamesMaeding
in reply to: WPerciful

check your .net version involved, as if its set too low, I think the references may not be respected.

Just an idea, though you would be getting tons of errors so....


internal protected virtual unsafe Human() : mostlyHarmless
I'm just here for the Shelties

Message 7 of 27
WPerciful
in reply to: JamesMaeding

I'm running Visual Studio 2015 and AutoCAD 2018.  The only code in the app at the moment is the tool palette comandline routine.  I did have to specify CPU which I don't recall having to ever set in the past.



Wayne Perciful
Design Manager | Occidental Petroleum
Occidental Petroleum
Facebook | Twitter | LinkedIn

Message 8 of 27
JamesMaeding
in reply to: WPerciful

I would bet something is up with your references, as I never set CPU.

I think for some progs using old com objects I have set to 32 bit, but that was years ago.

I bet when you run that down, you will have your answer.


internal protected virtual unsafe Human() : mostlyHarmless
I'm just here for the Shelties

Message 9 of 27
WPerciful
in reply to: JamesMaeding

Sir I think that you're on to something.  I will remake the project.  Instead of setting the CPU and other options, I'll post them here.  Perhaps with community's help we'll get to the bottom of it.



Wayne Perciful
Design Manager | Occidental Petroleum
Occidental Petroleum
Facebook | Twitter | LinkedIn

Message 10 of 27


@WPerciful wrote:

Correct,  I edited the code.  I was attempting to resolve this error: namespace autodesk.autocad.windows.paletteset not defined.  I've got all of the references in but I get that error.


 

Autodesk.AutoCAD.Windows.PaletteSet is not a namespace, it is a class that resides in the Autodesk.AutoCAD.Windows namespace.

 

 

You didn't bother to show the Imports declarations, which is most-likely where the error is.

Message 11 of 27

Upgraded to AutoCAD 2018 and VS 2015. 2018 SDK AcCoreMDG, AcdbMgd and Acmgd loaded but throws Autodesk.autocad.windows.paletteset not defined error. Attempted to resolve this by modifying my code which throws end of statement & expression expected because my attempt was a syntax error.

 

So as stated, you are correct.  My effort to resolve my original error failed, but I showed it anyway demonstrate my effort to fix the problem.



Wayne Perciful
Design Manager | Occidental Petroleum
Occidental Petroleum
Facebook | Twitter | LinkedIn

Message 12 of 27

The exact error messages read:

 

BC3002 Autodesk.AutoCAD.Windows.PaletteSet is not defined

 

and the Intelisense says

 

{Namespace} Autodesk.AutoCAD.Windows.PaletteSet is not defined

 

Imports System.Runtime ' Which intelisense says is unnecssary

Imports Autodesk.AutoCAD.Runtime

 

 

 



Wayne Perciful
Design Manager | Occidental Petroleum
Occidental Petroleum
Facebook | Twitter | LinkedIn

Message 13 of 27
JamesMaeding
in reply to: WPerciful

you fixed it though, right?

Activist_Investor called it correctly I thought.


internal protected virtual unsafe Human() : mostlyHarmless
I'm just here for the Shelties

Message 14 of 27
WPerciful
in reply to: JamesMaeding

No it doesn't work.

 

Upgraded to AutoCAD 2018 and VS 2015. 2018 SDK AcCoreMDG, AcdbMgd and Acmgd loaded but throws Autodesk.autocad.windows.paletteset not defined error. Attempted to resolve this by modifying my code which throws end of statement & expression expected. Below is my unmodified code.

 

Imports System.runtime

Imports Autodesk.AutoCAD.Runtime

 

    <CommandMethod("test")>
Public Sub test()
    Dim ps New Autodesk.AutoCAD.Windows.PaletteSet = Nothing
    ps = As Autodesk.AutoCAD.Windows.PaletteSet("_")
    Dim dp As dtp = New dtp ' dtp is user control
    ps.Add("_", dp)
    ps.Visible = True
End Sub

 

Source of base code is from Mike Tuersley's AutoDesk University 2007 course on tool palettes.  Been using it for years.

 



Wayne Perciful
Design Manager | Occidental Petroleum
Occidental Petroleum
Facebook | Twitter | LinkedIn

Message 15 of 27
JamesMaeding
in reply to: WPerciful

did you set copylocal to false on the acad references?

Also, delete the obj folder, that sometimes gets things back in order.


internal protected virtual unsafe Human() : mostlyHarmless
I'm just here for the Shelties

Message 16 of 27
norman.yuan
in reply to: WPerciful


@WPerciful wrote:

No it doesn't work.

 

Upgraded to AutoCAD 2018 and VS 2015. 2018 SDK AcCoreMDG, AcdbMgd and Acmgd loaded but throws Autodesk.autocad.windows.paletteset not defined error. Attempted to resolve this by modifying my code which throws end of statement & expression expected. Below is my unmodified code.

 

Imports System.runtime

Imports Autodesk.AutoCAD.Runtime

 

    <CommandMethod("test")>
Public Sub test()
    Dim ps New Autodesk.AutoCAD.Windows.PaletteSet = Nothing
    ps = As Autodesk.AutoCAD.Windows.PaletteSet("_")
    Dim dp As dtp = New dtp ' dtp is user control
    ps.Add("_", dp)
    ps.Visible = True
End Sub

 

Source of base code is from Mike Tuersley's AutoDesk University 2007 course on tool palettes.  Been using it for years.

 


I strongly doubt that the code as you showed here (in RED!) "being used for year"! It is impossible, because it cannot be compiled as you now experienced.

 

Activist_Investor has already pointed this out, and why did you not try to correct this obvious syntext error and tried to find other reason in vain?

Norman Yuan

Drive CAD With Code

EESignature

Message 17 of 27


@WPerciful wrote:

No it doesn't work.

 

Upgraded to AutoCAD 2018 and VS 2015. 2018 SDK AcCoreMDG, AcdbMgd and Acmgd loaded but throws Autodesk.autocad.windows.paletteset not defined error. Attempted to resolve this by modifying my code which throws end of statement & expression expected. Below is my unmodified code.

 

Imports System.runtime

Imports Autodesk.AutoCAD.Runtime

 

    <CommandMethod("test")>
Public Sub test()
    Dim ps New Autodesk.AutoCAD.Windows.PaletteSet = Nothing
    ps = As Autodesk.AutoCAD.Windows.PaletteSet("_")
    Dim dp As dtp = New dtp ' dtp is user control
    ps.Add("_", dp)
    ps.Visible = True
End Sub

 

Source of base code is from Mike Tuersley's AutoDesk University 2007 course on tool palettes.  Been using it for years.

 

The very simple and obvious syntax error, which remains in the code you posted in the above quote will result in an 'end of statement' compile error because your code does not compile as it is shown.

 

In the above code, you didn't correct the syntax errors that I previously pointed out.

Message 18 of 27


@WPerciful wrote:

The exact error messages read:

 

BC3002 Autodesk.AutoCAD.Windows.PaletteSet is not defined

 

and the Intelisense says

 

{Namespace} Autodesk.AutoCAD.Windows.PaletteSet is not defined

 

Imports System.Runtime ' Which intelisense says is unnecssary

Imports Autodesk.AutoCAD.Runtime

 

 

 


Your Imports do not include the required one:

 

Imports Autodesk.AutoCAD.Windows 

Message 19 of 27

You're not following the posts.  And you're comments are providing no value.



Wayne Perciful
Design Manager | Occidental Petroleum
Occidental Petroleum
Facebook | Twitter | LinkedIn

Message 20 of 27

I've added that code and it doesn't resolve the issue.  The intelisense says Imports statement is unnecessary.



Wayne Perciful
Design Manager | Occidental Petroleum
Occidental Petroleum
Facebook | Twitter | LinkedIn

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