Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Custom Role Provider give "can't load type error"

Reply
Thread Tools

Custom Role Provider give "can't load type error"

 
 
Alias
Guest
Posts: n/a
 
      02-16-2007
Hi -

I'm trying to implement a custom RoleProvider based on the SqlRoleProvider.
I keep receiving a an error that it can't load type
'MyRoleTest.MyRoleProvider' when trying to load my RoleProvider. However
this only occurs after deployment. On my local machine it works fine. So I
created the most basic role provider project I could think of. It is below:


Imports System.Web.Security
Imports System.Web.Configuration
Imports System.Configuration.Provider
Imports System.Collections.Specialized
Imports System
Imports System.Data
Imports System.Data.SqlClient
Imports System.Configuration
Imports System.Diagnostics
Imports System.Web
Imports System.Globalization
Imports System.Text
Imports Microsoft.VisualBasic

Public Class MyRoleProvider
Inherits SqlRoleProvider
Public Overrides Sub Initialize(ByVal name As String, ByVal config As
System.Collections.Specialized.NameValueCollection )
MyBase.Initialize(name, config)
End Sub
End Class

Here is how I reference it in the web.config :

<roleManager enabled="true" defaultProvider="TheRoleProvider">
<providers>
<clear/>
<add name="TheRoleProvider" type="MyRoleTest.MyRoleProvider"
connectionStringName="dbConn" applicationName="TestApp"/>
</providers>
</roleManager>

Locally it runs fine, but once deployed on the server it errors out on the
<add...> line. I'm using the fully qualified type name and the DLL for the
project containing the provider is in the Bin folder.

The odd thing is that I did the exact same thing for the MembershipProvider,
inheriting from SqlMembershipProvider and referencing it the same way in the
web.config and it works without a hitch. I would apprecieate any ideas. I
did try adding the MyRoleProvider class to the Web App Project itself in the
App_Code folder but that gave the same error.


 
Reply With Quote
 
 
 
 
=?Utf-8?B?TWlsb3N6IFNrYWxlY2tpIFtNQ0FEXQ==?=
Guest
Posts: n/a
 
      02-16-2007
Good morning,

Assuming class definition should stay withing web app project, move
MyRoleProvider class file to app_code folder (do not define custom namespace
name in the class file), remove 'MyRoleTest' from webconfig
<add name="TheRoleProvider" type="MyRoleProvider"
connectionStringName="dbConn" applicationName="TestApp"/>
Otherwise, if provider resides in separate control library, reference
library and add fully qualified class name:
<add name="TheRoleProvider" type="FullyQuilifiedClassNameWithNamespace"
connectionStringName="dbConn" applicationName="TestApp"/>

hope it helps
--
Milosz


"Alias" wrote:

> Hi -
>
> I'm trying to implement a custom RoleProvider based on the SqlRoleProvider.
> I keep receiving a an error that it can't load type
> 'MyRoleTest.MyRoleProvider' when trying to load my RoleProvider. However
> this only occurs after deployment. On my local machine it works fine. So I
> created the most basic role provider project I could think of. It is below:
>
>
> Imports System.Web.Security
> Imports System.Web.Configuration
> Imports System.Configuration.Provider
> Imports System.Collections.Specialized
> Imports System
> Imports System.Data
> Imports System.Data.SqlClient
> Imports System.Configuration
> Imports System.Diagnostics
> Imports System.Web
> Imports System.Globalization
> Imports System.Text
> Imports Microsoft.VisualBasic
>
> Public Class MyRoleProvider
> Inherits SqlRoleProvider
> Public Overrides Sub Initialize(ByVal name As String, ByVal config As
> System.Collections.Specialized.NameValueCollection )
> MyBase.Initialize(name, config)
> End Sub
> End Class
>
> Here is how I reference it in the web.config :
>
> <roleManager enabled="true" defaultProvider="TheRoleProvider">
> <providers>
> <clear/>
> <add name="TheRoleProvider" type="MyRoleTest.MyRoleProvider"
> connectionStringName="dbConn" applicationName="TestApp"/>
> </providers>
> </roleManager>
>
> Locally it runs fine, but once deployed on the server it errors out on the
> <add...> line. I'm using the fully qualified type name and the DLL for the
> project containing the provider is in the Bin folder.
>
> The odd thing is that I did the exact same thing for the MembershipProvider,
> inheriting from SqlMembershipProvider and referencing it the same way in the
> web.config and it works without a hitch. I would apprecieate any ideas. I
> did try adding the MyRoleProvider class to the Web App Project itself in the
> App_Code folder but that gave the same error.
>
>
>

 
Reply With Quote
 
 
 
 
Alias
Guest
Posts: n/a
 
      02-16-2007
