none
WCF CustomValidator Error: Could not load type 'mycustomvalidator' from assembly 'myassembly' RRS feed

  • Question

  • I have a WCF Service Library, Web hosted, with which I am trying to use CustomeUsernamePassword Authentication.  Whenever I try to add a service reference or "view in browser the .svc file, I get the following error:

    Could not load type 'BTOrderingServices.CustomUserNameValidator' from assembly 'BTOrderingServices.

    BTOrderingServices is the name of my Library and the name of the .dll. and CustomUserNameValidator is the Class that I created in the Service.vb (BTOrderingService.vb) to do the Validation.  Below is part of the Web.config that applies to the ServiceBehavior.  I'm not sure what to try next.

       <behaviors>
          <serviceBehaviors>
            <behavior name="ServiceBehavior">
              <serviceMetadata httpGetEnabled="true" />
              <serviceDebug includeExceptionDetailInFaults="false" />
              <serviceCredentials>
                <userNameAuthentication userNamePasswordValidationMode="Custom"
                  customUserNamePasswordValidatorType="BTOrderingServices.CustomUserNameValidator, BTOrderingServices" />
              </serviceCredentials>
            </behavior>
          </serviceBehaviors>
        </behaviors>


    mp

    Friday, April 26, 2013 9:02 PM

Answers

  • I was able to resolve this issue with a work around, and I also believe I may have stumbled on the root cause.  It has to do with the fact that I have a WCF Library project, and a separate Web Site Project as the host. 

    First, the work  around.  I created a Custom Validator Module/Class, but instead of including it with my Library Service, I installed it in the App_Code folder of the Web Host.  I then could reference it as CustomeUserNameValidator, App_Code.CustomUserNameValidator and it worked as expected.

    Now for what seems to be the root cause.  I noticed that when I created a reference in the Web Host to the Service Library, the .dll was copied to the bin folder of the Web Host.  However,  subsequent changes and rebuilds of the Library did NOT appear to be reflected in the .dll in the bin folder of the Web Host.  That makes no sense to me, but it would explain why the CustomUserNameValidator was never found when it was included in the Library.  Those changes were simply not carried over to the "Reference" copy in the Web Host bin folder.  I suppose I would need to remove and then add the reference back in.

    I have yet to figure out why the updating wouldn't be automatic, nor have I tried to move that class back into the Library, because it is working as is, but I intend to.


    mp

    Thursday, May 2, 2013 1:11 AM

All replies

  • Hi,

    >>customUserNamePasswordValidatorType="BTOrderingServices.CustomUserNameValidator, BTOrderingServices" />

    The first value is the type name and the second is the name of the assembly in which to find the type. Does it show invalid in your web.config?

    Also check if this is the issue #Could not load type X from assembly Y

    http://www.carlosble.com/2007/09/could-not-load-type-x-from-assembly-y/

    Best Regards.


    Haixia
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Monday, April 29, 2013 5:31 AM
    Moderator
  • I was able to resolve this issue with a work around, and I also believe I may have stumbled on the root cause.  It has to do with the fact that I have a WCF Library project, and a separate Web Site Project as the host. 

    First, the work  around.  I created a Custom Validator Module/Class, but instead of including it with my Library Service, I installed it in the App_Code folder of the Web Host.  I then could reference it as CustomeUserNameValidator, App_Code.CustomUserNameValidator and it worked as expected.

    Now for what seems to be the root cause.  I noticed that when I created a reference in the Web Host to the Service Library, the .dll was copied to the bin folder of the Web Host.  However,  subsequent changes and rebuilds of the Library did NOT appear to be reflected in the .dll in the bin folder of the Web Host.  That makes no sense to me, but it would explain why the CustomUserNameValidator was never found when it was included in the Library.  Those changes were simply not carried over to the "Reference" copy in the Web Host bin folder.  I suppose I would need to remove and then add the reference back in.

    I have yet to figure out why the updating wouldn't be automatic, nor have I tried to move that class back into the Library, because it is working as is, but I intend to.


    mp

    Thursday, May 2, 2013 1:11 AM
  • Hi,

    Thank you for sharing your findings and experience here. It will be very beneficial for other community members who have similar questions.

    Best Regards.


    Haixia
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Thursday, May 2, 2013 8:40 AM
    Moderator