The Acumen software design blog provides you with helpful articles about Visual Studio.

Several web sites provide a good overview.

Official Microsoft Visual Studio Docs

Visual Studio Wikipedia

Remotebuild 

remotebuild

Problem:

When installing remote build for Mac to enable Visual Studio Tools for Apache Cordova remote builds, you receive errors as shown in the text below:

MACSERVER01:~ acumenconsulting$ remotebuild test

Remote build server listening on [https] port 3000

Please view/edit server configuration at /Users/acumenconsulting/.taco_home/RemoteBuild.config. You many need to run ‘remotebuild saveconfig’ to generate it. You will have to restart the server if you update the server configurations.

Downloading: cordova@4.3.0

npm WARN engine npm@1.3.4: wanted: {“node”:”>=0.6″,”npm”:”1″} (current: {“node”:”5.1.0″,”npm”:”3.3.12″})

npm WARN install:rimraf@2.2.0 ENOENT: no such file or directory, chmod ‘/Users/acumenconsulting/.taco_home/node_modules/cordova/4.3.0/node_modules/npm/node_modules/rimraf/bin.js’

/Users/acumenconsulting/.taco_home/node_modules/cordova/4.3.0

└── (empty)

npm WARN ENOENT ENOENT: no such file or directory, open ‘/Users/acumenconsulting/.taco_home/node_modules/cordova/4.3.0/package.json’

npm WARN EPACKAGEJSON 4.3.0 No description

npm WARN EPACKAGEJSON 4.3.0 No repository field.

npm WARN EPACKAGEJSON 4.3.0 No README data

npm WARN EPACKAGEJSON 4.3.0 No license field.

npm WARN EBUNDLEOVERRIDE Replacing bundled npm > cmd-shim with new installed version

npm WARN EBUNDLEOVERRIDE Replacing bundled npm > read-installed with new installed version

npm WARN EBUNDLEOVERRIDE Replacing bundled npm > read-package-json with new installed version

npm WARN EBUNDLEOVERRIDE Replacing bundled npm > rimraf with new installed version

npm WARN EBUNDLEOVERRIDE Replacing bundled npm > sha with new installed version

npm ERR! code 1

Error: Downloading cordova@4.3.0 failed.

For more information please refer to http://aka.ms/TacoCliKnownIssues

Failed to load Cordova 4.3.0: TACO0204: Error installing cordova via npm. Exit Code: 1. See output for details.

Error: taco-remote test failed.

Error installing cordova via npm. Exit Code: 1. See output for details.

/usr/local/lib/node_modules/remotebuild/node_modules/q/q.js:126

throw e;

^

null: Error installing cordova via npm. Exit Code: 1. See output for details.

Solution:

This is caused by having Node.js 5.1.0 installed on the Mac. Downgrade to 4.2.2 LTS and the remotebuild test will succeed.

For more information about how Acumen can help with your other Software needs, contact us today!

CordovaAndroid Cordova

Visual studio will build your project for Ripple, but not for the Android Emulator nor for and Android Device.

The error is dependent upon your debug target platform.  If you are using the Emulator, it is trying to build for your Emulator version, if you are using a device, it is building for that device.

In my case, I had to use the Android SDK Manager to install the Android 5.0.1 (API 21) – SDK Platform.

I recommend installing the SDK Platform for all Android target platforms.  You don’t need to install any other components from each version.

For more information on Acumen Software Design, contact us today!

Visual Studio, Entity Framework (EF)

Visual Studio, Entity Framework or EF

C#.net/vb.net asp.net 4.5

EF error 6.0

Visual Studio 2013

Errors:

Object reference not set to an instance of an object.

An exception of type ‘System.NullReferenceException’ occurred

Web page error:

System.NullReferenceException was unhandled by user code

Message=Object reference not set to an instance of an object.

Source=System.Data.Entity

StackTrace:

at System.Data.EntityKey.AddHashValue(Int32 hashCode, Object keyValue)

