Archive for the ‘Visual Studio’ Category.

Entity Framework Stored Procedure Instructions

This is a how-to on getting Entity Framework (EF) version 5 and 6 to include stored procs and how to consume the resulting entities in code.

  1. In the EF designer choose `Update Model From Database`.
  2. When the page to `Choose Your Database Objects and Settings` comes up which allows one to add new tables/views/stored procs, select the stored proc of interest. Remember the name for the resulting data mapping entity will be the name with the extension `_Result`.2015-06-12_19-10-39
  3. Once the wizard is finished EF will contain the stored proc in the `Model Browser`. The model browser can be displayed by right clicking the EF design surface and selecting `Model Browser`.2015-06-12_19-51-20
  4. Here is an explanation of what has happened.
    (1) You have added the stored proc into the `Stored Procedures __abENT__#8260; Functions` as an item of interest.
    (2) EF has created a function import of the stored proc and placed it into `Function Imports`.
    (3) If EF was able to determine the *result set entity* it will most likely be in the `Complex Types` folder.
  5. If the mapping has gone right you should be able to call the stored proc off of the EF context in code and it will return a list of the complex type `xxx_Result`. If it works you will know it, but there could be problems with the mapping.

Mapping Problems and How to Resolve

  • One can delete at anytime the any object in the folders of 1/2 or 3 shown above and regenerate or create a custom mapping. Don’t be afraid to delete.
  • Sometimes very complex stored procs will not divulge the right mapping of the entity in the result set and the resulting complex type will cause failures. One way around that is to create a faux data return in the stored proc which leaves no ambiguity for Ef.
          1. In the database change the stored proc as follows.  Comment out the meat of the result select and replace it with a one-to-one column stub faux select such as this example: “SELECT 1 AS ResultId, ‘Power1’ AS GroupName, ‘Test’ AS Description”. Note to be clear you will need to match every column and name.
          2. In EF’s Model Browser delete all things associated with the stored proc in folders 1, 2 and 3 above.
          3. Regenerate all by using`Update Model From Database`.
          4. Check the results.
  • If the above steps fail one can always create a function mapping by hand. Be careful not to create duplicates, if so delete all and start over.
        • Open up and find the stored proc you inserted into folder #3 above. Right click and select`Add Function Import…`2015-06-12_20-09-09
        • One can get the column information, change items on the above screen; it is trial and error.
        • You will need to play around with this until you have the right columns for your function import. Be wary of numbered copiesof the complex types which may be created from the mapping.

Remember to reset the stored proc back to its original state instead of the faux stub mentioned.

Share

Visual Studio: How to Resolve TestWindowPackage.Initialize Failure

I began to receive the error message box in Visual Studio after a restart from an install of an unrelated to test Visual Studio plugin (which I have used in the past):

The ‘TestWindowPackage’ package did not load correctly.  … examining the file … AppData\Roaming\Microsoft\VisualStudio\12.0\ActivityLog.xml

Looking at that log showed these errors:

TestWindowPackage.Initialize failed with exception … System.InvalidOperationException:

Loading MEF components failed with the following exception:
The composition produced a single composition error. The root cause is provided below. Review the CompositionException.Errors property for more detailed information.

No exports were found that match the constraint:
    ContractName    Microsoft.VisualStudio.TestWindow.VsHost.PackageContainer
    RequiredTypeIdentity    Microsoft.VisualStudio.TestWindow.VsHost.PackageContainer

 

To resolve the issue I did step 1 and 2 but am showing step 3 in case it helps.

  1. Close all instances of Visual Studio.
  2. Delete all files in `AppData__abENT__#92;Local__abENT__#92;Microsoft__abENT__#92;VisualStudio__abENT__#92;12__abENT__#46;0__abENT__#92;ComponentModelCache` Note that directory is not found in `Roaming` as the activity log file, but in `Local`.
  3. Restart, if that doesn’t work then start over with step 4.
  4. From a Visual Studio Command Line do this operation: `devenv __abENT__#8260;setup __abENT__#8260;ResetSkipPkgs` See (/Setup (devenv.exe)) for more information.
Share

Azure Build: How to Enable A Build Definition in Visual Studio

 

In Visual Studio 2013 one may run into this error  when getting a build running with Windows Azure online TFS.

Team Foundation Error

TF215079: The build definition NexusTFS_CD is disabled. Enable the build definition and try again.

TFS Error

