So I have seen a bunch of answers to this question. None seem to resolve my issue. I am running the project as a self hosted webservice using servicestack.
Yes I have uninstalled and reinstalled entity framework, cleaned solution, restarted visual studio, rebuilt
Yes I have checked all binding redirects.
Yes I have checked that EntityFramework Dll is in the folder being searched for the dll.
Yes I have permissions to this folder (out of desperation I put the project on my own desktop to eliminate security issues).
Yes the nuget package, the project and all configs have .net 4.5.1 as their target platforms.
Despite all of this, I still get the error:
Could not load file or assembly 'EntityFramework' or one of its dependencies. Access is denied.":"EntityFramework"
=== Pre-bind state information ===
LOG: DisplayName = EntityFramework
(Partial)
WRN: Partial binding information was supplied for an assembly:
WRN: Assembly Name: EntityFramework | Domain ID: 1
WRN: A partial bind occurs when only part of the assembly display name is provided.
WRN: This might result in the binder loading an incorrect assembly.
WRN: It is recommended to provide a fully specified textual identity for the assembly,
WRN: that consists of the simple name, version, culture, and public key token.
WRN: See whitepaper http://go.microsoft.com/fwlink/?LinkId=109270 for more information and common solutions to this issue.
LOG: Appbase = file:///C:/Users/MyUserName/Desktop/TempFolder/Web.MyProject.Service/bin/x86/Debug/
LOG: Initial PrivatePath = NULL
Calling assembly : EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Users\MyUserName\Desktop\TempFolder\Web.MyProject.Service\bin\x86\Debug\Web.MyProject.Service.vshost.exe.Config
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Attempting download of new URL file:///C:/Users/MyUserName/Desktop/TempFolder/Web.MyProject.Service/bin/x86/Debug/EntityFramework.DLL.
ERR: A fatal error occurred when retrieving next codebase for download (hr = 0x80070005).
Can anyone point me at some tools to track down the cause of the problem (unless you know what the problem is ;-D).
Turns out the "Access is Denied" was not lying. The context I was working with was a wrapper around (inherited from) an actual EntityFramework context which implemented some impersonation in the constructor. The impersonated user did not have access to the bin directory which is the reason for the error.
Related
It looks like a silly question but i have no way out to pass my error.
I'm working on ASP.NET MVC 5 and everything work fine on my local machine, even i deploy on my local IIS (IIS 7 on Windows 7)
I have a hosting (just a hosting, not a server) and now i deploy on that host and i get the message:
Could not load file or assembly 'Microsoft.IdentityModel, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. Access is denied.
The error line come from: #Html.AntiForgeryToken()
I have created a fresh mvc 5 project (not add any logic). I just add a simple form with AntiForgeryToken but the issue is still on my host.
So what the relating between Microsoft.IdentityModel and the anti forgery token logic of MVC 5 and does any way i can force MVC getting Microsoft.IdentityModel from my dll not GAC?
I really don't understand what's going on. Could anyone can help me the way to find out more clear and detail about my issue?
set "Copy local" to true in the reference properties for "Microsoft.IdentityModel" in visual studio and try again
I am trying to follow this tutorial to access more user information when they log in using Facebook.
Get more information from Social providers used in the VS 2013 project templates
Ultimately I would like to be able to get data such as the user's firstName, lastName, Zip, etc. when a user logs in using Facebook and store that in the AspNetUsers table when they register. I will try this link.
For now I would just like to get this tutorial working but it is slightly different from my MVC 5.2.2 project. I am getting a 'type or namespace name "FB" could not be found. How can I fix this error?
Also, the ExternalLoginCallback is different, would I add the "await StoreFacebookAuthToken(user);" above var result = await SignInManager.ExternalSignInAsync(loginInfo, isPersistent: false);?
Solved:
I opened the Package Manager Console and it displayed a message which said that I was missing assemblies and it gave me the option to Restore the assemblies.
Than I received an error, "Could not load file or assembly 'System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified."
So I went to Manage NuGet Packages for Solution... and I just updated everything then it worked.
I have changed from vs 2010 to 2012 with asp.net MVC4.I have connected my application to the database using Telerik open Access.
I am implementing syncfusion in my application.
I have two issues,
1.Getting Null Reference Exception(Object does not set to an instance of an object) at
#Html.Syncfusion().CaptchaControl("Captcha1").EnableRefreshImage(true).RequestMapper("RefreshCaptcha").
2.while connecting my apln to the database using telerik open access it is showing error that "ModelContext does not found"
Query 1: Getting Null Reference Exception(Object does not set to an instance of an object)
The reported issue occurred due to the unavailability of Syncfusion.Theme.Base dll in your application. Syncfusion has introduced a new assembly “Syncfusion.Theme.Base” in the latest version 10.3.0.43 for theming support. so refer the Syncfusion.Theme.Base dll in your application and add the Syncfusion.Theme.Base assembly in web.config to overcome this NullReference exception issue. Please refer the below code snippet,
[Web.Config]
<assemblies>
<add assembly="Syncfusion.Theme.Base, Version=10.304.0.43, Culture=neutral, PublicKeyToken=3d67ed1f87d44c89" />
</assemblies>
Query 2: while connecting my apln to the database using telerik open access it is showing error that "ModelContext does not found".
Before providing solution to this query, I would like to know more details on this issue. Could you please let us know the list of Syncfusion controls that you are using in your application, so that I can analyze the issue and provide you a better solution.
I am currently using DotNetOpenAuth v4.1.0.12182 to perform simple Relying Party functionality and was able to get it working (tested Google and Yahoo) without even adding any web.config entries. However, this site will be deployed onto web servers which have the following setting enabled:
Go to Control Panel > Administrative Tools > Local Security Policy
Find the setting "System cryptography: Use FIPS compliant algorithms..." and set it to Enabled
Without this enabled the site works fine. With this enabled I get the Server Error "This implementation is not part of the Windows Platform FIPS validated cryptographic algorithms". I did find information on the dotnetopenauth v4-0 beta release page which mentions that, as of the DotNetOpenAuth 4.0 release, one of the changes was "FIPS-compliant SHA algorithms can now be configured in your .config files."
What I need help with...
I am seeking to know what config changes I need to make in order to get this FIPS message/error to go away. I've looked at [http://www.dotnetopenauth.net/developers/help/configuration-options/][2] but cannot find any clarity on it as to what is FIPS related. Any help would be greatly appreciated, thank you!
Updated (7/10/2012)
I'm providing the steps I've re-taken so the error can be replicated:
I used a fairly fresh install of Server 2008 R2 Enterprise (already had VS 2010 installed and perhaps some updates)
Added the Web Server Role
Added the .NET Framework 3.5.1 Feature
Enabled the Local Security Policy: System cryptography: Use FIPS compliant algorithms for encryption, hashing, and signing
Restarted the server
Compiled/built the OpenIdRelyingPartyWebForms sample and published it for use as a local IIS website
Ran into a URI error that caused me to have to set the App Pool to use ASP.NET v4.0
Ran into another error that caused me to have to "force install of .NET 4": http://devonenote.com/2010/06/could-not-load-type-system-servicemodel-activation-httpmodule/
Now the "Relying Party" webpage finally rendered so I clicked the Members Only link and then clicked the Sign In with a Yahoo ID option
After about a 2-3 second pause for it processing I receive:
[InvalidOperationException: This implementation is not part of the Windows Platform FIPS validated cryptographic algorithms.]
System.Security.Cryptography.SHA512Managed..ctor() +4479214
[TargetInvocationException: Exception has been thrown by the target of an invocation.] when trying to do System.Security.Cryptography.SHA512.Create +11 and then System.Security.Cryptography.CryptoConfig.CreateFromName +1195
[TypeInitializationException: The type initializer for 'DotNetOpenAuth.OpenId.HmacShaAssociation' threw an exception.] DotNetOpenAuth.OpenId.HmacShaAssociation.TryFindBestAssociation (cs:134)
Troubleshooting steps...
Added the config entries (based upon the link that Andrew provided) to the Framework64/v4.0.30319/Config/machine.config under the tag. However, since I have not yet added the Security.Cryptogrophy DLL anywhere I removed those lines from the config (the ones dealing with HMACSHA512).
Restarted the machine
Browsed back to and clicked the Sign In with a Yahoo ID button
[InvalidOperationException: This implementation is not part of the Windows Platform FIPS validated cryptographic algorithms.]
System.Security.Cryptography.SHA384Managed..ctor() +4486510
[TargetInvocationException: Exception has been thrown by the target of an invocation.] when trying to do System.Security.Cryptography.SHA384.Create +11 and then System.Security.Cryptography.CryptoConfig.CreateFromName +1195
[TypeInitializationException: The type initializer for 'DotNetOpenAuth.OpenId.HmacShaAssociation' threw an exception.] DotNetOpenAuth.OpenId.HmacShaAssociation.TryFindBestAssociation (cs:134)
What I noticed is that now it is complaining about SHA384 instead of SHA512, so the machine.config entry for SHA512 (telling ASP.NET to use the SHA512Cng class within System.Core) must be working!
So next I proceeded to add SHA384 & SHA256 entries, did an iisreset, and browsed back to and clicked the Sign In with a Yahoo ID button. This time I was finally redirected to Yahoo, logged in, and was sent back to my localhost URL but received this FIPS error:
[InvalidOperationException: This implementation is not part of the Windows Platform FIPS validated cryptographic algorithms.]
System.Security.Cryptography.HMACSHA256..ctor(Byte[] key) +4491026
So now I proceeded with the following:
Added in the HMACSHA512 machine.config line I originally took out and duplicated it for HMACSHA256
Added the Security.Cryptography.dll file from the codeplex project referenced in Andrew's response to the GAC (windows\assembly) as per this MSDN blog
Restarted the machine
Browsed to and clicked the Yahoo button again but received the same error
It appears as if the new Cryptography DLL was not being "picked up" by ASP.NET and used. So, next I tried:
Removing the DLL from the GAC
Restarting the machine
Added the Cryptography DLL as a reference to the OpenIdRelyingPartyWebForms sample and re-compiled and published it, overriding the exisiting IIS website files
Browsed to and clicked the Yahoo button again but received the same error
Any ideas on how I can get past this problem with HMACSHA256?
You need to configure .NET itself to create the FIPS-compliant versions of the required algorithms. Please check out this previously filed and fixed issue, including the comments, for guidance on how to proceed.
Using Andrew's comment/link I was able to get the solution working. However, I was never able to overcome the FIPS issue using .NET Framework 3.5. I had to upgrade to .NET Framework 4.0 and then add the following to the root configuration element of the machine.config XML file:
<mscorlib>
<cryptographySettings>
<cryptoNameMapping>
<cryptoClasses>
<cryptoClass CoreSHA512="System.Security.Cryptography.SHA512Cng, System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
<cryptoClass CoreSHA384="System.Security.Cryptography.SHA384Cng, System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
<cryptoClass CoreSHA256="System.Security.Cryptography.SHA256Cng, System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
</cryptoClasses>
<nameEntry name="System.Security.Cryptography.SHA512" class="CoreSHA512"/>
<nameEntry name="System.Security.Cryptography.SHA384" class="CoreSHA384"/>
<nameEntry name="System.Security.Cryptography.SHA256" class="CoreSHA256"/>
</cryptoNameMapping>
</cryptographySettings>
</mscorlib>
In case the XML was stripped out above, follow the link that Andrew provided and you'll find the XML in the post by joeudwin. I removed the lines for "TestHMACSHA512" and duplicated the lines for "TestSHA512" for 384 and 256 entries. I did not need to download Security.Cryptography.dll from CodePlex.
i am trying to deploy simple asp.net mvc frameworkd application in may shared hosting and i get erro like this:
Security Exception
Description: The application attempted to perform an operation not allowed by the security policy. To grant this application the required permission please contact your system administrator or change the application's trust level in the configuration file.
Exception Details: System.Security.SecurityException: Request for the permission of type 'System.Security.Permissions.ReflectionPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
http://test.pakabink.lt/
In my control panel i am seting "ASP.NET 2.0 Full Trust". What i need to ask for server administrator to change?
You should be able to bin deploy and run the MVC framework in medium trust. There is a possibility that there is some other permission that the hosting company has taken away but it should work. Are you testing with the default MVC project? If you are using other components (Structure Map, for example), that may be causing the error.
Check out Bin Deploying ASP.NET MVC from Phil Haack about deploying and the required trust level.
Medium trust does not allow certain Reflection operations. I guess some part of your code does or calls other part(s) of code.
Web deploy copies some System.Web dlls to bin folder, for example System.web.MVC but not all. It is kind of lot of debugging to determine which ones are missing, like the previous comment said about reflection methods.