Hi Milosz -

Thanks for responding. Is there anything else I can be looking for? What
you wrote is exactly what I wrote, that is why I can't figure this out. I'm
wondering if I'm missing a reference or something. I've tried it both ways
and I didn't use a namespace when I had it included in my web project. The
class is scaled down to the bare minimum and it works perfect locally but
not when it is deployed. Is there something I must override when inheriting
from SqlRoleProvider? I'm starting to wonder if their is a native .Net DLL
that isn't being deployed. Thanks!


"Milosz Skalecki [MCAD]" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Good morning,
>
> Assuming class definition should stay withing web app project, move
> MyRoleProvider class file to app_code folder (do not define custom
> namespace
> name in the class file), remove 'MyRoleTest' from webconfig
> <add name="TheRoleProvider" type="MyRoleProvider"
> connectionStringName="dbConn" applicationName="TestApp"/>
> Otherwise, if provider resides in separate control library, reference
> library and add fully qualified class name:
> <add name="TheRoleProvider" type="FullyQuilifiedClassNameWithNamespace"
> connectionStringName="dbConn" applicationName="TestApp"/>
>
> hope it helps
> --
> Milosz
>
>
> "Alias" wrote:
>
>> Hi -
>>
>> I'm trying to implement a custom RoleProvider based on the
>> SqlRoleProvider.
>> I keep receiving a an error that it can't load type
>> 'MyRoleTest.MyRoleProvider' when trying to load my RoleProvider. However
>> this only occurs after deployment. On my local machine it works fine.
>> So I
>> created the most basic role provider project I could think of. It is
>> below:
>>
>>
>> Imports System.Web.Security
>> Imports System.Web.Configuration
>> Imports System.Configuration.Provider
>> Imports System.Collections.Specialized
>> Imports System
>> Imports System.Data
>> Imports System.Data.SqlClient
>> Imports System.Configuration
>> Imports System.Diagnostics
>> Imports System.Web
>> Imports System.Globalization
>> Imports System.Text
>> Imports Microsoft.VisualBasic
>>
>> Public Class MyRoleProvider
>> Inherits SqlRoleProvider
>> Public Overrides Sub Initialize(ByVal name As String, ByVal config As
>> System.Collections.Specialized.NameValueCollection )
>> MyBase.Initialize(name, config)
>> End Sub
>> End Class
>>
>> Here is how I reference it in the web.config :
>>
>> <roleManager enabled="true" defaultProvider="TheRoleProvider">
>> <providers>
>> <clear/>
>> <add name="TheRoleProvider" type="MyRoleTest.MyRoleProvider"
>> connectionStringName="dbConn" applicationName="TestApp"/>
>> </providers>
>> </roleManager>
>>
>> Locally it runs fine, but once deployed on the server it errors out on
>> the
>> <add...> line. I'm using the fully qualified type name and the DLL for
>> the
>> project containing the provider is in the Bin folder.
>>
>> The odd thing is that I did the exact same thing for the
>> MembershipProvider,
>> inheriting from SqlMembershipProvider and referencing it the same way in
>> the
>> web.config and it works without a hitch. I would apprecieate any ideas.
>> I
>> did try adding the MyRoleProvider class to the Web App Project itself in
>> the
>> App_Code folder but that gave the same error.
>>
>>
>>



 
Reply With Quote
 