Here are two things to look for/ to do. But both of the items require one to bring up the build definition file (internally named xaml (not the wpf kind)) by (in Visual Studio) right clicking on the build definition which shows the disabled build with an x in the icon in the Team Explorer, Build section:

WhereToClick

  1. There may be build problems other than the build definition is disabled. Select the `Process` section by clicking it and look for any triangle warning signs in the window/tab which opens. If the triangle icon is there, that may mean that something is missing and needs your attention. If in TFS, your Team Project Collection has multiple solutions, the actual solution to build may not be set. Set it in the `Projects` section.
    Yellow Warning
  2. To enable the build definition go to the `General` settings and and change the `Queue Processing`  from `Disabled` to `Enabled`.

Enable

If everything is a go, the icon should change after you `save` the xaml file. Queue a new build and run.

Success

Share

Azure: Failed to Create Web Site in Visual Studio Using Azure

If you have a valid azure account but receive this message in Visual Studio 2013 (or 2012 with the Azure toolkit installed) while trying to create a website

This subscription is not registered to use the following resources: Website. The remote server returned an unexpected response: (400) Bad Request.

Subscription

Here are the steps to fix and or pinpoint the issue.

  1. Log into to manage the account Azure Portal (Opens in new window). Is this account the same one that is tied to Visual Studio?
  2. Find the `WebSites` section along the left hand side.
  3. Create a new website.

If you are able to do those steps, you have eliminated the sign on issue (wrong account) and the general ability to create websites in Azure.

  1. Try to create a website again in Visual Studio using the account specified above used to log into Windows Azure Portal.

If it still fails at this point, trying installing the latest Azure Toolkit (2.2 of this writing) into Visual Studio. Tell me what you have run into…I would like to hear.

Share

Visual Studio TFS: TF10175 During Add Solution To Source Control in Visual Studio How To Fix

If one is attempting to add a project in Visual Studio 2013, 2012 or 2010 and one get this message:

TF10175: The team project folder $/{Project Name Being Added} does not exist. Contact your Team Foundation Server administrator and ask that it be created.

This discusses how to create a Team Project in TFS and then add the solution into source control.

Steps To Create a Team Project in TFS

  1. Verify you are actually can connect to a top level Team Project Server. I use the term top level because it is the TFS server which holds your sub Team Projects. In Visual Studio open up the Team Explorer window and select the Connect (it’s the electrical plug icon) and then proceed to select a top level server / Team Project to connect to. If you can connect proceed to the next step, if you cannot connect, talk to the person in charge of TFS and either have her/him grant you access to do step 2 or have them do step 2 and give you access so you then add it to Source Control. Once the team project is added *by them* then you may have to do #1 again (if they add it) but then specifically connect to the team project before skipping to step 3.
  2. Create a Team Project on the server before you save to it. If you have privileges you should be able to go to File->New->Team Project and put the name of the project (or possibly solution name) into the “What is the name of the team project?"

    If this dialog below doesn’t come up or there is a failure, do the advice in step 1 about contacting an admin to do step 2.

    Click to enlarge:
    TFSAdd

  3. Once that is created, you can then add the solution to source control.
Share

Visual Studio Fix: Intellisense Not Popping Up or Not Working

(Update 4/27/2015 Added Asp.net intellisense failure)

I was running the latest version of Visual Studio 2013 and ran into the intellisense not automatically popping up when I would type a period. Now I could hit CTRL-J (list members) and it would pop up the list which showed me that it worked and was not dead per se, but I still did not have it automatically popup after typing a period. I was also running Visual Studio 2012 on the same box and it did not have the same problem; intellisense popped the list up on the period. I thought, “This ends here” and researched it. Here is what made it auto pop for me:

  1. In quick launch type “Statement Completion” and choose the first one  “Text Editor -> All Languages -> General” to be taken to the options page for all languages.
  2. On the general options page in the “Statement Completion” section override whatever is in the boxes “Auto list members” and “Parameter Information” and makes those checked. Such as shown here:

Statement Completion

 

That brought back the auto popup for me in VS2013 and should for you as well.  This fix should work with any version of Visual Studio 2008, 2010, 2012 and 2013.

Still having problems? Then see Using Intellisense on MSDN for other troubleshooting suggestions.


ASP.Net

It has been reported that ASP.Net users are experiencing a different kind of intellisense failure. If it is web related intellisense look into installing Visual Studio Web tools.  See

