Click here to Skip to main content
16,006,476 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi. I am trying to add a procedure to a C# project. The procedure contains

C#
typeof(UriParser)


but I get a compiler error:

The type or namespace name 'UriParser' could not be found (are you missing a using directive or an assembly reference?)


The following lines are included above the namespace:

C#
<pre lang="C#">
using System;
using System.Text;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.IO;
using System.Reflection;</pre>

and the references in Solution Explorer are System, System.Data, System.Windows,Forms and System.Xml. 


What reference am I missing?

The entire procedure is to do with removing an unescaped slash from the url:

C#
public void LeaveDotsAndSlashesEscaped()
{
    var getSyntaxMethod =
        typeof(UriParser).GetMethod("GetSyntax", BindingFlags.Static | BindingFlags.NonPublic);
    if (getSyntaxMethod == null)
    {
        //throw new MissingMethodException("UriParser", "GetSyntax");
    }

    var uriParser = getSyntaxMethod.Invoke(null, new object[] { "http" });

    var setUpdatableFlagsMethod =
        uriParser.GetType().GetMethod("SetUpdatableFlags", BindingFlags.Instance | BindingFlags.NonPublic);
    if (setUpdatableFlagsMethod == null)
    {
        //throw new MissingMethodException("UriParser", "SetUpdatableFlags");
    }

    setUpdatableFlagsMethod.Invoke(uriParser, new object[] { 0 });
}


(I also commented out the 'throw new ...' lines because they cause 2 other errors, but I am handling errors elsewhere, so it doesn't matter.)

Thank you for your help.

What I have tried:

The actual issue is the 'unwanted backslash in url' problem in a Windows CE6.0 Net Compact Framework project, and I have looked at a number of would-be solutions in VB.net and also C#, but all have major problems with the CE6.0 and Net CF. This solution (above) only has one error to get rid of, so I am sticking with it till the error is gone!
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900