I am trying to solve a boring issue with an EF 6 data context now for several hours, though the entire code is small and simple. I did the same within the same solution already a couple of times and I never encountered this problem. Even when I compare the different implementations, configurations and references, I cannot find a difference. Here is the (very small) code snippet:
using (var context = new ConnectorDataContext())
{
var customer = context.Customers.FirstOrDefault();
}
Of course, there is more inside the using after the query, but it is not relevant whether it is there or not.
The collection is defined as
DbSet<ConnectCustomer> Customer {get;set;}
The context is derived from DbContext. Everything is attributed correctly (was copied from other, well working code parts of the solution.
The connection string points to a database which is used in other parts of the solution too. Yet, the test is isolated, so there is definately no other open connection.
But now, with this one, I always get an EntityException, caused by the underlying Provider, with an inner exception of "Overflow caused by the arithmetic operation". I am really close to desperation. Please help.
I've been battling a similar issue for far too long, and have only seen it emerge since upgrading to EF 6.x (not that I can conclusively say this is the cause). In my case, all calls to entity framework extension methods result in the "Arithmetic Overflow on Open" exception. Additionally, I only see this issue with IIS (any version), not IIS Express.
I found the following combination of things fixed the issue for me:
Manually clean your deployment location (del your obj and bin folders), try creating a new DB and point to it instead
Ensure your App Pool in IIS has "Enable 32-Bit Applications" set to True (right click on App Pool -> Advanced Settings)
Ensure that your database accepts remote connections - SQL Server Mgmt Studio, Right click on DB Server Instance -> Properties -> Connections -> Check the "Allow remote connections to this server" box
Ensure that DTC allows "Remote Clients": Windows Search for "Component Services" -> expand Computers -> My Computer -> Distributed Transaction Coordinator -> Right Click on "Local DTC" -> properties -> Security Tab -> Check Network DTC Access, Allow Remote Clients, Allow Inbound and Allow Outbound Transaction Manager Communication
Ensure that your Connection String is legit. I find this useful: http://www.developerfusion.com/tools/sql-connection-string/
Best of luck
I had the same issue. The application worked fine and then it suddenly started with the exceptions (no apparent changes in the code were made).
The solution was uninstalling program called "Web Companion" (I accidentally installed it by installing something else and not unticking during the installation process).
Therefore if you suddenly get these errors for no apparent reason, check for recent programs installed on your machine. Some of them can apparently cause it.
Related
I've been battling the following error over the past few weeks trying to run UI tests with Selenium (Chrome 92):
WebDriverException unknown error: net::ERR_CONNECTION_RESET. (Session info: chrome=92.0.4515.107)
This occurs most often trying to locate HTML elements using XPath.
Originally, I added a retry loop which checks if the WebDriverException is thrown three times, and if so, recycle the IWebDriver and try again (via IWebDriver.Quit() and IWebDriver.Dispose(). This does not fix the problem, nor does having my application restart after exceeding the retry limit. Thus, I'm starting to think this is a problem at the system-level (Windows Server 2016). Even a reboot does not always fix the issue - when it starts to fail, it just totally freezes and I end up having to completely rebuild the environment.
I'm using the Selenium WebDriver NuGet v92.0.4515.4300; I realize this isn't in total parity with the version listed above, but having the exact same versions does not fix the problem.
I know 'unknown error' is vague. Does anyone have suggestions for what could be causing the problem?
Thanks in advance.
EDIT: Posting browser arguments here, rather than cramming them into a comment. I forgot to mention, there is an instance of Fiddler which we run as a proxy on the local system and use in conjunction with some tests. It's started and ended with the testing application.
The following are injected as options when creating the Chrome instance:
--user-data-dir=C:\temp\{uniquedir}
options.AddUserProfilePreference("credentials_enable_service", false);
options.AddUserProfilePreference("profile.password_manager_enabled", false);
And these are added as command-line arguments through Selenium:
--lang=en-GB
--ignore-certificate-errors
--no-experiments
--disable-translate
--disable-plugins
--enable-logging
--no-sandbox
--dns-prefetch-disable
--disable-gpu
--disable-field-trial-config
(We are doing some security-related detections, hence the disabling of certificate errors.)
You mentioned that you use Fiddler, if the issue is reproducible only when it is started, you can try to regenerate the HTTPS certificates
The issue can be due to the application itself. If the error is shown when you are not using Selenium/ChromeDriver you can ask your developers/devops to check the IIS settings or follow one of the suggestions below.
Check your Internet options from computer Settings->Network&Internet->Proxy. On my computer "Automatically detect Settings" is enabled.
You can also try to delete the Chrome browser cache.
Flush the DNS (ipconfig /flushdns)
It could be some rule (firewall, internal DNS record) configured for the network where is your Windows Server.
Check if the issue is reproducible in incognito mode (without any browser extensions enabled). You can pass --incognito argument when starting the driver.
Issue could be caused by a certificate or SSL/TLS problem.
I have been experiencing run-time errors in my application since the project files were moved to a new file server this past weekend as well the retirement of several old domain controllers. One is an LdapException (The connection cannot be established) when creating a new PrincipalContext as in the code below:
WindowsPrincipal wp = new WindowsPrincipal(WindowsIdentity.GetCurrent());
using (PrincipalContext pc = new PrincipalContext(ContextType.Domain))
{
UP = UserPrincipal.FindByIdentity(pc, wp.Identity.Name);
}
I've tried a number of things including specifying various domain names and my network administrator has tried several things, but no luck.
I am also receiving an EntityException (The underlying provider failed on Open) when trying to get data from my MySQL database using EF as in the following code (crashes on the second line).
p = new pEntities();
Statuses = new ObservableCollection<status>(p.statuses);
I've taken several drastic steps that haven't solved my issues:
Uninstalled and reinstalled Visual Studio
Uninstalled and reinstalled MySQL
Deleted my user profile (this fixed some errors I was getting in VS, but not he run-time errors in the application itself)
I've tested the code in a completely new project and get the same errors, so it doesn't seem related to the project itself. I've also read quite a few SO and other posts on the two errors, but haven't been able to figure anything out. Is there something else I should be doing?
UPDATE
So, I moved my project to a local drive (C:) rather than the network, and now both errors are resolved, but I have no idea why that would fix it. Are there any known issues with running projects from networks drives that could cause these types of errors?
Note: Not sure if the question is asked the right way. This is how I perceive the issue but it's fully possible that the problem is addressable form a totally different angle, which I'm unaware of due to the ignorance.
Question
Is there a built-in database available for an out-of-the-box, MVC solution? If so, how do I find out its connection string?
Current string is for Azure and looks like this (frankly, it scares living excrement out me because I don't understand most of it).
<add name="DefaultConnection" connectionString="
Data Source=(LocalDb)\v11.0;
Initial Catalog=aspnet-Plong-20141107210818;
Integrated Security=SSPI;
AttachDBFilename=|DataDirectory|\aspnet-Plong-20141107210818.mdf"
providerName="System.Data.SqlClient" />
Background info
I'm developing a site and publish it to the Azure. It has some connections to the database and I'm using Code First and Entity Framework. Everything works great (maybe except the fact that it takes a few seconds to upload and initialize the page prior showing, which is annoying if I've only made changes to the markup of Razor).
In fact, all's been set up pretty much automagically, and I didn't have to configure much at all. Now, it's biting my in the sitting device because of the following.
I need to be able to run my site on the local host (using F5, if you will) because I'll be going off-line (or at the very least under a very lousy connection). I can do that right now, except for the page that contacts the database reference, where I'm getting the error below.
I get what the problem is - no local DB set up using code first. I wonder if there's a lazy man's solution to it (using some built in DB and code-first-able). If so, where do I set it up? I prefer to keep the reference to default connection string as intact as possible but if I need to edit it (or, most likely, add a new one and reference it), how do I learn the correct connection string?! (Yes, I know, this is the price I pay for taking an easy way out letting Azure configure everything for me. Head down in shame.)
{"Model compatibility cannot be checked because the database does not contain model metadata. Model compatibility can only be checked for databases created using Code First or Code First Migrations."}
As far as I know that's not a connection string to SQL Azure, but for a local (development) database. It will create a .mdf file in your App_Data folder. You can find connection strings to SQL Azure somewhere in the Azure dashboard. I switch between dev en production using for example:
public MyContext : DbContext
{
public MyContext()
#if DEBUG
: base("development")
#else
: base("production")
#endif
{
}
}
However, you could also use XML transformation of the web.config, web.debug.config and web.release.config. Note that web.debug.config is not really used when you run your application locally, so put your development connection strings in web.config and publish your application in release mode so the XML transformation of web.release.config takes place.
Edit: Get the SQL Azure connection string
Got to the management portal and click on SQL Databases. Click on the database and go to Dashboard. On the right side you see "Show connection strings". It looks something like this:
Server=tcp:xxx.database.windows.net,1433;Database={your_db_name};User ID={your_user_id};Password={your_password_here};Trusted_Connection=False;Encrypt=True;Connection Timeout=30;
I've been given a task to update a C# tool that works with the JAMS scheduler tool, and I've only heard good things about JAMS in spite of my complete inability to install or get it to work at all. I haven't been able to find anything online about this problem, so I know it must be something stupid that I'm doing. (I come from a mac/unix background and everything on windows seems fairly foreign to me)
I've gone through (multiple) successful installs of the JAMS x64 demo, but when I open the Windows JAMS Client GUI, I get consistently get an error popup saying:
Unable to load specified root folder: \
Exception:System.Net.Sockets.SocketException (0x80004005): No such host is known
at System.Net.Dns.InternalGetHostByName(String hostName, Boolean includeIPv6)
at System.Net.Dns.GetHostEntry(String hostNameOrAddress)
at MVPSI.JAMS.Server.GetURL(String objectURL)
at MVPSI.JAMS.Server.GetRemoteObject[T](String objName)
at MVPSI.JAMS.Server.Connect()
at MVPSI.JAMS.Server.GetRemoteObject[T](String objName)
at MVPSI.JAMS.Folder.Check(Int32& folderID, String folderName, FolderAccess access, Server js)
at JAMSWin.FolderNavigatorCtl.LoadRootFolder(String folderAddress) in c:\ProductionAZ\JAMS\Release\V6.1\JAMSWin\FolderNavigatorCtl.cs:line 406
I believe this error is caused by the JAMS server service using an incorrect server name, but I've tried many combinations (I've also installed/setup JAMS dbs in both my SQL2008 database engine and SqlExpress):
(local)
(local)\SqlExpress (with various capitalizations though I don't think this matters, does it?)
(local)\SQL2008
domainName\SqlExpress
... (the list goes on. Some of them were entirely impossible and I shouldn't have tried them, such as SQLEXPRESS\JAMS, but in my panic I did try it.)
No matter what I enter as the server name, I get the same result - the popup, and then the GUI window comes up saying "Unable to connect to the JAMSServer service; No such host is known."
This is all local, so I don't think it is a connectivity problem.
Any help would be greatly, greatly appreciated.
blue - full disclosure here as I work for JAMS.
Without seeing your logs here, it's a little difficult to say for sure what could be going wrong, my best guess is you're defining the SQL Server as the Server the client is connecting to, rather than just your local machine. The Client is trying to connect to the JAMS Server which in turn is trying to talk to SQL.
There is a Red J at the upper left hand corner of the product, if you click there and then on "Servers" you can define the JAMS Server you're trying to talk to. As you mentioned this is all local, simply utilize "localhost" and you should be off to the races.
If you're still having issues, I'd recommend sending in your logs to support for review because there may be something else going on here, it's too tough to say at the moment.
Devon
I get the following error when running Microsoft Code Contracts:
CodeContracts: Diagnostic: Failed to connect to any cache.
The user manual for Code Contracts states:
Cache results: Controls if the analysis results are cached. If
checked, the analysis tries to avoid analyzing methods whose outcomes
cannot possibly change (because no contracts, no code, and no relevant
metdata has changed). Enabling this option allows for faster
turn-around times if using the static checker repeatedly. To share the
cache among multiple developers, use a SQL server and put the server
name in the SQL Server conguration box in the UI. Note: the SQL
server connection uses Windows authentication to log onto the server.
Your developers will need the right to create and modify databases.
Find out the correct name of SQL server installed on your machine (note that "localhost" will not work; it has to be the actual machine name):
Right click on the project, select "Properties", go to the "Code Contracts" tab (down the bottom of the list), then, add your machine name:
This works for Release 1.5.60911.10 (Sep 11, 2013). Perhaps future versions of Code Contracts will attempt to connect to "localhost" and/or accept "localhost" in this box, and/or automatically detect SQL Server 2012.
In my particular case, I didn't have "(localdb)\V11.0" installed; if I had installed this then it would have worked out of the box (it must be defaulting to this internally).
Just uncheck the "Cache Results" option under the "Static Analysis" section of "Code Contracts" property page.