Announcing release of ASP.NET and Web Tools 2013.1 for Visual Studio 2012

Share

Fear and Loathing in Visual Studio 2012 at 256 Colors

While working with the Visual Studio 2012 RC I experienced the downside to the new color scheme. When I Citrix-ed into my workstation I adjusted the colors to the 256 color set for better performance over the wire. That was not good.

Now I normally work with the dark color theme and discovered that the appropriately shaded colors simply ran together to the point where text editor window became almost as one the other windows.

Ok, a picture is worth a thousand bug reports, ahem issue reports, so let me show you.

Dark Theme

256 Colors Full Color
256 colors dark True Colors Dark

Light Theme

I decided to switch to the light theme, not that my specific editor colors which work on the dark, do not play well in the light and that has nothing to do with this situation, but notice how in 256 colors the golden rod color becomes prominent in the windows.

256 Colors Full Colors
256 colors Light True Colors Light

VS2010

How did VS 2010 look in 256 Colors? Just fine thank you!

Ahh nothing ages well like a good editor; Chateau De Studio 2010!

256 VS 2010

Summary

Long story short don’t use the non true color setting when remoting in to use Visual Studio 2012!

Share

IIS & Visual Studio 2010: Publishing Gotchas using Web Deploy

On my current project I am in charge of getting a fresh install of Server 2008 R2 with IIS 7.5 running to support a Silverlight web site and its accompanying  WCF service. Here are the some of the error messages and tips and tricks I did to get Visual Studio 2010 Web Deploy to work.

IIS 7.5 Failure Possibilities

Web deployment task failed.(Remote agent (URL http://… //MSDEPLOYAGENTSERVICE) could not be contacted.  Make sure the remote agent service is installed and started on the target computer.)

Remote agent (URL http://… //MSDEPLOYAGENTSERVICE) could not be contacted.  Make sure the remote agent service is installed and started on the target computer.

An unsupported response was received. The response header ‘MSDeploy.Response’ was ” but ‘v1’ was expected.
The remote server returned an error: (503) Server Unavailable.

These errors can come up and for the most part can be fixed on the Server which is running IIS.

  1. Web Deploy package is not installed on the IIS server in question. To install find the “Web Deploy” or “Web Deploy 2.0” from the top level IIS.Net\Download (for downloading all extensions) or directly on the Web Deploy 2.0 page.  Alternately if the Platform installer addin is installed one can find it through the IIS Server Manager where one can also install it and other goodies. (The platform installer as shown below can be found in the Server list or and individual website list of icons in the management section.)
    WebPlatform
  2. Even if Web Deploy package is installed, the service is not running automatically. Follow these steps to find the correct service and get it running.
    1. Run services.msc from the start bar or command line.
    2. Search for the service named Web Deployment Agent Service. Once found verify it is running and also starts up automatically after a reboot.
      WebDeploymentAgentService
  3. Also your account may not have permissions to publish to the web site in question. In IIS Management Studio, find the website in question and make sure your (or other’s) credentials are found in the IIS Manager Permission list.
    Permissions

Fear and Loathing in Visual Studio During Publish

Here are some of the errors one can get when trying to publish

Web deployment task failed.(Could not complete the request to remote agent URL ‘https://{your server name}:8172/msdeploy.axd?site=Default Web Site’.)

Could not complete the request to remote agent URL ‘https://{your server name}:8172/msdeploy.axd?site=Default Web Site’.
The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel.
The remote certificate is invalid according to the validation procedure.

If you get one of the above, it is suggesting that it cannot find your server. To fix this situation, specify the server name with HTTP:// behind it. For example if (on your intranet) you remote to your server named ValHalla Visual Studio expects you to have this in the server line to look like this:
Service URL

No need to have /MsDeploy.axd!

Wait There is More

If you receive any of these errors:

Invalid Service Url

Web deployment task failed. An error occurred when the request was processed on the remote computer.)

An error occurred when the request was processed on the remote computer.
Site ‘OneSource’ does not exist.

Check the website name. Note IIS is setup with at default web site named “Default Web Site”. If that is the case then literally specify “Default Web Site” in the list. Otherwise find the name of the target website and the application/service which has been setup in IIS and make sure one is publishing to that site/name combination. The following example is publishing the OneSource site to a “Default Web Site” in IIS.

Default

I hope this helps (HTH) to any whomever may come after. Smile

Share