Hello Everybody.
I need to have an external application create users on my dotnetnuke site. In order to do so, I've decided to create a seperate DLL class.
In this DLL class I'm referencing the DotNetNuke.Security.Membership.AspnetMembershipProvider class, and I'm trying to use its public methods to manipulate memebers tables in the database.
However, It seems I am unable to initialize an object of the AspnetMembershipProvider class. When I try to run the following line of code:
DotNetNuke.Security.Membership.MembershipProvider memProvider = DotNetNuke.Security.Membership.MembershipProvider.Instance();
I get the following Exception
System.TypeInitializationException was unhandled
Message="The type initializer for 'DotNetNuke.Security.Membership.MembershipProvider' threw an exception."
Source="DotNetNuke"
TypeName="DotNetNuke.Security.Membership.MembershipProvider"
StackTrace:
at DotNetNuke.Security.Membership.MembershipProvider.Instance()
at Funtactix.Dnn.dnnMediator.MediatorUser.CreateUser(String email, String password, String firstName, String lastName, String charName, String country, String city, String passwordQuestion, String passwordAnswer) in D:\DotNetNuke\dnnMediator\dnnMediator\MediatorUser.cs:line 30
at ConsoleApplication1.Program.Main(String[] args) in D:\DotNetNuke\dnnMediator\ConsoleApplication1\Program.cs:line 12
at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
Inner Exception:
{"Object reference not set to an instance of an object."}
Stack Trace:
" at DotNetNuke.Framework.Reflection.CreateObject(String ObjectProviderType, String ObjectProviderName, String ObjectNamespace, String ObjectAssemblyName, Boolean UseCache)\r\n at DotNetNuke.Framework.Reflection.CreateObject(String ObjectProviderType, Boolean UseCache)\r\n at DotNetNuke.Framework.Reflection.CreateObject(String ObjectProviderType)\r\n at DotNetNuke.Security.Membership.MembershipProvider.CreateProvider()\r\n at DotNetNuke.Security.Membership.MembershipProvider..cctor()"
Anyone has an idea what am I doing wrong? Is there a way to initialize a dotnetnuke membershipprovider outside a dotnetnuke site?
Thanks in advance for everyone who helps.