VS2005 freeze and disk thrashing when opening designers in C# projects? - c#

In some projects, but not all, when I open a designer for the first time (either WinForms or typed dataset) Visual Studio thrashes the disk for up to 30 minutes while freezing (this appears to be reads and writes with between 100 and 140 pages\sec).
Once it has done it the first time for a project, it's fine opening other projects until I close and re-open VS where it will freeze/thrash again the first time I open a designer.
Does anyone else see this, what the hell is it doing, and is there anything I can do to stop it?

It sounds like you are either running short on RAM and opening a designer puts it over the top or your hard disk needs to be defragmented.
It could be registry fragmentation too. Try pagedefrag.

OK, so it looks like it was defunct database connections in the Server Explorer tab:
A database on our test server was removed without my knowledge, but my project still had a data connection set up for it. It seems that whenever a table adapter is initialised in the designer, VS tries to connect to all the databases in the data connections list causing issues if the database does not exist. It even tries to connect to data connections that are not used by the current table adapter.
Some of our WinForms were badly written (naughy devs!) and were loading data in the constructors without checking for 'DesignMode' - these have been repaired.
Herbie

Related

best practice to save temporary data from a form in case of PC shutdown

I've created a C# forms application in which the user must enter production data of that working day.
Now I was thinking that in case of a sudden shutdown of the PC, the operator will have lost all the production data that was already filled in that day.
So when he restarts the application all the data should have to be filled in again.
At the end of the day (production order ends) all this data may be deleted again.
I was thinking of putting everything in a sql database and then delete it again at the end of the day, but this seems a bit of overkill.
Most of the production data will be entered in textboxes and datagridviews.
What would be an easier solution for this?
I wrote some POS app in nigera before, works fine with their local unstable environment (power shortage).
maybe you should give it a try, it took me one month to implement it on my software.
Microsoft Sync Framework

Xamarin.Forms Android app SQLite data disappears

I am writing a Xamarin.Forms app for Android using C#. I setup the Sqlite dB at: System.Environment.SpecialFolder.Personal
When the app is deployed on device I can add data and then retrieve it.
However, when I check the app next day(offline, without debugging from pc) all the dB data is gone.
Does it mean that the dB file is gone after some time?
Data from DB should not gone.
Are your sure that your DB initialization code is ok? Maybe every time you started the app, tha data is restoring to some start state?
The mysterious dissappearance of data in a sqlite db can have multiple causes.
Make sure that your db file exists, maybe you can implement a small debug button somwhere which will throw an alert which tells you if the file exists.
However using System.Environment.SpecialFolder.Personal shouldn't be the cause, I use that folder for my apps as well.
Second, do you actively commit your transactions? Especially when your app gets backgrounded, i would recommend calling Commit() in order to make sure that every pending transaction gets written into database, since you never know when the garbage collector comes around while your app is backgrounded.
If you are working with multiple threads, make sure that you are opening your database in a mode supporting a multithreaded environment.
If you open your sqlite db with a simple
SQLiteConnection conn = new SQLite.SQLiteConnection(path);
the database will open single-threaded.
Try this instead:
SQLiteConnection conn = new SQLite.SQLiteConnection(path, SQLiteOpenFlags.Create | SQLiteOpenFlags.ReadWrite | SQLiteOpenFlags.NoMutex);
If that doesn't help, please give a bit more insight into your code (how do you open the db, how do you insert/update data, etc...)

Failed to open a connection to the database" While creating a Table Adapter in C#