Solution/Resolution      

The IQueryable query string is valid and returns results, but EF throws and exception anyway when you call ToList().

You can copy the query to SQL Server Management Studio and execute the query successfully.

This can occur if one of your class variables of type “string” has a null value in the query response.

For more information about how Acumen can help with your other Software needs, contact us today!

For additional help, feel free to click on Microsoft’s Support page below:

https://support.microsoft.com/en-us/contactus/

Visual Stuido, or VS

VS

A lot of people suggest editing the pubxml file.  Don’t do it.

A lot of people suggest adding pre-build instructions.  Don’t do it.

I recommend simply including the file in your project and setting the “Copy to Output Directory” property to “Copy always“.

If you need a folder, but don’t want the contents, create a readme.txt file and mark it as “Copy always” to force the directory to copy.

pubxml technique:

http://stackoverflow.com/questions/16790322/adding-extra-files-to-published-mvc-api-project

<Target Name=”CustomCollectFiles”>

<ItemGroup>

<_CustomFiles Include=”$(MSBuildProjectDirectory)\bin\MySpecialFile.txt” />

<FilesForPackagingFromProject Include=”%(_CustomFiles.Identity)”>

<DestinationRelativePath>bin\%(RecursiveDir)%(Filename)%(Extension)</DestinationRelativePath>

</FilesForPackagingFromProject>

</ItemGroup>

</Target>

 

<PropertyGroup>

<CopyAllFilesToSingleFolderForPackageDependsOn>

CustomCollectFiles;

$(CopyAllFilesToSingleFolderForPackageDependsOn);

</CopyAllFilesToSingleFolderForPackageDependsOn>

 

<CopyAllFilesToSingleFolderForMsdeployDependsOn>

CustomCollectFiles;

$(CopyAllFilesToSingleFolderForPackageDependsOn);

</CopyAllFilesToSingleFolderForMsdeployDependsOn>

</PropertyGroup>

custom build technique:

https://msdn.microsoft.com/en-us/library/aa833213(v=vs.100).aspx

For information about how Acumen can help with your IT needs, call us today!

Our software development team recently encountered a problem debugging in Visual Studio. When they start the debug session, the browser session shows a blank page.

IE Blank page

We researched registry settings, Visual Studio settings, web.config, IIS Express settings, malware, IE settings, Chrome settings, and many other factors without success.

If you view the source on the blank page, you will see:

IEBlankpageViewSource

<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.0 Transitional//EN”>
<HTML><HEAD>
<META http-equiv=”Content-Type”
content=”text/html; charset=windows-1252″></HEAD>
<BODY></BODY></HTML>

Specified things we checked:
We verified that debugging was present in web.config:
<compilation debug=”true” strict=”false” explicit=”true” targetFramework=”4.0″/>

We verified our .net framework was installed correctly. It was in place as we expected.

We checked the Visual Studuio Tools->Options->Debugging->Enable Just My Code setting, but no luck.

We looked for web proxy settings such as Fiddler, but they were not present.

We did see an error “A first chance exception of type ‘System.UnauthorizedAccessException’ occurred in mscorlib.dll” but didn’t find any permission issues.

Solution:
In the end we discovered that the problem was caused by an app_offline.htm file. For some reason, the app_offline content does not render properly and the page is presented with blank content. This can occur in a project written in C# or VB.

We suspect that the UnauthorizedAccessException is the reason that the app_offline.htm content did not render, but don’t have any evidence of this.

Visual Studio app_offline_htm

.net MVC

.net mvc

Our .net MVC development team started working with the new Web API 2 controllers released with Visual Studio 2013, and quickly hit some important issues.

Routing and AttributeRouting and using Web API 2 controllers inside an Area in an ASP.NET MVC5 project

