I have been implementing RSA security for a project I am working on.
- I’m using the SecurID4Net files found on the web to get this rolling, which by default are targeted to the .Net 2.0 framework, ANY CPU.
- I created a derived SqlMembershipProvider which references the SecurID4Net.Interfaces project, targeting .Net 4.0, any CPU.
- My class lib “Services” references the SqlMembershipProvider, also targeting Any CPU.
- My web app “Services.Web” references the “Services” lib, .Net 4.0, Any CPU.
I’m not using the client profile for any assembly targeting .Net 4. Every reference I have described here has Copy Local set to True.
I have my local IIS default web site set up to my output folder for the web project, so I can Ctrl-Shift-B and browse my IIS folder. When my client app signs in for the first time (possibly 2 or 3 times), it works fine, but after that sign ins fail. Additionally, when attaching to the IIS7 process (Services.Web), I would get the following error:
System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.
at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module)
at System.Reflection.Assembly.GetTypes()
at Microsoft.Tools.SvcHost.ServiceHostHelper.LoadServiceAssembly(String svcAssemblyPath)
The DLL it is having problems loading is the SqlMembershipProvider I created.
So, I changed the SecurID4Net.Interfaces project to target .Net 4.0, and recompiled. It seems to work consistently now (still testing this part), but CTRL-ALT-P to attach to the IIS process still results in the WcfSvcHost error popping up before I can actually attach to the process… everything else seems to be working.
- I’m running my VS as admin so I can attach to an IIS process;
- All references described are set to Copy Local = true;
- All assemblies are targeting .Net 4.0 Full Profile;
- All assemblies are reachable, not blocked by the copy operation to the server where this is hosted;
- To my knowledge no syntax issues with the web.config.
Anyone have any ideas why this error keeps popping up? Why would this error pop up when everything seems to be working?
I think I found the answer almost immediately. After inspecting each AssemblyInfo.cs file in the chain of projects, I found this in my SqlMembershipProvider assembly:
I removed the value so it’s an empty string.
I had a very similar issue in another project I worked on a few months ago where the web site had this filled in, and the web site worked on the very first load, but every load thereafter failed with a very cryptic error which, after drilling down, found that it could not load the assembly, giving a FileNotFoundException.
I don’t know why this tiny, simple attribute would cause so many headaches…
EDIT: I’m 99% certain this was it. When I attach to my IIS process I no longer get a WcfSvcHost error.