FluentSecurity not working with mvc 4#39
Conversation
|
Hi Vadim, Until then you should be able to fix this using assembly redirect in your web.config. Let me know if this works for you. |
|
My web.config has the same configuration. The application works in a proper way, but the tests were failed. After the app.config has been added to the test library the tests pass. Thx! |
|
Would you say this issue is resolved for now? I will look at distributing different packages for MVC 3 and 4 in time for the final releas. |
|
Yes, works fine! |
|
Great. I'll leave this pull-request open for now as a reminder. If you feel like blogging about the problem and solution it would be much appreciated! |
|
I've written a short post about this problem: https://gist.github.com/3840929 |
|
Hi, We're having issues using custom violation handlers in conjunction with MVC 4 and Azure. We've tried against 1.4 and the latest pre-release version. The assembly binding redirect is in place as above but does not resolve the error. This is the error we get as the instance is started by the Azure Dev Fabric:
Can anyone confirm that they have used violation handlers with MVC 4? Thanks for any help! |
|
Where is this exception coming from? FluentSecurity? Your app? I have successfully used violation handlers in an MVC4 app in azure so I need more information if I am to help investigate this. One thing that looks strange in your example is the signature of your violation handler implementation. Try this instead: |
|
Thanks for looking at this. Indeed, the signature of the violation handler that I posted does look strange. I believe we had been fooling around with the signature to see what might happen; I'm not sure how the access modifier got dropped. In the other case, we tried declaring the method explicitly. Long story short, we did begin with the signature that you suggested. My hopes were raised momentarily, alas ... What information would help you investigate this? Here's a more complete copy of the error text taken from the Compute Emulator: With the following binding redirects:
|
|
To me this looks like an Azure related exception. Have very little experience with it but maybe this can help: A few questions if that did not do the trick:
|
|
That Azure issue doesn't seem related, although certainly Azure could be the culprit here. I'm trying to boil this down. What would you expect to happen, given that I've pulled out all of the configuration related to violation handlers, and leave only a class that implements IPolicyViolationHandler? |
|
To simply this a bit: In VS 2010: This works:
This doesn't work:
|
|
OK. We boiled this down. Long story short, the scenario of an MVC4 (Web.Mvc 4) Internet Application running on a Azure Cloud Project (Web Role), where an interface that is defined in a referenced class library which itself references MVC3, and the interface contains a method signature that returns an ActionResult (in this case), results in a TypeLoadException (see above). To be clear, Azure + MVC3 + FluentSecurity + Policy Violation Handlers work fine. What appears to be the solution, and what I'd like you to consider, is changing the "Specific Version" property of the "System.Web.Mvc" reference in the class library (FluentSecurity in this case) to false. It appears that when "Specific Version" is true the binding redirects either fail (no record of this in the logs) or are never attempted. See attached image. In the boiled down version described above, changing "Specific Version" to false resolved the TypeLoadException and allowed us to implement the class library's interface that was built against MVC 3. I haven't forgotten that you've said you've successfully used Azure / MVC4 / Fluent Security / PolicyViolationHandlers, which is mystifying. Looking forward to ideas! |
|
Any thoughts on this? |
|
@ekeonit Sorry for not replying. Christmas time is not the best time for doing open source stuff I'm afraid. ;O) |
|
Thanks Kristoffer! Joel On 2012-12-18, at 10:54 PM, Kristoffer Ahl notifications@github.com wrote:
|
|
Hi Kristoffer, Thank you a lot! |
|
Hi Mauro, The issue is against System.Web.Mvc. You say above that you changed the -- Joel On Wed, Dec 19, 2012 at 12:18 PM, mubeda notifications@github.com wrote:
|
|
Hi Joel, Best, |
|
I'm having a similar problem which is triggered by Entity Framework, inside my unit test library for an ASP.NET MVC 4 application. Upon calling DbContext.Database.Initialize (in the test fixture setup method), a ReflectionTypeLoadException is raised, saying the following: "Method 'Handle' in type 'MyApp.Security.DenyAnonymousAccessPolicyViolationHandler' from assembly 'MyApp, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' does not have an implementation.":"MyApp.Security.DenyAnonymousAccessPolicyViolationHandler". I have verified that the Handle method is implemented, and there's no problems with the application itself. |
|
Mauro, Can you also confirm that you changed the "Specific Version" property of System.Web.Mvc referenced by the fluent security project (i.e: you have built fluent security from the source after making the change); and not that you've changed the "Specific Version" property of System.Web.Mvc in your project which references fluent security Thanks, -- Joel |
|
Hi there! Regards, |
|
I'm running into a similar issue. The problem pops up when I run InstallUtil against the ASP.NET MVC 4 project which has an installer to create an event log source. Changing the specific version flag doesn't seem to make a difference. Some hints here perhaps? http://stackoverflow.com/questions/948785/typeloadexception-says-no-implementation-but-it-is-implemented |
|
I too solved the issue by recompiling against v4 of MVC. I don't really have the time to work out why my solution is having problems with it, even with 'specific version' set to false and: It would be nice to have it as a nuget package... |

install mvc 4 as nuget package