Visual Studio 2010 Macros vsaenv cannot find one or more components error

by Joe Payne 26. June 2011 08:52

This week has been nothing but hassles after upgrading to Visual Studio 2010 Professional. 

After a few days running VS2010, I was happy with the installation so I decided to uninstall Visual Studio 2008 from my computer.  The uninstall went fine and I even bounced my PC just to be on the safe side.

At first Studio 2010 seemed completely unaffected by the uninstall of VS2008, but boy was I wrong.  As soon as I tried to fire off a recorded macro VS2010 just sits there like it’s going to hang.  Eventually I noticed a background popup box in the taskbar.  I switched to it and saw that VS2010 was complaining “cannot find one or more components…” blah blah blah.

Closing the popup had a 50/50 chance of completely blowing up the VS2010 IDE.  Joy.

I even tried doing a Repair from the installation setup.  No luck.

After researching this morning, I found the cause.  I have copied both it and the solution below.  In my situation, this resolved it perfectly and I didn’t even have to reboot.

2.1.7 On computers on which Visual Studio 2008 or SQL Server 2008 is installed and Visual Studio 2010 has been uninstalled and then reinstalled, using the Visual Studio Macros IDE may cause Visual Studio to crash

Uninstalling Visual Studio 2010 also removes the Visual Studio Macro Tools package. If the computer also has Visual Studio 2008 or SQL Server 2008, then reinstalling Visual Studio 2010 does not reinstall the Visual Studio Macro Tools package. This causes an error when the Macros IDE is started, and Visual Studio crashes if you try to recreate the MyMacros.vsmacros project.

To resolve this issue:

  1. Delete the following file:
    1. On a 64-bit operating system: "%ProgramFiles(x86)%\Microsoft Visual Studio 9.0\Common7\IDE\1033\Microsoft.VSDesignerUI.dll"
    2. On a 32-bit operating system: "%ProgramFiles%\Microsoft Visual Studio 9.0\Common7\IDE\1033\Microsoft.VSDesignerUI.dll
  2. On the Add or Remove programs page, select Uninstall/Change Visual Studio 2010 and then click Next.
  3. Select Add or Remove features.
  4. Clear and then re-select any of the features in the list. This causes the update state to be enabled.
  5. Finish the Setup wizard. Visual Studio Macro Tools should be installed.

Tags:

AbleCommerce 7 Build Web Site with Visual Studio 2010

by Joe Payne 24. June 2011 12:08

Having problems building your AbleCommerce 7 website with VS2010?  So am I.

So far I’ve figured out that even though you have your IIS application pool set to .Net 2.0, you still have to set the Target Framework in VS2010 to .Net 4.0.    Otherwise VS2010 won’t build the AC7 site.

Not sure why, but if you don’t do it that way, VS2010 will complain about ScriptManager and/or UpdatePanel (the AJAX stuff) and your site won’t build.

Sure would be nice to spend time programming instead of fighting VS2010.  Upgrading to Visual Studio 2010 may not have been my best move of the week Sad smile

Tags:

Control an ASP.Net Modal Popup within a Gridview Row

by Joe Payne 22. June 2011 14:47

So today I needed to do something I had done before.  Simple, right?  Just copy/paste the code from another project and <wham> everything works, right?  NOT!

Today’s goal was to make a popup edit window for the contents of a specific grid row.  Each gridview row has it’s own edit button.  I want the user to be able to edit the controls of the gridview row within a nifty popup window.

First we have to add a Panel to our HTML.  This panel will contain everything included in our popup window.  Here’s a good start:

<asp:Panel ID="EditReturnItemDialog" runat="server" Style="display: none; width: 300px" CssClass="modalPopup">
    <asp:Panel ID="EditReturnItemDialogHeader" runat="server" CssClass="modalPopupHeader" EnableViewState="false">
        <asp:Localize ID="EditReturnItemDialogCaption" runat="server" Text="Edit Return Item" EnableViewState="false"></asp:Localize>
    </asp:Panel>
    <br />
    Specify Return Number for this return...
    <br /><br />
    <table>
        <tr valign="middle" style="font-weight:bold">
            <td>Return Number: </td>
            <td><asp:TextBox ID="txt_AuthorizeReturnNumber" runat="server" Width="80px"/></td>
        </tr>
        </table>
    <br /><br />
    <center><asp:Button ID="btn_SaveEditReturnItem" runat="server" Text="Submit" OnClick="btn_SaveEditReturnItem_Click"/>&nbsp;&nbsp;&nbsp;<asp:Button ID="btn_EditReturnItemCancel" runat="server" Text="Cancel" /></center>
</asp:Panel>

Notice the object ID names here.  They are critical and must match exactly with how you specify them in the ModalPopupExtender.  If you get just one wrong, the popup won’t fire and you may not even see an error depending on how your browser is configured.

