Showing posts with label .Net. Show all posts
Showing posts with label .Net. Show all posts

7/20/2019

The controller for path '/' was not found or does not implement IController #VisualStudio #MVC



The controller for path '/' was not found or does not implement IController


Some error messages are no help at all!


When running in Debug mode Visual Studio reports:

An exception of type 'System.Web.HttpException' occurred in System.Web.dll but was not handled in user code.
Additional information: Execution of the child request failed. Please examine the InnerException for more information.

The inner exception:

{System.Web.HttpException (0x80004005): The controller for path '/' was not found or does not implement IController.
   at System.Web.Mvc.DefaultControllerFactory.GetControllerInstance


A "forest and trees" problem...


A web search returns many possibilities for the error, but none that applied to my project. It turns out I had one of those "forest and trees" problems! I had typed Html.Action instead of Html.ActionLink in a Layouts page. In effect I was asking the layouts view to load a view that used the layouts view that then loaded the layouts view that loaded the view that used the layouts view… Yup, an endless loop.


The error message was not of much help and sent me on a wild goose chase. Once I realized what was going on I made one small edit and was back in business.



.

10/22/2016

Forest and Trees Problem: "A network-related or instance-specific error occurred while establishing a connection to SQL Server"

 

A "Can't see the tree for the forest" problem.


image_thumb[11]
There's an old phrase, "Can't see the forest for the trees", that in reverse, "Can't see the tree for the forest", applies to a recent "demo fail" of mine.

During a break in a C# class I was delivering last week I typed up a little demo for accessing SQL Server, and got an error. A quick read of the error said that it couldn't find the server, and it hinted at a protocol error.  

Additional information: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)

    image_thumb[12]

 

Seeing the big "Named Pipes" tree standing there… I Binged and Googled and found all kinds of stuff… that did not help.

While the answer to the problem was clearly stated in the message above, "Verify the instance name is correct", I didn't see it as I was looking at all of the other "trees" in that little code forest. The "tree" that I needed to deal with in this case was a C# beginner error of putting a backslash in a string. (I copy and pasted it without looking at it!) The back slash is an escape character to flag the next character as a special code. In this case "\v" is the code for a Vertical Tab. So, I had created a connection string looking for a server named "(localdb)VerticalTab11.0".

image

What made this little error a bit painful was that in this class I had mentioned escape characters in C#, and how to deal with them, at least four times! Oh well…