Currently, this IS possible. It was not possible with Web API and it seems like it was also not possible in beta, but this can be done with Web API 2 and MVC 5. I used the following configurations:

 // File: ~/Areas/API/APIAreaRegistration.cs
    using System.Web.Http;
    using System.Web.Mvc;

    namespace MySolution.Areas.API {
        public class APIAreaRegistration : AreaRegistration {
            public override string AreaName {
                get {
                    return "API";
                }
            }

            public override void RegisterArea(AreaRegistrationContext context) {
                context.Routes.MapMvcAttributeRoutes();
                context.Routes.MapHttpRoute(
                    name: this.AreaName,
                    routeTemplate: this.AreaName + "/{controller}/{id}",
                    defaults: new { id = RouteParameter.Optional }
                );
            }
        }
    }
 // File: ~/Global.asax.cs
    using System.Linq;
    using System.Web.Http;
    using System.Web.Mvc;
    using System.Web.Routing;
    using Newtonsoft.Json.Serialization;
    using WebMatrix.WebData;
    using AcumenSystem5.Models;
    using System.Threading;
    using System.Web.Optimization;

    namespace MySolution {
        public class MvcApplication : System.Web.HttpApplication {
            protected void Application_Start() {
                AreaRegistration.RegisterAllAreas();
                GlobalConfiguration.Configure(config => { // This HAS to be here. Having it last caused routing to not work.
                    config.MapHttpAttributeRoutes(); // This allows us to use AttributeRouting

                    // This sets JSON as the default return format and removes any circular references
                    var appXmlType = config.Formatters.XmlFormatter.SupportedMediaTypes.FirstOrDefault(t => t.MediaType == "application/xml");
                    config.Formatters.XmlFormatter.SupportedMediaTypes.Remove(appXmlType);
                    var json = GlobalConfiguration.Configuration.Formatters.JsonFormatter;
                    json.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();
                    config.Formatters.JsonFormatter.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore; 
                });
                RouteConfig.RegisterRoutes(RouteTable.Routes);
                BundleConfig.RegisterBundles(BundleTable.Bundles);
                LazyInitializer.EnsureInitialized(ref _initializer, ref _isInitialized, ref _initializerLock);
            }
        }
    }

AttributeRouting and WebAPI Routing not working correctly and returning 404 Errors – .net MVC

After struggling with areas, I hit this issue when adding the Web API 2 controller to the root controllers folder. I discovered that the ordering of configuration mattered. So, like as shown in the Global.asax.cs above, the order needs to be as follows to work correctly:
protected void Application_Start() {

     // Full file code in example above
        AreaRegistration.RegisterAllAreas();
        GlobalConfiguration.Configure(config => { // This HAS to be here. Having it last caused routing to not work.
            config.MapHttpAttributeRoutes(); // This allows us to use AttributeRouting

            config.Routes.MapHttpRoute( // This allows us to use conventional HTTP routing
                    name: "Name",
                    routeTemplate: "api/{controller}/{id}",
                    defaults: new { id = RouteParameter.Optional }
                ); ;

            // This sets JSON as the default return format and removes any circular references
            var appXmlType = config.Formatters.XmlFormatter.SupportedMediaTypes.FirstOrDefault(t => t.MediaType == "application/xml");
            config.Formatters.XmlFormatter.SupportedMediaTypes.Remove(appXmlType);
            var json = GlobalConfiguration.Configuration.Formatters.JsonFormatter;
            json.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();
            config.Formatters.JsonFormatter.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore; 
        });
        RouteConfig.RegisterRoutes(RouteTable.Routes);
        BundleConfig.RegisterBundles(BundleTable.Bundles);
        LazyInitializer.EnsureInitialized(ref _initializer, ref _isInitialized, ref _initializerLock);
    }

Hope this helps!

Check out our ASP.NET MVC to see what we can do for you.

For more information on .net MVC, click on the link below:

https://docs.microsoft.com/en-us/aspnet/mvc/overview/older-versions-1/controllers-and-routing/asp-net-mvc-routing-overview-cs

PHP

Getting Started

This tutorial assumes you have the following applications installed:

PHPTools for Visual Studio

