.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Validation(): Attribute 'Factory' is not a valid attribute of element 'ServiceHost'

Posted By:      Posted Date: August 29, 2010    Points: 0   Category :WCF
Hi, I'm using REST WCF3.5. In my .svc file, the Factory attribute is giving me Warning in the Visual Studio Team Suite saying "Validation(): Attribute 'Factory' is not a valid attribute of element 'ServiceHost'." <%@ ServiceHost Language="C#" Debug="true" Service="RestService" CodeBehind="~/App_Code/RestService.cs" Factory="AppServiceHostFactory" %> using System; using System.ServiceModel; using System.ServiceModel.Activation; using Microsoft.ServiceModel.Web; class AppServiceHostFactory : ServiceHostFactory {  protected override ServiceHost CreateServiceHost(Type serviceType, Uri[] baseAddresses)  {   WebServiceHost2 host = new WebServiceHost2(serviceType, true, baseAddresses);                 // Add the basic authenticator interceptor   host.Interceptors.Add(new BasicAuthenticationInterceptor(    System.Web.Security.Membership.Provider, "foo"));   return host;  } } I've added the reference as well & Everything works fine but I was wondering why am I getting this warning?? Thanks!  

View Complete Post

More Related Resource Links

Validation (ASP.Net): Attribute 'onchange' is not a valid attribute of element 'TextBox'.



I'm new to ASP.NET, C# and Visual Studio.  I do not have an IIS Server on my computer.  I do not have a registered version of Windows XP on my computer.  I got the above message after opening one of my .aspx files (someone else created it using an older version of ASP.Net) referring to the line below:


<asp:textbox id="txtOrderNumber" Runat="server" onchange="ClientOnChange();" ontextchanged="txtOrderNumber_TextChanged"></asp:textbox>

Custom Validation Attribute is not called by validation mechanism.

Hello everyone I have create custom validation attribute and assign it to class level validation. Unfortunately, it is not called. I try every way that it think it could be solve the problem. However, it take me for hours and I can't find the attribute is not called by validation mechanism.For illustrate you I put the following code.Attribute[AttributeUsage(AttributeTargets.Class, AllowMultiple = true, Inherited = true)] public sealed class BooleanDependencyAttribute : ValidationAttribute { private const string _defaultErrorMessage = "?????????{0}"; private readonly object _typeId = new object(); public string DependencyPropertyName { get; private set; } public string DependentPropertyName { get; private set; } public BooleanDependencyAttribute(string dependencyPropertyName, string dependentPropertyName) : base(_defaultErrorMessage) { DependencyPropertyName = dependencyPropertyName; DependentPropertyName = dependentPropertyName; } public override object TypeId { get { return _typeId; } } public override string FormatErrorMessage(string name) { return String.Format(CultureInfo.CurrentUICulture, ErrorMessageString,name); } public override bool

'Unspecified error' doing sp_xml_preparedocument on XML element with a long attribute

In SQL Management Studio 2008 (connected to SQL 2005 database), I get this:The XML parse error 0x80004005 occurred on line number 2, near the XML text "<item value="&#xD;&#xA;libname...Msg 6602, Level 16, State 2, Procedure sp_xml_preparedocument, Line 1The error description is 'Unspecified error'.When I do this declare @doc nvarchar(max), @idoc int set @doc = '<item value="&#xD;&#xA;libname..." />' EXEC sp_xml_preparedocument @idoc OUTPUT, @doc when the value of the @value attribute is actually a string of somewhat over 830000 characters.If I truncate the string somewhat, the statements execute successfully.Anyone know how to fix this?  (and "use shorter attributes" is not an acceptable answer :-)I would use XQuery except that I can't figure out how to get the equivalent of @mp:id and @mpparentid to give me the hierarchical structure information I need.  If anyone knows how to do that, I'd appreciate a hand there too!  

WCF Service in VS.Net 2010 (provided as the Service attribute value in the ServiceHost directive)