Also notice at the end of the panel is a save button with an OnClick event, but the Cancel button does not have one.  This is intentional.  Unless you have need to extra functionality within the Cancel operation, you can hook the ‘cancel’ functionality of the MPE directly to the button.  Alternatively you can specify an OnClick event for the Cancel button and specifically issue the MPE.Hide() command.  It’s your choice.

Once your Panel is in place, now it’s time to build the ModalPopupExtender itself.  Here how this one will look:
<ajax:ModalPopupExtender ID="mpe_EditReturnItemPopup" runat="server" TargetControlID="btn_Hidden1"
PopupControlID="EditReturnItemDialog" BackgroundCssClass="modalBackground" CancelControlID="btn_EditReturnItemCancel"
DropShadow="false" PopupDragHandleControlID="EditReturnItemDialogHeader" />

There’s a lot here, but basically it all makes sense.  We give the MPE an ID for itself.  But notice the TargetControlId is set to an object we haven’t added yet.  That object, btn_Hidden1 is the trick.  Normally an MPE requires being hooked into a working button.  That’s what we’re doing here, we’ve just made the button invisible. 

By setting an MPE to a button that isn’t used, it gives you the ability to create an MPE and manually manipulate it elsewhere in the code-behind.  Here’s the code for the hidden button, it’s quite simple:

<asp:Button ID="btn_Hidden1" runat="server" style="display: none"  />

Note how I’ve used a style with display: none instead of the usual Visible=”false”.  Why?  Because a Visible=”false” will not render the control at all on the client side, thus the MPE cannot find it’s button to hook.  The MPE will fail to fire the popup and it’s doubtful you’ll even see an error.  So do not use the Visible=, instead use a style with display: none on your hidden button.

We have one last thing to build on the HTML side:  Our gridview command button.  This button renders for each row in the Gridview control.  It’s responsible for opening the actual popup window when it’s clicked.

Adding the button is easily done.  Simply add the button to a template field in your gridview row like such:

<asp:TemplateField HeaderText="Actions">
    <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
    <ItemTemplate>
        <asp:LinkButton ID="btn_Edit" runat="server" ToolTip="Edit" CommandName="Do_Edit" CommandArgument='<%#string.Format("{0}", Eval("ReturnItemId"))%>'><img src="<%# GetIconUrl("edit.gif") %>" 
        border="0" alt="Edit" /></asp:LinkButton>
    </ItemTemplate>
</asp:TemplateField>

In this particular case, we’re using an icon image to represent the button but you get the point nonetheless.

The key here is we’re using the gridview RowCommand event to handle the popup action.  So the button must have the CommandName and CommandArgument parameters specified.

Finally we’re done with the HTML side.  Now let’s build the code-behind to drive this popup.

For your Gridview control, make sure you’ve specified a function for the RowCommand event like so:

<asp:GridView ID="grd_ReturnItems" runat="server" AutoGenerateColumns="False" DataKeyNames="ReturnItemId"
    CellSpacing="0" CellPadding="4" Width="100%" SkinID="Summary" OnRowCommand="grd_ReturnItems_RowCommand" >

Now build the code-behind to drive the ModalPopupExtender and render the popup.  Here’s the final piece of the puzzle:

Protected Sub grd_ReturnItems_RowCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCommandEventArgs) Handles grd_ReturnItems.RowCommand
 
    ' pull in the ReturnItemID and load up the returnitem class
    Dim _ReturnItemId As Integer = AlwaysConvert.ToInt(e.CommandArgument)
    Dim _ReturnItem As ReturnItem = ReturnItemsDataSource.Load(_ReturnItemId)
    If _ReturnItem.ReturnItemid = 0 Then
        Return
    End If
 
    Select Case e.CommandName
        Case "Do_Edit"
            mpe_EditReturnItemPopup.Show()
    End Select
 
End Sub

See how it’s done?  Simply call the .Show() method of the ModalPopupExtender object.  The browser client handles the rest automatically.

Well if you’ve read this far, then you’ve probably realized by now that I never answered the question of “Why didn’t it work when you copy/paste’d the code from another project?”  I made the mistake of using Visible=”False” on the hidden button instead of using style=”display: none” </thumpsforehead> Smile

Tags: , , , ,

AC7 Articles | Personal | Tech Support

ASP.Net error ScriptManager does not exist in the current context

by Joe Payne 16. June 2011 11:08

I just recently upgraded to Visual Studio 2010.  After trying to build the site for the first time (in VS2010 that is), I got an unusual error message.

For some reason, VS2010 didn’t like this code any more when VS2008 was ok with it:

ScriptManager.RegisterClientScriptBlock(page, typeof(string), "EditHTML", js, true);

Visual Studio 2010 was complaining that ScriptManager does not exist in the current context.  Yet it compiled fine in 2008 Studio.

After a little searching on the net, I found a conversation about having to add a reference to System.Web.Extensions to the project.  Doing this resolved the problem for me.

So technically, VS 2010 was right – it didn’t exist in the current context Smile

Tags:

Month List