.net core to sqlserverce issue - .net-core

I am trying to connect to a SQL Server CE (.sdf) file using the .Net Core console. I keep on getting the error below whereas the same code is working properly in the .Net Framework.
Can anyone suggest to me what the issue is?
The type initializer for 'System.Data.SqlServerCe.KillBitHelper' threw
an exception. ---> System.IO.FileNotFoundException: Could not load
file or assembly 'System.Security.Permissions

It is not possible and not supported, System.Data.SqlServerCe requires the full .NET Framework and Windows.
UPDATE It is actually possible (on Windows only) with .NET Core 3.x - see https://github.com/dotnet/corefx/issues/33897#issuecomment-536269132

Related

COULD NOT LOAD TYPE 'System.Security.Principal.WindowsImpersonationContext' from assembly 'mscorlib'

I'm creating an ASP.NET API Core application, to handle API services, which communicate to an Oracle Database.
At runtime, when the process tries to connect to the DB with a new Oracle Connection throught a DbContext ( Entity Framework) an unhandled error appears and forces the app to stop.
myDbContext.Database.Connection.Open();
This line causes the following error
System.TypeLoadException : 'Could not load type
'System.Security.Principal.WindowsImpersonationContext' from assembly
'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=xxx'.'
I had an old but similar project which used the same code and worked properly.
The library used is the same for Oracle Connector : Oracle.ManagedDataAccess.EntityFramework
What I tried :
Unistall - Reinstall Oracle.ManagedDataAccess.EntityFramework,
same for other Oracle connector ( Oracle.ManagedDataAccess, Oracle.ManagedDataAccess.Core )
Install System.Security.Principal
Changing the target framework from 3.1 to 5
I went first to this page 'System.Security.Principal.WindowsImpersonationContext' from assembly 'mscorlib' error when trying to parse template with Razor Engine but did not find anything that could help me resolve this.
For dot net 6, I was getting the same exception. Only kept the package: Oracle.ManagedDataAccess.Core and removed all others related to oracle and it works.
Get rid of 'Oracle.ManagedDataAccess'. I had both 'Oracle.ManagedDataAccess' and 'Oracle.ManagedDataAccess.Core' installed. This issue is most likely caused because 'Oracle.ManagedDataAccess' is for .NET Framework and not .NET Core/.NET 6.
I had the same problem. The .NET Core version has the same name as the .NET Framework version Oracle.ManagedDataAccess.dll but with a lower version number. As a result, Visual Studio takes the higher version from the GAC rather than the NuGet package. -> Delete the GAC version.

Error System.NotSupportedException on Razor Pages Project

After researching a lot and finding nothing about it, I decided to ask for collaboration here in the community.
I am trying to perform run in Visual Studio 2019 from a Razor Pages project, created in the 2017 version of Visual Studio. The Target Framework is net461.
However, the following error occurs:
NotSupportedException: Attempting to load an assembly from a network
location that would cause the assembly to be in safe mode in earlier
versions of the .NET Framework. This version of the .NET Framework
does not enable CAS policy by default, so this loading can be
dangerous. If it does not intend to confine the assembly, enable the
loadFromRemoteSources option.
I am not loading any assemblies over the network. All files are on my computer. Also, all exe, dll files are unlocked.
Error is in the startup.cs:
services.AddMvc()
I greatly appreciate any help.
are you creating .NET 4.6.* project or .Net Core? For .Net Core the target framework should be .NET Core 2.* or 3.* and make sure SDK is installed on your machine.

Asp.net Core 2.0 with .net framework 4.6.1 - Cannot find reference assembly '.NETFramework/v4.6.1/Microsoft.CSharp.dll

I have recently upgraded my project from asp.net core 1.1 to asp.net core 2.0. and app us using .Net framework 4.6.1. Application is working as expected on local dev machine but once it deployed to server with dotnet publish command I am seeing this error
InvalidOperationException: Cannot find reference assembly
'.NETFramework/v4.6.1/Microsoft.CSharp.dll' file for package
Microsoft.CSharp.Reference
I have also noticed that ref folder that use be present when using asp.net core 1.1 when published is now missing. How to fix this issue.
Same issue was resolved when MvcRazorCompileOnPublish was added to .csproj file.
Give it a try.
<MvcRazorCompileOnPublish>true</MvcRazorCompileOnPublish>
<MvcRazorExcludeRefAssembliesFromPublish>false</MvcRazorExcludeRefAssembliesFromPublish>
I noticed if you have the Views folder included with the compiled View.dll when you start your IIS pool, you get this error. I was doing this on purpose for a short term work around hack.
In my case (I run .Net core in console application mode) none of above solutions didn't works, i just downloaded .Net Framework 4.6.1 from this link.

Getting an error while trying to debug an ASP.NET (WebForms) app that I've migrated

I'm trying to migrate an ASP.NET 2.0 app (WebForms) to ASP.NET 3.5. I've finally fixed a 500.19 IIS 7.5 error I was having. Now it will run, so long as I don't attempt to debug it. If I do attempt to debug it I get an error message. I've searched for help on this error and there's precious little out there. Here's the text of the error message:
Unable to start debugging on the web server. Check for one of the following.
The application you are trying to debug uses a version of the Microsoft .NET Framework that is not supported by the debugger.
The debugger has made an incorrect assumption about the Microsoft .NET Framework version your application is going to use.
The Microsoft .NET Framework version specified by you for debugging is incorrect.
Please see the Visual Studio .NET debugger documentation for correctly specifying the Microsoft .NET Framework version your application is going to use for debugging.
Well, as far as I know, I'm using the correct version of the .NET Framework (3.5) for this app. Although I am not as familiar with IIS 7.5 on Windows 7.
I found that I had to get into IIS and change the application pool that my upgraded ASP.NET app was using. It had been assigned to an application pool that's associated with .NET 4.0. I changed it to one related to .NET Framework 2.0.

Getting error when I attempt to debug an ASP.NET 3.5 web site using Visual Studio 8

I'm getting the following error when I attempt to debug a web site I've created with Visual Studio 8, and ASP.NET 3.5 Framework.
Anyone know how I can fix this issue?
Thanks,
Greg
...
Auto-attach to process '[8036] aspnet_wp.exe' on machine 'S418-B-XA2A' failed. Check for one of the following.
The application you are trying to debug uses a version of the Microsoft .NET Framework that is not supported by the debugger.
The debugger has made an incorrect assumption about the Microsoft .NET Framework version your application is going to use.
The Microsoft .NET Framework version specified by you for debugging is incorrect.
Please see the Visual Studio .NET debugger documentation for correctly specifying the Microsoft .NET Framework version your application is going to use for debugging.
I think your IDE is defaulting to a different .NET framework version, you need to set it properly in the debugger, see for example : http://msdn.microsoft.com/en-us/library/ms241897(v=VS.90).aspx

Resources