So, I'm mantaining a software an ex co-worker did.
He uses an xsd to create TableAdapters for his reports and other stuff.
The thing is, I need to add a new TableAdapter and I get the aforementioned error. It also says the dread "A network-related or instance-specific error occurred while establishing a connection to SQL Server."
I am at loss here and I don't know what to do. Here are the facts:
I have 2 connection strings, one for the production environment and one for the development environment (my computer).
When I go to settings and then the edit window of the connection string, I hit "test connection" and it says it works fine.
Both SQL Server 2008R2 and Visual Studio 2010 are on the same machine, my machine.
I do not have a named instance.
I right click on the xsd design view and click "Add -> TableAdapter" and use the local connection string (the one I already tested and worked)
I click "Use existing stored procedures" and then hit [Next]. Then I am able to pick a stored procedure for the Select section and I can see the columns.
I click finish, the system locks for a while and then I get the error.
Named Pipes, TCP/IP are enabled in SQL Server configuration.
I'm kinda lost and I already wasted 2 days on this. I have tried what little I know and nothings works. I hope I can find help within your wisdom.
Sorry for the long post but I wanted to provide as much info as I could in one single shot.
OK, After some trial and error, I found the solution. At least, I made it work on my environment.
What #Rusland said, made me think and I searched for another Settings file. It did not exist. I decided then to erase the connection strings and the Settings file to see if the project compiled. As expected, it threw a ton of errors.
So, it was not the file.
I decided to add one by one the connection strings and test as I added them. The first one that I added, was the connection string used in development (localConStr). The configuration of the table adapter was as shown in the first image. As you can see, localConStr is selected (as has always been) only this time, having only one connection string I received an error, a different error than before. The one in the second image.
How could it be possible for the TableAdapter to ask for that Connection String if there were no refferences to it? I deleted it and the Connection property of my table adapter was set to the localConStr. So... I did what any desperate man would do: CTRL+F and find all refferences to rptTbl_loansAgingTableAdapter. My only reasoning was that somewhere in the code, the connection string was probably hardcoded by my predecessor. One thing worth mentioning: I specifically used "loansAgingTableAdapter" as the search criteria because that's the one TableAdapter I was trying to modify in the first instance.
After some minutes, I was navigating the XSD at code level (it's just an XML) and to my surprise, I found an element named Connection and there was not one but TWO!. Just to make things clear, this file has been untouched by me till today (I mean, I did not touch it by hand, any changes had been made by the IDE)
The two connection strings were:
<Connection AppSettingsObjectName="Settings" AppSettingsPropertyName="localConStr"...
and
<Connection AppSettingsObjectName="Settings" AppSettingsPropertyName="loanConStr" ...
Yes, I know they look very alike, but notice they are local and loan. I decided to delete the second one (loanConStr) since it was not in my Settings file anymore (loanConStr was the original connection string left by my predecessor, localConStr was created by me so that I could switch connection strings in runtime instead of modifying the connection string and recompile every time I had to make a change and deploy again).
After that, I made sure all the DataTables in my DataSet used the same connection string (localConStr) and recompiled. I then tried the things that were giving me troubles:
First: I created a new DataTable: the action was successful
Second: I modified an existing DataTable: success again
Last, but not least, I tried to execute the report. I ran the app and went to the report and success! Apparently, my problem is solved.
What had happened? I am not sure, but if I had to guess, I would say that the TableAdapter was trying to use a connection string that pointed to a server that did not exist in my network (my client's server) so, every time I tried to configure it or change anything, Visual Studio was unable to contact that server and that's why I gor the connection error.
Why was the TableAdapter trying to use that connection string when the local connection string was explicitly specified? I don't know, but leavin IN THE XSD only one connection string was my solution.
As a side note, you might ask "But Compa, what will happen when the user wants to run a report that uses the localConStr?" Simple, I change the connection string at runtime when the report window is opened with the one being used by the whole app.
Sorry for the long post, and if you want a TL;DR version:
Go to your xds dataset file, delete any unwanted connection strings and then go to design view and make sure all your TableAdapters use the only ConnectionString specified in your xsd
It looks like you're seeing the database just fine. (Thus you get a list of stored procedures).
Try the rights on the procedure itself.
GRANT EXECUTE on [dbo].[rpt_loansAging] to [TheSqlAuthenticationUserNameWeCannotSeeInTheScreenShot]
APPPEND
Since you've tried everything else, try opening up a new VS project (Same version of VS and Target Framework) and try adding a TableAdapter in the same way.
If that works, then you got voodoo going on. You could delete and recreate them in the original project.
Every blue moon, something goes awry with Visual Studio, ESPECIALLY projects that started out as VS2003, were upgraded to VS2005, maybe upgraded to VS2010 (whatever combination).
I had a project that I upgraded from VS2003 to VS2005, and it built fine on my computer. On the build machine, it started failing........No idea what it was.
I ended up seeing some small anomaly in the "By Project" references. I simply removed all "By Project" references (within the .sln solution) ... and re-added the "By Project" references, and it fixed everything.
Go figure.

Constantly get The local data store is currently in use by another operation when working on small projects

I use Visual Studio Team Services to store the source code of my projects as I work on them, I love the service, especially that it is free, but I have been running into the biggest pain lately.
Randomly when I go to save, modify, check in check out I get this error for every single file I am modifying. So if I am trying to save changes to 8 files I get this message 8 times and it takes 45 60 seconds of trying to check out for each file meaning to takes 6 - 8 minutes for the errors to stop (even if I hit cancel).
The local data store is currently in use by another operation
I looked it up online and found many people with the same issue but the response from MS has nothing to do with my situation.
http://blogs.msdn.com/b/phkelley/archive/2013/05/31/tf400030-the-local-data-store-is-currently-in-use-by-another-operation.aspx
It basically says this can happen when you have to many files in your workspace or have several large solution open at once.
This does not apply to me as I usually only have on solution open at a time and my projects are very small (400 -500 files).
Ran into this issue as well on VS 2013 and TFS - every time I opened my team explorer it would take 10+ seconds to show all projects, then when I would expand the project in source control, another 10+ seconds would roll by.
Earlier today I began to experience the "local storage is being used" error when trying to save data in class files. I did some original research, and this following link saved the day for sure. Now TFS is blazing!
Local Data Store Solved
What you do is edit workspace (including all projects associated), and change the "Location" dropdown from "Local" to "Server". It took about 4-5 minutes for the changes to finish, but well worth it.
Hopefully this will help someone down the road.
Lately I started to get same error message and Visual Studio started to work very slow with TFS and nuget. I have tried repair and uninstall but not solve the problem. At the and it was so painfully slow that I cannot continue working. (Expanding one item on source control explorer takes 10 seconds)
Here is my story and how my problem be solved:
I was mapped tfs folders separately not to get whole TFS because there are lots of irrelevant documents. After trying lots of fix suggestion, I thought this might be the problem because I did this separate mapping first time while I have been using TFS. I generally map and get all items at once and never met this issue before.
I removed all mappings and it was like magic. Error is gone, slow TFS source control is gone and it is rocket fast now. Just to be in a safe side I also delete my workspaces and create a new one and get all TFS items at once.
I found the error would be triggered when I had more than once instance of VS 2012+ running utilizing Source Control Explorer, Solution Explorer and/or Team Explorer windows. I've not had this problem when running a single instance of VS 2012+ (on updates 2+) utilizing Source Control Explorer, Solution Explorer and/or Team Explorer windows in tandem.
I found this article and gave it's suggestion a shot: to prevent multiple threads from accessing the data store simultaneously.
http://blogs.msdn.com/b/phkelley/archive/2013/05/31/tf400030-the-local-data-store-is-currently-in-use-by-another-operation.aspx
This proved to be a remedy for this issue.
I would add for other users with large file repositories, using source control and share this issue, it may be greatly beneficial to create multiple workspaces for each of your branches/repositories. I found that by doing this my queries to TFS sped up immensely and also helped with this error. I found this suggestion here: http://blogs.msdn.com/b/phkelley/archive/2013/05/30/using-multiple-workspaces-with-visual-studio.aspx. I share this as users mention TFS running slowly.
I also started getting the same error this week. Maybe there's something wrong with VS Update 3?
Simply could not work on any of the projects of the "broken" local workspace anymore.
VS would show all files as being checked out, but none were really.
Other local workspaces were working fine.
I tried removing a project from the workspace, but when trying to confirm it, I would receive the same TF400030 error again.
Suggestion
If nothing else works, you might want to try this: simply delete the whole workspace and create it again, this time separating projects into different workspaces. This worked for me.
You'll probably want to back up your files first.
I did as mentioned below and TFS started working fine
Close all the VS instances
Go to: C:\Users[UserName]\AppData\Local\Microsoft\VisualStudio\15.0_46af8b8e
Delete the privateregistry.bin file
Reopen the project solution
Above worked for me.
Had the same problem,can be fixed in 3 quick steps:
Remove current Workspace: Source Control Explorer->Work Space ListBox->workspaces... and remove the workspace.
- Make sure that all pending changes are checked in
Delete Workspace local folder.
- Its Better to delete the folder entirely.If eventually keeping some folders make sure to delete all $tf folders (hidden folders inside the workspace folder)
Remap the projects you need ( the less the better )
Hopes that helps.
In my case the cause was a compressed folder containing my local data store, shown in blue in Windows explorer. Removing the compression did the trick.
I ran into this error when renaming my workspace. After changing back to original everything worked fine again
Restarting the Visual studio resolved the issue for me.

Visual Studio 2012 - corrupted .cs file

Few hours ago I started a new project. I pretty much finished it up, but I was making some performance tests with it. During those tests my PC suddenly crashed, so I needed to restart it.
After reboot, when I open my project, my main .cs file doesn't want to open! When I click on it in visual studio, it opens a blank notepad file! How do I retrieve my code from that file? Almost all of my code was in it...
Seems like it is not a VS related question but file recovery based one.
If you ever saved your file, chances are that you can recover them. Winhex is a good tool to recover deleted files. Here is how.
If you never saved, chances are very bleak.
I have same problem few days ago. My PC restart suddenly and all file that is opened in VS is no longer work.
Try to open this file in Sublime text and Notepad++. If this will open file then you can copy it otherwise their is no way to read that stream that is look like $$%%$%%$#^%#^$
What I do is coding back from backup copy and spent my few more hour to recover my work by doing it again.
I believe if your code is personal then you should backup it or try private git (bitbucket,github) somewhere so you can easily get your thing back instead of 100% total lose of data.

Categories

Resources