To solve the problem, escape the escape character ("(localdb)\\v11.0") or mark the entire string as a literal string with the At sign ("con.ConnectionString = @"Data Source=(localdb)\v11.0 …").

   image

For a list of the C# escape characters see this MSDN article:
   https://msdn.microsoft.com/en-us/library/h21280bw.aspx

.

1/07/2015

Still exam procrastinating? Second Shot is back!

 

Time for New Year's resolutions? Or just finish some of last years…

Take any Microsoft Certified Professional (MCP) exam between January 5, 2015, and May 31, 2015. If you don't pass, get a free retake!

All of the Microsoft Certified Solutions Associate (MCSA), Microsoft Certified Solutions Expert (MCSE), Microsoft Certified Solutions Developer (MCSD), and Microsoft Specialist certification exams are eligible. Microsoft Technology Associate (MTA) exams and Microsoft Office Specialist (MOS) exams do not qualify for this promotion.

Details here: https://www.microsoft.com/learning/en-us/second-shot.aspx

 

.

12/07/2014

Just how much is PI in .Net?

 

<Silly blog article>

 

The .Net Framework includes a math library that includes a constant for PI. Just how much is PI?

The MSDN article says:

   image

 

The Visual Studio debugger says:

   image

The Visual Studio Autos and Locals windows say:

   image

And when written from Console.WriteLine:

   image

Or does it?  Reformatted with "R" WriteLine matches the value reported from the debugger.

   image

and for the final test:

   image

 

So who is right? According to Wikipedia the first 50 digits are 3.14159265358979323846264338327950288419716939937510. Based on that number the MSDN documentation describes a more accurate number than returned by Math.PI.

 

From the .Net double documentation: here and here

  • Double-precision numbers store an approximation of a real number.
  • Holds signed IEEE 64-bit (8-byte) double-precision floating-point numbers
  • A Double value has up to 15 decimal digits of precision, although a maximum of 17 digits is maintained internally
  • When you work with floating-point numbers, remember that they do not always have a precise representation in memory.
  • The documentation's examples only have 18 digits, so PI as a double should be apx 3.14159265358979324

 

In the end…

3.14159265358979323846264338327950288419716939937510  Wikipedia
3.14159265358979323846   MSDN documentation for Math.PI
3.14159265358979324        What I would guess based on the documentation for doubles
3.1415926535897931          Returned in Visual Studio debugging tools
3.1415926535897931          Returned by the ToString() conversion through WriteLine formatted with "R"
3.14159265358979             Returned by the ToString() conversion through WriteLine

and just for fun… JavaScript says:
3.141592653589793

 

So…  for the important question… is the value of PI in the documentation for Math.PI wrong?  Smile

   image

 

</Silly blog article>

Now I have to get back to some real work!

.

11/13/2014

.NET 2015–Open Source? Mac? Linux?

 

Got to take a look at this… (nuff said)

Announcing .NET 2015 - .NET as Open Source, .NET on Mac and Linux, and Visual Studio Community

 

Visual Studio Community edition. Free!   ("This is not Express. This is basically Pro.")

http://www.visualstudio.com/en-us/downloads/download-visual-studio-vs#DownloadFamilies_2

"This edition of Visual Studio is available at no cost for non-enterprise application development."

.

Interesting stuff coming!

 

.

9/21/2014

Developer Apprentice Program in .NET

 

Know someone who is unemployed who would make a great programmer?

 

MAX Technical Training is doing something quite interesting!  Again!

image

Dislocated workers who live in Hamilton, Butler, Warren and Clermont counties and are not working may be eligible to take Developer Apprentice training in .NET programming. Good candidates include those with a background in IT who want to update their programming skills or those who enjoy math, problem solving and/or puzzles. Musicians and those who enjoy learning foreign languages tend to make good programmers.

The Hamilton Co. session is now going to happen on September 23.  Warren Co. is September 24, and the program is open to Clermont and Butler Co. folks as well. 

When: September 23, 2014 at 10 am
Where: OhioMeansJobs Hamilton County, 1916 Central Parkway, Cincinnati  45214

When: September 24, 2014 from 9 am – 10 am
Where: OhioMeansJobs Warren County, 300 East Silver St., Lebanon, OH  45036

"Interested in becoming a Developer or know someone who is?"

"Whether you are an employer looking hire a .NET programmer or a Job Seeker looking to build a new career - this is the program to meet both your needs."

"This intense 9 week "boot camp" immerses you in 42 intense full-days of training. To be accepted, you must pass two aptitude tests and a screening interview with the program director." 

"This will be MAX's fourth program. All of our past apprentices who have completed the program are successfully employed in developer related positions with Great American Insurance, Paycor, Western and Southern, or Assurex."

For more information: http://www.maxtrain.com/DynamicPage.aspx?DynamicContentID=166

 

.

9/12/2014

Developer Apprentice Program in .NET

 

MAX Technical Training is doing something quite interesting!  Again!

 

"Interested in becoming a Developer or know someone who is?"

"Whether you are an employer looking hire a .NET programmer or a Job Seeker looking to build a new career - this is the program to meet both your needs."

"This intense 9 week "boot camp" immerses you in 42 intense full-days of training. To be accepted, you must pass two aptitude tests and a screening interview with the program director." 

"This will be MAX's fourth program. All of our past apprentices who have completed the program are successfully employed in developer related positions with Great American Insurance, Paycor, Western and Southern, or Assurex."

 

IMPORTANT DATES:

September 17: If you are currently unemployed and live in Hamilton County please attend our Recruitment Fair on September 17 at 9 am.

September 24: For Butler, Warren and Clermont County unemployed residents, please attend our Recruitment Fair on September 24 at 9 am.

For more information: http://www.maxtrain.com/DynamicPage.aspx?DynamicContentID=166

12/29/2013

Is VB.Net dead?

 

Just a random thought at the start of a new year… Is VB.Net dead? Deprecated? Just not interesting to Microsoft Learning?

It seems the newer 204** series Microsoft MOC classes only cover C# (and JS / HTML5). I've also been reading that C# is the only language option in most of the newer certification exams.

On the other hand, it looks like Visual Studio is still treating VB as an equal to C#. There are no new VB and C# language features in VS 2013, but VB is still there. The VB team blog says "We are actively working on the next versions of Visual Basic and C#" (*).

What about VBScript? As of Internet Explorer 11, VBScript is considered deprecated. (MSDN article)

This will be entertaining to watch as many of my web and SharePoint class attendees are still working in VB shops!

Mike

5/11/2011

Get Certified Now! (Exams are going to cost more soon…)

 

The primary Microsoft certification exams have cost $125 for a long time now. Starting July 1st they are going up to $150. You can lock in the current pricing for a while, get discounts from your favoriate MCT (10%) or take an exam or two at a 25% discount while you are at TechEd (details) next week! You can also get your exams as part of a certification bootcamp. (here’s two I’m leading: SharePoint Admin and SharePoint Dev)

See here for details: http://borntolearn.mslearn.net/btl/b/weblog/archive/2011/04/22/so-about-that-price-increase.aspx

 

.

9/28/2010

SharePoint and ASP.NET Vulnerability – Security Update Available

 

Note that this is not just limited to SharePoint. It impacts anything running ASP.NET except for 1.1 SP3.

 

UPDATE!

Out of Band Release to Address Microsoft Security Advisory 2416728

http://blogs.msdn.com/b/sharepoint/archive/2010/09/28/out-of-band-release-to-address-microsoft-security-advisory-2416728.aspx

 

This security update is rated Important for all supported editions of ASP.NET except Microsoft .NET Framework 1.0 Service Pack 3.

See here for versions and details: http://www.microsoft.com/technet/security/bulletin/MS10-070.mspx

 

 

SharePoint developers and server administrators need to follow up on this Microsoft Security Advisory.

Read this ASAP!

http://weblogs.asp.net/scottgu/archive/2010/09/18/important-asp-net-security-vulnerability.aspx

and this:

http://blogs.msdn.com/b/sharepoint/archive/2010/09/21/security-advisory-2416728-vulnerability-in-asp-net-and-sharepoint.aspx

 

“This vulnerability affects Microsoft SharePoint 2010 and Microsoft SharePoint Foundation 2010.  The vulnerability is in ASP.NET. We recommend that all SharePoint 2010 customers apply the workaround as soon as possible”

.

9/20/2010

SharePoint and ASP.NET Vulnerability

 

UPDATE!

Out of Band Release to Address Microsoft Security Advisory 2416728

http://blogs.msdn.com/b/sharepoint/archive/2010/09/28/out-of-band-release-to-address-microsoft-security-advisory-2416728.aspx

 

SharePoint developers and server administrators need to follow up on this Microsoft Security Advisory.

Read this ASAP!

http://weblogs.asp.net/scottgu/archive/2010/09/18/important-asp-net-security-vulnerability.aspx

and this:

http://blogs.msdn.com/b/sharepoint/archive/2010/09/21/security-advisory-2416728-vulnerability-in-asp-net-and-sharepoint.aspx

 

“This vulnerability affects Microsoft SharePoint 2010 and Microsoft SharePoint Foundation 2010.  The vulnerability is in ASP.NET. We recommend that all SharePoint 2010 customers apply the workaround as soon as possible”

.

8/02/2010

Are you an unemployed developer? (Project Phoenix)

 

For complete details: http://sqlblog.com/blogs/arnie_rowland/archive/2010/07/30/like-a-phoenix-rising-from-the-ashes.aspx

 

 

Project Phoenix is inviting unemployed or underemployed developers to propose a software project for a non-profit agency, school, or church. The idea is that we will provide a package of the latest software, tools, and training resources to help you improve your skills, get up to date with current technologies, gain practical experience, potentially earn a recommendation for your efforts, and in general, enjoy the feeling of accomplishing something useful for others. We are not giving out a 'free lunch', just supporting your efforts to personally gain from your own 'sweat equity'.

Project Criteria:

  • Client is a USA IRS 503(c)3 non-profit, school, or church, OR a Canadian CRA registered charity,
  • Solves a problem or satisfies a need for the client,
  • Client desires the project and is supportive,
  • Uses any combination of .NET 4.0, Windows Server 2008, SQL Server 2008, or Windows Phone 7,
  • May be a new software solution, or an upgrade to an existing software solution,
  • Additional consideration given projects that will be posted on Codeplex with a GPL license.

All 24 selected developers will receive the following award benefits:

Award timelines:

Every two weeks for the remainder of 2010, two (2) additional developers and projects will be selected.

For complete details: http://sqlblog.com/blogs/arnie_rowland/archive/2010/07/30/like-a-phoenix-rising-from-the-ashes.aspx

7/23/2010

Worst license dialog box?

 

Below is the license screen for the .NET Framework 4 Setup. Big, almost empty dialog box, and they only display three and a half lines of the license agreement at a time…  Maybe they added the print and save buttons so you could actually read it.

 

image

 

.

6/11/2010

Planning WAY Ahead… Tech-Ed 2011!

Tech-Ed 2010 is over today… and I missed out this year  :-(

But,

Tech-Ed 2011 has been scheduled!

May 16-19 2011  in  Atlanta

 

Sign up for EARLY discounts by June 30th, 2010

http://northamerica.msteched.com/registration

 

Home page: http://northamerica.msteched.com

 

See you there!

 

.

2/11/2010

SharePoint: It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level

 

“It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level. This error can be caused by a virtual directory not being configured as an application in IIS.”

 

If you are working on a SharePoint application page project then this error is most likely because you have a web.config file in your project.

So:

  • Don’t deploy the web.config to the LAYOUTS folder
  • Or if you need the web.config for any reason (testing, etc) then delete the authentication section:
        <authentication mode="Windows"/>

 

.

1/06/2010

Enumerate an enumeration!

 

A quick way to find all of the values of an enumeration (that Microsoft may have not completely documented).

System.Enum.GetNames returns an array of strings with the names

System.Enum.Parse looks up the numeric value using the string name

 

This example lists the value of a SharePoint enumeration named SpBasePermissions:

 

C# example:

//show name, decimal and hex
foreach (string enumName in Enum.GetNames(typeof(SPBasePermissions)))
{
    Console.WriteLine(String.Format("Item: {0,-25} Value: {1,20} {1,20:X}",
        enumName, (ulong)Enum.Parse(typeof(SPBasePermissions), enumName)));
}

 

VB.Net example:

For Each enumName As String In [Enum].GetNames(GetType(SPBasePermissions))
    Console.WriteLine(String.Format("Item: {0,-23} Value: {1,20:D} {1,20:X}", _
        enumName, [Enum].Parse(GetType(SPBasePermissions), enumName)))
Next

 

Result:

image

11/03/2009

Exam Discounts

This is a note for people who have attended my classes. (Everyone else go see their own MCT!)

If you are thinking about Microsoft certification, check with me before signing up for an exam. I can usually get you a discount on both the exam and on practice exams.

Currently:

  • 10% off of the exam
  • 40% on any MeasureUp 60 Day Online Practice Test

Not all exams qualify, but most MCP exams do. MeasureUp does not have a practice test of every Microsoft exam.

If you would like a discount voucher, email me at the email address I gave you during class or just call MAX Technical Training.

 

Know any college or tech school students? They can 55% off of exams here:
http://www.prometric.com/microsoft/student

.

5/15/2009

Silverlight: A few notes on HTML / JavaScript access from Silverlight

 

You can call into a Silverlight control from JavaScript in the HTML page and access Silverlight managed code properties and methods. The process is relatively straight forward really lets you use a Silverlight object as a true control, and not just a fancy animated advertisement (Sorry Flash designers…)

I will follow shortly with notes on the other half of the picture, accessing HTML objects and JavaScript functions from Silverlight code.

 

 

Accessing data / method in Silverlight from JavaScript

Step 1:  Add a reference

Add a reference to System.Windows.Browser, and add a using or Imports to your code file.

        using System.Windows.Browser;

 

Step2: Mark the item or class to be scriptable

The item can be either a property or a method. The attribute is [ScriptableMember] (<ScriptableMember> in VB.Net). Some examples show [ScriptableMemberAttribute], but the short form is preferred.

A sample property:

        private int x=9;

        [ScriptableMember]
        public int MyProperty { get { return x; } set { x = value; } }

 

The entire class can be marked as Scriptable using [ScriptableType], but note that all public members are then available for access from JavaScript.

See notes at the end of this article for more info on the use of the attributes.

 

Example:

or the entire class (warning: all publics are exposed)
[ScriptableType]
public class Calculator2
{
    public int Add(int a, int b)
       { return a + b; }

    public int Subtract(int a, int b)
    { return a – b; }
}

 

Step 3: Register the class as scriptable

Register the class as scriptable either in the app.xaml.cs, but more likely in yourpage.xaml.cs file.

Example if registered from Page.xaml

        private void UserControl_Loaded(object sender, RoutedEventArgs e)
        {
            HtmlPage.RegisterScriptableObject("Page", this);

        }

Example to register another class:

         private void UserControl_Loaded(object sender, RoutedEventArgs e)
        {

            HtmlPage.RegisterScriptableObject("MyPage",  new Class1());

        }

 

Step 4: Make the call from the HTML page:

This example makes the call from a button, but could also be done from the <BODY> onload event or the Siverlight control’s load event.

    <script>
    function GetSomeData() {
        sl = document.getElementById("Xaml1");
        alert(sl.Content.Page.MyProperty);
     }
    </script>
    <button onclick="GetSomeData()" >Get Data</button>

or as a single line:
        <button onclick="sl = document.getElementById('Xaml1');alert(sl.Content.Page.MyProperty);" >Get Data 2</button>

or even...
        <button value="Get Data" onclick="alert(document.getElementById('Xaml1').Content.Page.MyProperty);" >Get Data 2</button>

 

Some observations and discoveries…

  • Both attributes are not needed!
    Some sources say that both the class must be marked as [ScriptableType] and the property or method must be marked as [ScriptableMember]. I found that just marking the class as [ScriptableType] made all public members script accessible. I also found that marking a property or method as [ScriptableMember] was all that was needed to expose the one member. It was not necessary to mark up the class at all.

    And I would say that Microsoft agrees with me!  ;-)
    http://msdn.microsoft.com/en-us/library/system.windows.browser.scriptabletypeattribute(VS.95).aspx
  • “ScriptableTypeAttribute Class - Indicates that all public properties, methods, and events on a managed type are available to JavaScript code when they are registered by using the RegisterCreateableType method.”

    “If you want to expose only a subset of properties, methods, and events as scriptable endpoints, do not use a ScriptableTypeAttribute object. Instead, attribute the subset of properties, methods, and events with a ScriptableMemberAttribute object.”

    If you do choose to use [ScriptableType] and want to hide one of the public members mark it with:

       [ScriptableMember(EnableCreateableTypes = false)]

    Note: the preferred notation for the attributes excludes the word “Attribute”, so use [ScriptableType] and [ScriptableMember].

     

  • "HtmlAccess=Enabled" is not needed for calls INTO Silverlight, only to enable calls out.
      <asp:Silverlight ID="Xaml1" HtmlAccess=Enabled ...

 

Useful web resources:

3/14/2009

SharePoint: Finding SharePoint GUIDs

 

Update… I put together a PowerShell version of this here: http://techtrainingnotes.blogspot.com/2011/06/finding-sharepoint-guids-using.html  (so now you have four versions!)

Update… I put together a version of this that uses the SharePoint web services so you can get the GUIDs without having to be on the server. The EXE and the C# project can be downloaded here.

So now you have three versions, API from a Windows app, API from a LAYOUTs page and Web Services from a Windows app.

---

 

 

Just a little code to share….   :-)

 

I needed a quick way to find the GUIDs used on a SharePoint site so I wrote a little C# routine to display them. Below is the sample code for both a Windows app and a SharePoint Layouts ASPX page.

 

The Windows Version:

As this calls the API instead of the web services so this will need to be run from one of the SharePoint servers.

Add a textbox, a button and a listbox on a form then…

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Microsoft.SharePoint;

namespace WindowsApplication2
{
    public partial class Form1 : Form
    {
        public Form1()
        {  InitializeComponent();    }

        private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            textBox1.Text = listBox1.SelectedItem.ToString();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            listBox1.Items.Clear();
            SPSite site;
            try
            {
                site = new SPSite(txtSiteURL.Text);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return;
            }
            listBox1.Items.Add("Site: " + site.ID.ToString());
            SPWeb web = SPContext.Current.Web;  //site.RootWeb;
            listBox1.Items.Add("Web: " + web.ID.ToString());
            foreach (SPList list in web.Lists)
            {
                listBox1.Items.Add(list.Title + ": " + list.ID.ToString());
            }

        }

    }
}

 

The Layouts folder version:

Create a text file in the SharePoint LAYOUTS folder with a name like “getGuids.aspx” and paste the following code. Run the page from any site:  http://youserver/yoursite/_layouts/getGuids.aspx

<%@ Page Language="C#"  %>
<%@ Import Namespace="Microsoft.SharePoint" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
    private void Page_Load(object sender, EventArgs e)
    {
        ListBox1.Items.Clear();
        SPSite site;
        site = SPContext.Current.Site;
        ListBox1.Items.Add("Site: " + site.ID.ToString());
        SPWeb web = SPContext.Current.Web;   // site.RootWeb;
        ListBox1.Items.Add("Web: " + web.ID.ToString());
        foreach (SPList list in web.Lists)
        {
            ListBox1.Items.Add(list.Title + ": " + list.ID.ToString());
        }
    }

    private void ListBox1_SelectedIndexChanged(object sender, EventArgs e)
    {
        TextBox1.Text = Request.Form["ListBox1"];
    }

</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:TextBox ID="TextBox1" runat="server" Width="530px" />
        <br /><br />
        Click to copy to the text box.<br />
        <asp:ListBox ID="ListBox1" runat="server"
          OnSelectedIndexChanged="ListBox1_SelectedIndexChanged"
          Rows="20" AutoPostBack="True"/></div>
    </form>
</body>
</html>

Note to spammers!

Spammers, don't waste your time... all posts are moderated. If your comment includes unrelated links, is advertising, or just pure spam, it will never be seen.