469,658 Members | 1,844 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,658 developers. It's quick & easy.

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

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.
Feb 16 '07 #1
5 7975
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.
Feb 16 '07 #2
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]" <mi*****@DONTLIKESPAMwp.plwrote in message
news:32**********************************@microsof t.com...
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.NameValueCollectio n)
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.

Feb 16 '07 #3
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]" <mi*****@DONTLIKESPAMwp.plwrote in message
news:32**********************************@microsof t.com...
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.


Feb 16 '07 #4
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]" <mi*****@DONTLIKESPAMwp.plwrote in message
news:69**********************************@microsof t.com...
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]" <mi*****@DONTLIKESPAMwp.plwrote in message
news:32**********************************@microso ft.com...
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.NameValueCollectio n)
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.



Feb 16 '07 #5
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]" <mi*****@DONTLIKESPAMwp.plwrote in message
news:69**********************************@microsof t.com...
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]" <mi*****@DONTLIKESPAMwp.plwrote in message
news:32**********************************@microsof t.com...
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.



Feb 18 '07 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by .Net Sports | last post: by
1 post views Thread by Dominique Vandensteen | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.