Click here to Skip to main content
15,917,565 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I got this error.

An unhandled exception of type 'System.ServiceModel.AddressAccessDeniedException' occurred in System.ServiceModel.dll

Additional information: HTTP could not register URL http://+:7001/Class1/. Your process does not have access rights to this namespace (see http://go.microsoft.com/fwlink/?LinkId=70353[^] for details)

I am using without WCF template . i am creating the wcf service.
C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;
namespace ConsoleApplication2
{
    [ServiceContract]
    interface Interface1
    {
        [OperationContract]
        string getdata();
    }
}




C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;
namespace ConsoleApplication2
{

    class Class1 :Interface1
    {
        public string getdata()
        {
            return "wcf";
        }
    }
}




C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;

namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
            ServiceHost obj = new ServiceHost(typeof(Class1));
            obj.AddServiceEndpoint(typeof(Interface1), new BasicHttpBinding(), "http://localhost:7001/Class1");
            obj.Open();
            Console.WriteLine("start the service");
            Console.ReadKey();
        }
    }
}





I got the error in program of Open methods.

I was referred more sites but i cannot got the answer .

please any one help me.
Posted
Updated 15-Aug-12 21:16pm
v2

Make Class1 public.
I have changed only that.

C#
[ServiceContract]
    interface Interface1
    {
        [OperationContract]
        string getdata();
    }

    public class Class1 : Interface1
    {
        public string getdata()
        {
            return "wcf";
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            ServiceHost obj = new ServiceHost(typeof(Class1));
            obj.AddServiceEndpoint(typeof(Interface1), new BasicHttpBinding(), "http://localhost:7001/Class1");
            obj.Open();
            Console.WriteLine("start the service");
            Console.ReadKey();
        }
    }


It worked fine without any error.
 
Share this answer
 
I had same error , but when I run my services as administrator then it will work fine.
Thank you so much!
 
Share this answer
 
Open your Visual Studio as 'Run As Administrator' and then run your WCF service. I hope Now It will run.

Thanks :)
 
Share this answer
 
Comments
CHill60 10-Jun-15 3:55am    
Question has already been resolved and if you read the question carefully the error is "process does not have access rights to this namespace". It explicitly mentions Class1 within the project. So running as administrator will not grant access to that non-public class.
akhilesh Awasthi 12-Oct-15 0:57am    
Thank you very much
Member 11956823 31-Oct-15 8:54am    
Thanks sir that's work here

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