=?Utf-8?B?TWlsb3N6IFNrYWxlY2tpIFtNQ0FEXQ==?=
Guest
Posts: n/a
 
      02-16-2007
No no, read my reply again I pointed you were using
"MyRoleTest.MyRoleProvider" instead of just "MyRoleProvider" in web.config. I
reckon this is the only reason for this exception (the message clearly
indicates certain type cannot be loaded). All references are there, i they
weren't, you would get exception like 'cannot load assembly blablalaa'. Move
the class to app_code directory (make sure it's public), then update
web.config with

<add name="TheRoleProvider" type="MyRoleProvider"
connectionStringName="dbConn" applicationName="TestApp"/>

Should work.
--
Milosz


"Alias" wrote:

> Hi Milosz -
>
> Thanks for responding. Is there anything else I can be looking for? What
> you wrote is exactly what I wrote, that is why I can't figure this out. I'm
> wondering if I'm missing a reference or something. I've tried it both ways
> and I didn't use a namespace when I had it included in my web project. The
> class is scaled down to the bare minimum and it works perfect locally but
> not when it is deployed. Is there something I must override when inheriting
> from SqlRoleProvider? I'm starting to wonder if their is a native .Net DLL
> that isn't being deployed. Thanks!
>
>
> "Milosz Skalecki [MCAD]" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > Good morning,
> >
> > Assuming class definition should stay withing web app project, move
> > MyRoleProvider class file to app_code folder (do not define custom
> > namespace
> > name in the class file), remove 'MyRoleTest' from webconfig
> > <add name="TheRoleProvider" type="MyRoleProvider"
> > connectionStringName="dbConn" applicationName="TestApp"/>
> > Otherwise, if provider resides in separate control library, reference
> > library and add fully qualified class name:
> > <add name="TheRoleProvider" type="FullyQuilifiedClassNameWithNamespace"
> > connectionStringName="dbConn" applicationName="TestApp"/>
> >
> > hope it helps
> > --
> > Milosz
> >
> >
> > "Alias" wrote:
> >
> >> Hi -
> >>
> >> I'm trying to implement a custom RoleProvider based on the
> >> SqlRoleProvider.
> >> I keep receiving a an error that it can't load type
> >> 'MyRoleTest.MyRoleProvider' when trying to load my RoleProvider. However
> >> this only occurs after deployment. On my local machine it works fine.
> >> So I
> >> created the most basic role provider project I could think of. It is
> >> below:
> >>
> >>
> >> Imports System.Web.Security
> >> Imports System.Web.Configuration
> >> Imports System.Configuration.Provider
> >> Imports System.Collections.Specialized
> >> Imports System
> >> Imports System.Data
> >> Imports System.Data.SqlClient
> >> Imports System.Configuration
> >> Imports System.Diagnostics
> >> Imports System.Web
> >> Imports System.Globalization
> >> Imports System.Text
> >> Imports Microsoft.VisualBasic
> >>
> >> Public Class MyRoleProvider
> >> Inherits SqlRoleProvider
> >> Public Overrides Sub Initialize(ByVal name As String, ByVal config As
> >> System.Collections.Specialized.NameValueCollection )
> >> MyBase.Initialize(name, config)
> >> End Sub
> >> End Class
> >>
> >> Here is how I reference it in the web.config :
> >>
> >> <roleManager enabled="true" defaultProvider="TheRoleProvider">
> >> <providers>
> >> <clear/>
> >> <add name="TheRoleProvider" type="MyRoleTest.MyRoleProvider"
> >> connectionStringName="dbConn" applicationName="TestApp"/>
> >> </providers>
> >> </roleManager>
> >>
> >> Locally it runs fine, but once deployed on the server it errors out on
> >> the
> >> <add...> line. I'm using the fully qualified type name and the DLL for
> >> the
> >> project containing the provider is in the Bin folder.
> >>
> >> The odd thing is that I did the exact same thing for the
> >> MembershipProvider,
> >> inheriting from SqlMembershipProvider and referencing it the same way in
> >> the
> >> web.config and it works without a hitch. I would apprecieate any ideas.
> >> I
> >> did try adding the MyRoleProvider class to the Web App Project itself in
> >> the
> >> App_Code folder but that gave the same error.
> >>
> >>
> >>

>
>
>

 
Reply With Quote
 
Alias
Guest
Posts: n/a
 
      02-16-2007
Hi Milosz -

I was using MyRoleTest.MyRoleProvider for the type because my class was in a
seperate project.

At the bottom of my post I said that I tried adding the class directly to
the App_Code folder, when I did that I was using only the class name for
MyRoleProvider for the type. Which is why I can find no reason for this not
to work.

It works perfect for my custom MembershipProvider class however the exact
same thing doesn't work for my custom RoleProvider class when deployed.

Thanks for taking the time to respond. I appreciate that.

"Milosz Skalecki [MCAD]" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> No no, read my reply again I pointed you were using
> "MyRoleTest.MyRoleProvider" instead of just "MyRoleProvider" in
> web.config. I
> reckon this is the only reason for this exception (the message clearly
> indicates certain type cannot be loaded). All references are there, i they
> weren't, you would get exception like 'cannot load assembly blablalaa'.
> Move
> the class to app_code directory (make sure it's public), then update
> web.config with
>
> <add name="TheRoleProvider" type="MyRoleProvider"
> connectionStringName="dbConn" applicationName="TestApp"/>
>
> Should work.
> --
> Milosz
>
>
> "Alias" wrote:
>
>> Hi Milosz -
>>
>> Thanks for responding. Is there anything else I can be looking for?
>> What
>> you wrote is exactly what I wrote, that is why I can't figure this out.
>> I'm
>> wondering if I'm missing a reference or something. I've tried it both
>> ways
>> and I didn't use a namespace when I had it included in my web project.
>> The
>> class is scaled down to the bare minimum and it works perfect locally but
>> not when it is deployed. Is there something I must override when
>> inheriting
>> from SqlRoleProvider? I'm starting to wonder if their is a native .Net
>> DLL
>> that isn't being deployed. Thanks!
>>
>>
>> "Milosz Skalecki [MCAD]" <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed)...
>> > Good morning,
>> >
>> > Assuming class definition should stay withing web app project, move
>> > MyRoleProvider class file to app_code folder (do not define custom
>> > namespace
>> > name in the class file), remove 'MyRoleTest' from webconfig
>> > <add name="TheRoleProvider" type="MyRoleProvider"
>> > connectionStringName="dbConn" applicationName="TestApp"/>
>> > Otherwise, if provider resides in separate control library, reference
>> > library and add fully qualified class name:
>> > <add name="TheRoleProvider" type="FullyQuilifiedClassNameWithNamespace"
>> > connectionStringName="dbConn" applicationName="TestApp"/>
>> >
>> > hope it helps
>> > --
>> > Milosz
>> >
>> >
>> > "Alias" wrote:
>> >
>> >> Hi -
>> >>
>> >> I'm trying to implement a custom RoleProvider based on the
>> >> SqlRoleProvider.
>> >> I keep receiving a an error that it can't load type
>> >> 'MyRoleTest.MyRoleProvider' when trying to load my RoleProvider.
>> >> However
>> >> this only occurs after deployment. On my local machine it works fine.
>> >> So I
>> >> created the most basic role provider project I could think of. It is
>> >> below:
>> >>
>> >>
>> >> Imports System.Web.Security
>> >> Imports System.Web.Configuration
>> >> Imports System.Configuration.Provider
>> >> Imports System.Collections.Specialized
>> >> Imports System
>> >> Imports System.Data
>> >> Imports System.Data.SqlClient
>> >> Imports System.Configuration
>> >> Imports System.Diagnostics
>> >> Imports System.Web
>> >> Imports System.Globalization
>> >> Imports System.Text
>> >> Imports Microsoft.VisualBasic
>> >>
>> >> Public Class MyRoleProvider
>> >> Inherits SqlRoleProvider
>> >> Public Overrides Sub Initialize(ByVal name As String, ByVal config
>> >> As
>> >> System.Collections.Specialized.NameValueCollection )
>> >> MyBase.Initialize(name, config)
>> >> End Sub
>> >> End Class
>> >>
>> >> Here is how I reference it in the web.config :
>> >>
>> >> <roleManager enabled="true" defaultProvider="TheRoleProvider">
>> >> <providers>
>> >> <clear/>
>> >> <add name="TheRoleProvider" type="MyRoleTest.MyRoleProvider"
>> >> connectionStringName="dbConn" applicationName="TestApp"/>
>> >> </providers>
>> >> </roleManager>
>> >>
>> >> Locally it runs fine, but once deployed on the server it errors out on
>> >> the
>> >> <add...> line. I'm using the fully qualified type name and the DLL
>> >> for
>> >> the
>> >> project containing the provider is in the Bin folder.
>> >>
>> >> The odd thing is that I did the exact same thing for the
>> >> MembershipProvider,
>> >> inheriting from SqlMembershipProvider and referencing it the same way
>> >> in
>> >> the
>> >> web.config and it works without a hitch. I would apprecieate any
>> >> ideas.
>> >> I
>> >> did try adding the MyRoleProvider class to the Web App Project itself
>> >> in
>> >> the
>> >> App_Code folder but that gave the same error.
>> >>
>> >>
>> >>

>>
>>
>>



 
Reply With Quote
 
=?Utf-8?B?TWlsb3N6IFNrYWxlY2tpIFtNQ0FEXQ==?=
Guest
Posts: n/a
 
      02-18-2007
Howdy,

Sorry for misunderstanding. Try another resolution -create a control library
with the custom provider, then reference it in web site project, (don't
forget about with fully quilified name in web application's web.config file.

--
Milosz


"Alias" wrote:

> Hi Milosz -
>
> I was using MyRoleTest.MyRoleProvider for the type because my class was in a
> seperate project.
>
> At the bottom of my post I said that I tried adding the class directly to
> the App_Code folder, when I did that I was using only the class name for
> MyRoleProvider for the type. Which is why I can find no reason for this not
> to work.
>
> It works perfect for my custom MembershipProvider class however the exact
> same thing doesn't work for my custom RoleProvider class when deployed.
>
> Thanks for taking the time to respond. I appreciate that.
>
> "Milosz Skalecki [MCAD]" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > No no, read my reply again I pointed you were using
> > "MyRoleTest.MyRoleProvider" instead of just "MyRoleProvider" in
> > web.config. I
> > reckon this is the only reason for this exception (the message clearly
> > indicates certain type cannot be loaded). All references are there, i they
> > weren't, you would get exception like 'cannot load assembly blablalaa'.
> > Move
> > the class to app_code directory (make sure it's public), then update
> > web.config with
> >
> > <add name="TheRoleProvider" type="MyRoleProvider"
> > connectionStringName="dbConn" applicationName="TestApp"/>
> >
> > Should work.
> > --
> > Milosz
> >
> >
> > "Alias" wrote:
> >
> >> Hi Milosz -
> >>
> >> Thanks for responding. Is there anything else I can be looking for?
> >> What
> >> you wrote is exactly what I wrote, that is why I can't figure this out.
> >> I'm
> >> wondering if I'm missing a reference or something. I've tried it both
> >> ways
> >> and I didn't use a namespace when I had it included in my web project.
> >> The
> >> class is scaled down to the bare minimum and it works perfect locally but
> >> not when it is deployed. Is there something I must override when
> >> inheriting
> >> from SqlRoleProvider? I'm starting to wonder if their is a native .Net
> >> DLL
> >> that isn't being deployed. Thanks!
> >>
> >>
> >> "Milosz Skalecki [MCAD]" <(E-Mail Removed)> wrote in message
> >> news:(E-Mail Removed)...
> >> > Good morning,
> >> >
> >> > Assuming class definition should stay withing web app project, move
> >> > MyRoleProvider class file to app_code folder (do not define custom
> >> > namespace
> >> > name in the class file), remove 'MyRoleTest' from webconfig
> >> > <add name="TheRoleProvider" type="MyRoleProvider"
> >> > connectionStringName="dbConn" applicationName="TestApp"/>
> >> > Otherwise, if provider resides in separate control library, reference
> >> > library and add fully qualified class name:
> >> > <add name="TheRoleProvider" type="FullyQuilifiedClassNameWithNamespace"
> >> > connectionStringName="dbConn" applicationName="TestApp"/>
> >> >
> >> > hope it helps
> >> > --
> >> > Milosz
> >> >
> >> >
> >> > "Alias" wrote:
> >> >
> >> >> Hi -
> >> >>
> >> >> I'm trying to implement a custom RoleProvider based on the
> >> >> SqlRoleProvider.
> >> >> I keep receiving a an error that it can't load type
> >> >> 'MyRoleTest.MyRoleProvider' when trying to load my RoleProvider.
> >> >> However
> >> >> this only occurs after deployment. On my local machine it works fine.
> >> >> So I
> >> >> created the most basic role provider project I could think of. It is
> >> >> below:
> >> >>
> >> >>
> >> >> Imports System.Web.Security
> >> >> Imports System.Web.Configuration
> >> >> Imports System.Configuration.Provider
> >> >> Imports System.Collections.Specialized
> >> >> Imports System
> >> >> Imports System.Data
> >> >> Imports System.Data.SqlClient
> >> >> Imports System.Configuration
> >> >> Imports System.Diagnostics
> >> >> Imports System.Web
> >> >> Imports System.Globalization
> >> >> Imports System.Text
> >> >> Imports Microsoft.VisualBasic
> >> >>
> >> >> Public Class MyRoleProvider
> >> >> Inherits SqlRoleProvider
> >> >> Public Overrides Sub Initialize(ByVal name As String, ByVal config
> >> >> As
> >> >> System.Collections.Specialized.NameValueCollection )
> >> >> MyBase.Initialize(name, config)
> >> >> End Sub
> >> >> End Class
> >> >>
> >> >> Here is how I reference it in the web.config :
> >> >>
> >> >> <roleManager enabled="true" defaultProvider="TheRoleProvider">
> >> >> <providers>
> >> >> <clear/>
> >> >> <add name="TheRoleProvider" type="MyRoleTest.MyRoleProvider"
> >> >> connectionStringName="dbConn" applicationName="TestApp"/>
> >> >> </providers>
> >> >> </roleManager>
> >> >>
> >> >> Locally it runs fine, but once deployed on the server it errors out on
> >> >> the
> >> >> <add...> line. I'm using the fully qualified type name and the DLL
> >> >> for
> >> >> the
> >> >> project containing the provider is in the Bin folder.
> >> >>
> >> >> The odd thing is that I did the exact same thing for the
> >> >> MembershipProvider,
> >> >> inheriting from SqlMembershipProvider and referencing it the same way
> >> >> in
> >> >> the
> >> >> web.config and it works without a hitch. I would apprecieate any
> >> >> ideas.
> >> >> I
> >> >> did try adding the MyRoleProvider class to the Web App Project itself
> >> >> in
> >> >> the
> >> >> App_Code folder but that gave the same error.
> >> >>
> >> >>
> >> >>
> >>
> >>
> >>

>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Membership or Role Provider // Provider Model // Factories .. How does MS do it? sloan ASP .Net 1 07-03-2007 08:17 PM
Custom role provider not working Tom Van den Brandt ASP .Net 8 06-11-2007 08:28 PM
Custom Role Provider give "can't load type error" Alias ASP .Net Security 5 02-18-2007 11:09 PM
Custom Role Provider CK ASP .Net 1 07-25-2006 07:24 PM
debug a custom membership and role provider? =?Utf-8?B?QmVuIFIu?= ASP .Net 5 05-17-2006 12:04 PM



Advertisments