DEVSENSE has developed a fascinating plugin for Visual Studio – PHPTools. This plugin supplies IntelliSense and code completion, function definitions and documentation, as well as the ability to debug PHP – all inside of Visual Studio 2012.

Download the PHP Tools trial for free for 30 days to get started. Once it is installed, restart your Visual Studio project.

Creating and Debugging a Solution in Visual Studio

To create a project, go to FILE -> New Project… and select “PHP Web Project” under Templates -> PHP (image: http://d.pr/i/dQeq). Let’s start with some basic PHP for us to debug:

NewProject

< ?php

class Car {
    private $make;
    private $model;
    private $year;

    public function __construct($make, $model, $year) {
        $this->make = $make;
        $this->model = $model;
        $this->year = $year;
    }
    
    public function render() {
        echo $this->year . " " . $this->make . " " . $this->model;
    }
}

$mustang = new Car("Ford", "Mustang", 2002);
$mustang->render();

?>

Now, let’s set a breakpoint on line 19 and press the “Start” button in Visual Studio to debug and let’s see what happens.

Start

Hitting “Start” will allow Visual Studio to hook into your local HTTP server (Apache) and XDEBUG (an extension installed by XAMPP) to allow you to debug (you will see “?XDEBUG_SESSION_START=1” in the URL).

So now they we’ve started debugging, we quickly hit the breakpoint we set. If you right-click $mustang and click “Add Watch”, you can see the value of $mustang. At line 19, it is has not yet been set.

AddToWatch PHP

Press F10 to go to the next line – you will see in your Watches window that we now have a Car object.

Watch1

While on line 20, press F11 to step into the Car->render() function. We can see that the code ready to echo out the variables. Press “Continue” to finish the script and the result will display in your browser.

BrowserDisplay

You have now successfully debugged a PHP script in your browser! This approach can be taken with many applications – including WordPress

See our CMS Web Development Page for more ways we can help you!

In Visual Studio using Entity Framework 5.0, I receive the following error when working with link tables (many-to-many mapping tables):

Error 3034: Problem in mapping fragments starting at lines:Two entities with possibly different keys are mapped to the same row. Ensure these two mapping fragments map both ends of the AssociationSet to the corresponding columns.

First, it really helps to clearly understand how Entity Framework handles many to many mapping tables.  If a linking table has any fields other than the two linking ID fields, it will cause Entity Framework some trouble, but doesn’t cause this error.  It is also important to specify the foreign keys so Entity Framework knows what the fields are for.  For great detail, see http://weblogs.asp.net/zeeshanhirani/archive/2008/08/21/many-to-many-mappings-in-entity-framework.aspx

After a lot of searching and manipulation of Primary Keys (PK) and Foreign Keys (FK) I found that no logical action fixed the problem.  Theoretically you could edit the EDMX (XML) file and fix something, but it can be thousands of lines long and very cryptic.  You aren’t supposed to have to edit the EDMX file – certainly not for an error like this.  Again, theoretically you should be able to “Update Model from Database”, but it doesn’t resolve this problem.

Entity Framework Resolution

The resolution that seems to work for many and also worked for me was to delete the EDMX file and rebuild it.  The only warning is that you must specify the same names in the Wizard or your class names won’t match.  It isn’t worth the trouble to try to rename the classes.  If you find that you have changed the class names, you can also delete and rebuild your .tt/.cs files and regenerate them too.  At this point, you should have very few class references that are incorrect.

 

For information about how Acumen can help with your Software needs, contact us today!

SQL Server

SQL Server

Problem

When migrating a Visual Studio project with a local SQL Server application database to IIS, you receive the following error:

“Failed to generate a user instance of SQL Server due to failure in retrieving the user’s local application data path. Please make sure the user has a local user profile on the computer. The connection will be closed.”

Resolution

In IIS, Select the appropriate application pool.  Change advanced settings->process model->Load User Profile value to true.

 

For more information about how Acumen can help with your software needs, contact us today!