Hi,   I'm building my first WCF Service in VS.Net 2010 RC on a Win7 Ent 64. But when I launch my Service (ASP .Net Development Server) for debug and click on the .svc file, I get following error :   The type 'Systemat.Software.Services.PopsyWS.PopsyWebService', provided as the Service attribute value in the ServiceHost directive, or provided in the configuration element system.serviceModel/serviceHostingEnvironment/serviceActivations could not be found.   My Project is in the namespace "Systemat.Software.Services.PopsyWS", Assembly Name is "PopsyWebService",Service Name is "PopsyWebService" derived from "IPopsyWebService". All compile options are set on x86. My code behind is in the file PopsyWebService.svc.cs My svc file has <%@ ServiceHost Language="C#" Debug="true" Service="Systemat.Software.Services.PopsyWS.PopsyWebService" CodeBehind="PopsyWebService.svc.cs" %> I also tried PopsyWebService.PopsyWebservice with the same result (stating Type 'PopsyWebService.PopsyWebservice' was not found offcourse) Pretty sure on of those two is the correct one but neither of them work. Other posts talk about problems with the GAC but I don't think this has anything to do with my problem.   A new empty (example) project of a WCF Service works correctly so it's a project

A general validation attribute for checking uniqueness in a linq to sql data context

I've been programming asp.net for, oh, a couple of days now. Here's a question I can't even begin to figure out for myself. I hope it's obvious from the code what I want to accomplish, and I have, but it's not pretty. Furthermore I'd like to use it on whatever table, whatever field, i.e. check the uniqueness of a value against a table and field I specify, passing it all into the attribute constructor. public class UniqueEmailAttribute : ValidationAttribute{    public UniqueEmailAttribute()    {    }    public override Boolean IsValid(Object value)    {        //not pretty. todo: do away with this.        var db = new CoinDataContext();        int c = db.Emails.Count(e => e.Email1 == value.ToString());        return (Boolean) (c == 0);    }}

Linq to xml to retrieve element value by its attribute

Can someone please tell me how to select the mac element value.  Here is my code that not working.  Thanks. Attempt1:        '* from string        Dim xdoc As XDocument = XDocument.Parse(xmlString)        Dim LQElements = From xe In xdoc.Elements("mac") _                         Where xe.Attribute("type").Value = "eth" _                            Select xe.Value        For Each LQElement In LQElements            Dim mytype As String = LQElement.ToString        Next Attempt2: '* from string Dim xdoc As XDocument = XDocument.Parse(xmlString) Dim LQElements = (From xe In xdoc.XPathSelectElements("//mac") _ Where xe.Attribute("type") = "eth" _ Select New With { _ .type = xe.Attribute("type").Value, _

Custom validation attribute that compare 2 valaues

I want to create Custom validation attribute  that compare 2 valaues i wnat to get the two vlaue   in side the validator together sucha that i have check  2 conditions 1)if the values of the two fieds are 0 then no need to do any comparison else value 1 should be less than value 2 MVC2  

New appliesTo attribute on assemblyBinding element in web.config after upgrading website for Visual


We just upgraded from Visual Studio 2008 to Visual Studio 2010. We had to convert our projects and solutions, but we thought no changes were need for regular ASP.net websites. However, Visual Studio 2010 modified the assemblyBinding element in the web.config file to include the appliesTo attribute. The website is still targeting .net 3.5 and will be for a little while until we upgrade everything to 4.0.

So, is this attribute necessary? If so, why? We had hoped we didn't need to update all our websites solely for the purpose of using Visual Studio 2010 as we have a lot of them. We'll take the effort to upgrade them when we finally change them to target .net 4.0. Until then, is the web.config change necessary?

Here is what we had in web.config before the upgrade to Visual Studio 2010:

    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">

The type 'ServiceLib.Web.REST', provided as the Service attribute value in the ServiceHost directi


After publishing a simple web service, I encounter the following err when accessing it via the browser, like:


in the IIS I also created one virtual application named "Web" which contains the following files:
so, the structure under localhost is like:
http://localhost/bin/xxx.dlls (the web services files)
/web /REST.svc & web.config file (this is the virtual application folder)

I wonder what's wrong, thx for helping me. I guess it's an IIS problem since web service was accessable before, but now it's not Sad I don't know where the problem is. who can tell me ?

Server Error in '/Web' Application.

The type 'ServiceLib.Web.REST', provided as the Service attribute value in the ServiceHost directive could not be found.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Using SPWebConfigModification to conditionally modify an element's attribute or add the element if



I have a question about using SPWebConfigModification along with FeatureReceiver to make a change to my SharePoint web application's web.config when my feature installs.  I have a scenario where there is an element in my web.config that may or may not exist.  If it exists, it has an attribute with a value, and possibly child elements, e.g.:

<myelement myattr="myvalue">

  <mychild />



If the element exists, I need to change the value "myvalue", otherwise I need to add the element itself.  "mychild" child elements may or may not exist.  When my feature is uninstalled, I need the web.config to revert back to exactly its original state (restore the original value of "myvalue" and preserve "mychild" elements, if they existed previously, or remove the whole element if they did not).

Is this possible using the SPWebConfigModifications within the FeatureReceiver framework?  If so, if someone could point me to a simple example, that would be perfect, as all of the examples I can find seem to be quite simple.



I am not able to read xml file with XDocument if its Descendants has Attribute xmlns="http://abc.co


I am not able to read xml file with XDocument if its Descendants has  Attribute like:-

<?xml version="1.0" encoding="utf-8" standalone="yes"?>
  <row ID="1" xmlns="http://www.opentravela.org/OTA/2003/05">
    <var country_name="Caribbean and Rest of the world" city_name="Kingston" flight_category="Economy Class" via="Atlanta" flight_departure="London Heathrow" airline_logo="Delta" adult_fare="Delta" child_fare="660" infant_fare="561" date1="132" date2="2010-08-15" />


I don't know what to do ?

Looking for some help..

Category attribute of user control property does not work correctly in categories tab.



I have a User Control (ascx) and a property which a want to display in my categories tab in Visual Studio in the category named "Styles".

[Category("Styles"), DefaultValue(""), Description("The value for formating something.")]
public String MyFormatProperty
set { /* the code for set */; }
get { /* the code for get */; }

And here is the problem: Actually I do not need a get, because I only have to set the property (write only property). But when I omit the get, the property is displayed in the "Misc" category in the categories tab in Visual Studio. Only when I code the get as well, then the property is displayed correctly in the "Styles" category in the categories tab in Visual Studio.

Does anybody know why? How can I display the category correctly only with set?

Thanks, S.

Make sure that the class defined in this code file matches the 'inherits' attribute, and that it e


Here is the page directive for the page that throws the error:

@ Page language="c#" Inherits="University.AspNet.Index" CodeFile="Index.aspx.cs" %>

The code behind file Index.aspx.cs starts like this:

using University.Framework.UI;

namespace University.AspNet

public partial class Index : University.Framework.UI.HomePage

The code behind is extending this HomePage class, which is in turn an extenstion of another class University.Framework.UI.Page, which extends the System.Web.UI.Page class.

Am I misusing the I

Security Briefs: Hashing Passwords, The AllowPartiallyTrustedCallers Attribute


Keith Brown describes how yo can hash passwords when you want to store them in your own custom database, and when to use the AllowPartiallyTrustedCallers attribure on your assembly.

Keith Brown

MSDN Magazine August 2003

"Content for this URL is excluded by the server because a no-index attribute." in crawl logs


Hi All,

I am getting following error message in Crawl Logs

" Content for this URL is excluded by the server because a no-index attribute. "

Any help in this regard will be greatly appreciated.



ReadOnly DateTime attribute stores correct date but only retrieves DateTime.MinValue on Delete


Hey everyone,

I have a dynamic data site that stores Event data using LINQ-to-SQL. When someone requests an event, it is first stored as a PendingEvent (which is a child of Event) with a column/attribute called receivedAt, which is [ReadOnly(true)] and which is assigned in InsertEvent as shown.

        partial void InsertEvent(Event instance)
            instance.requestedAt = DateTime.Now;




This works fine. The event displays with the correct receivedAt date, and it's correct in my database. It shows up just fine on my Display, Edit, and List pages. However, if I try to delete, the receivedAt in the instance (retrieved with my debugger) in my delete function is 01/01/0001 12:00am, also known as DateTime.MinValue. My other dates appear correct.

If I remove "ReadOnly(true)" from the received at, everything works fine. Why won't "ReadOnly" allow me to have a time?
Thanks in advance,



I forgot to mention why I care. I can't submit the instance to be deleted because DateTime.MinValue is outside SQL's available datetime, so I get a SQL error. The delete also takes place in a custom dele

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend