dcsimg
Results 1 to 11 of 11
  1. #1

    Thread Starter
    Junior Member
    Join Date
    Apr 2017
    Posts
    22

    Type 'Microsoft.VisualBasic.PowerPacks.RectangleShape' is not defined

    Hello,

    I installed Visual Basic Power Packs to my Visual Studio 2015 and when I am attempting to use the RectangleShape, I get this error

    Name:  2017-12-20_18-46-16.jpg
Views: 383
Size:  15.3 KB

    Power Packs installed fine, I have all the tools available in the toolbox....

    Just not sure what to do with this... Please point me in the right direction to figure it out please...

    Richard

  2. #2
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    99,128

    Re: Type 'Microsoft.VisualBasic.PowerPacks.RectangleShape' is not defined

    What exactly did you do to generate those error messages? Normally, you would add a RectangleShape to your form from the Toolbox in the designer and that would add the appropriate assembly reference to your project. If you just try to use the type in code without adding the reference then your project won't know that that type exists and the result is error messages telling you the type is not defined.

    Check the References page of the project properties to see if the PowerPack assembly is referenced. If it's not, you can reference it manually there or you can use the designer to have it added for you. The latter may be a good idea if you don't know what assembly to reference. If you add a shape to get the reference, you can always delete that shape immediately after and the reference will remain.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Apr 2017
    Posts
    22

    Re: Type 'Microsoft.VisualBasic.PowerPacks.RectangleShape' is not defined

    All I did was drag a rectangle shape onto the form, I stretched it just to see what it could or couldn't do and then hit run. Nothin else was done.

    Though, when I dragged the rectangle to the form, it was on a User Control Design I was playing with. Could that have been the issue?

    Here are a few images of what I am seeing.

    Richard


    Name:  12-21-2017 6-43-17 AM.jpg
Views: 247
Size:  35.7 KB
    Name:  12-21-2017 6-42-35 AM.jpg
Views: 247
Size:  16.8 KB
    Name:  12-21-2017 6-41-48 AM.jpg
Views: 244
Size:  28.2 KB








    Quote Originally Posted by jmcilhinney View Post
    What exactly did you do to generate those error messages? Normally, you would add a RectangleShape to your form from the Toolbox in the designer and that would add the appropriate assembly reference to your project. If you just try to use the type in code without adding the reference then your project won't know that that type exists and the result is error messages telling you the type is not defined.

    Check the References page of the project properties to see if the PowerPack assembly is referenced. If it's not, you can reference it manually there or you can use the designer to have it added for you. The latter may be a good idea if you don't know what assembly to reference. If you add a shape to get the reference, you can always delete that shape immediately after and the reference will remain.

  4. #4
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    99,128

    Re: Type 'Microsoft.VisualBasic.PowerPacks.RectangleShape' is not defined

    It looks as though it should be working based on that. What happens if you try the same thing with a new project?
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Apr 2017
    Posts
    22

    Re: Type 'Microsoft.VisualBasic.PowerPacks.RectangleShape' is not defined

    Quote Originally Posted by jmcilhinney View Post
    It looks as though it should be working based on that. What happens if you try the same thing with a new project?


    Ok, I am confused......

    I did what you suggested and just created a new project, placed a rectangle on the form and hit run.

    Worked just fine....

    Not making sense.

    Any suggestions?

  6. #6

    Thread Starter
    Junior Member
    Join Date
    Apr 2017
    Posts
    22

    Re: Type 'Microsoft.VisualBasic.PowerPacks.RectangleShape' is not defined

    Here is a zip of that program. Check it out and see what you find.

    Thanks,
    Richard
    Attached Files Attached Files

  7. #7
    Sinecure devotee
    Join Date
    Aug 2013
    Location
    Southern Tier NY
    Posts
    4,497

    Re: Type 'Microsoft.VisualBasic.PowerPacks.RectangleShape' is not defined

    I suspect shape "controls" are lightweight controls meaning they have to be drawn on the container, so the Windows Form and other VB controls are built to support drawing of those shape controls on themselves.

    If you are dropping it on a User Control, then you probably need to have a reference or something within your control so that you will draw those shapes as well.

    But I'm only guessing.

  8. #8

    Thread Starter
    Junior Member
    Join Date
    Apr 2017
    Posts
    22

    Re: Type 'Microsoft.VisualBasic.PowerPacks.RectangleShape' is not defined

    I rebuilt the project with User controls and it works fine with the Rectangle inside it.

    I am not sure what the difference is, one started with out power packs installed and the other was started after it was installed.

    Wonder what the difference is?

    Richard



    Quote Originally Posted by rknox View Post
    Here is a zip of that program. Check it out and see what you find.

    Thanks,
    Richard

  9. #9
    You don't want to know.
    Join Date
    Aug 2010
    Posts
    4,580

    Re: Type 'Microsoft.VisualBasic.PowerPacks.RectangleShape' is not defined

    Quote Originally Posted by passel View Post
    I suspect shape "controls" are lightweight controls meaning they have to be drawn on the container, so the Windows Form and other VB controls are built to support drawing of those shape controls on themselves.

    If you are dropping it on a User Control, then you probably need to have a reference or something within your control so that you will draw those shapes as well.

    But I'm only guessing.
    It's even weirder than that but you're half right.

    When you drop one of these shape "controls", what actually happens is a panel-like transparent control is added to your form and sized to fill the whole space. It has a name like ShapeContainer, it's not really relevant exactly what it is. ShapeContainer knows how to draw each shape. So the shape "control" you dragged is drawn. There's only ever one control, but it has a lot of design-time magic to trick you into believing it's different.

    That sometimes interacts really poorly with other controls, but not often enough I can clearly remember any specific threads with examples. Probably things with z-order, but I bet every now and then the transparency fails too.

    With respect to "What the heck happened here" I think the key phrase is "rebuilt", rknox.

    Building makes a ton of intermediate files. VS tries to "help" you by reusing those files on subsequent builds. When it works, your builds get a lot faster. One way to really screw it up is to dramatically change your machine's environment by doing something like installing the PowerPacks. This puts you in a state where the intermediate files are "wrong" because they reference things that aren't there/are different now, but VS can't tell that's why they're broken.

    Build Clean then Rebuild All usually solves this kind of problem. When I get a bunch of confusing errors, that's my first debugging step!
    This answer is wrong. You should be using TableAdapter and Dictionaries instead.

  10. #10
    Sinecure devotee
    Join Date
    Aug 2013
    Location
    Southern Tier NY
    Posts
    4,497

    Re: Type 'Microsoft.VisualBasic.PowerPacks.RectangleShape' is not defined

    In his case, he had to start a new project and rebuild.
    Trying a clean and rebuild was one of the first things I tried on his project.

    I investigated a bit, comparing the vbproj files between a new working version and the original.
    The original, non-working, version had a few extra things in it that aren't necessary.
    I didn't bother seeing if the probably was the <HintPath> value added to the Reference Node or the compile include node for the powerpacks, but since they weren't in the working version I removed them. I also removed the reference to powerpacks.designer.
    After that, and a build, the original project came up fine.
    Below are the lines I removed from the User_Controls_Demo.vbproj file
    In the <Reference Include="Microsoft.VisualBasic.PowerPacks, .... block
    Code:
         ' <SpecificVersion>False</SpecificVersion>
         ' <HintPath>..\..\..\..\..\..\..\Program Files (x86)\Reference Assemblies\Microsoft\VBPowerPacks\v12.0\Microsoft.VisualBasic.PowerPacks.dll</HintPath>
    and the following two nodes (not sure "node" is the correct terminology).
    [code]
    '<'Reference Include="Microsoft.VisualBasic.PowerPacks.Design, Version=12.0.0.0, Culture%
    Last edited by passel; Dec 21st, 2017 at 09:55 AM.

  11. #11
    Sinecure devotee
    Join Date
    Aug 2013
    Location
    Southern Tier NY
    Posts
    4,497

    Re: Type 'Microsoft.VisualBasic.PowerPacks.RectangleShape' is not defined

    I apparently can't include the contents of the vproj as it messes up the post parser and fails to post.

    But I removed the blocks containing
    "Reference Include="Microsoft.VisualBasic.PowerPacks.Design,"

    and
    "Compile Include="Microsoft\VisualBasic\PowerPacks.vb"
    Last edited by passel; Dec 21st, 2017 at 10:03 AM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width