473,387 Members | 3,820 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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 8252
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Kevin | last post by:
Help, I am running a pass through query to oracle from SQL server 2000 as follows; select * from openquery(nbsp, 'select * from FND_FLEX_VALUES') I have run this query through both DTS and...
0
by: jff | last post by:
I defined a simple enumeration called "LandProjections" in one of my C# class library assemblies. I have another class library assembly that has a static method which references the enumeration....
1
by: Kris | last post by:
Hey everyone, I am trying to make a multi-project web application in visual studio that uses the server.transfer method in C# to get to the different aspx pages. However, when I call out to the...
0
by: xz | last post by:
I just installed Visual web dev. 2005 beta 1. I've never used the lite SQL server 2005 database, so I decided to try it out. From the Visual web dev. I selected 'create new sql server database' ...
0
by: .Net Sports | last post by:
I'm trying to build a datagrid project in vs.net, and getting an error that doesnt make sense: \\\\\\\\\\\\\\ Could not load type 'SportsMProject.btresults2a'. Source Error: Line 1: <%@...
1
by: Dominique Vandensteen | last post by:
I want to dynamicly load a type (typename is defined in the database). This type is located in the exe itself or one of the dll's in the directory with the exe file. When creating an instance...
0
by: hamstak | last post by:
While attempting to perform a build on an .aspx page from within VS 2005 I receive the "Could not load type" error pertaining to the class representing the page. The class is derived from a custom...
1
by: epatrick | last post by:
I have a series of custom controls developed under ASP.NET 1.1, and I've successfully migrated to ASP.NET 2.0. I have also developed a custom class dervied from System.Web.UI.Page, called...
4
by: freeflytim | last post by:
I'm trying to implement a custom MembershipProvider (and RoleProvider) together with a custom MembershipUser class in C#, Asp.Net 2.0, MS Visual Studio 2005. Everything has worked fine so far,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.