I like linqpad, but often when I need it, I have some data in Visual studio that I need to do stuff with.
Therefore I would love to know if it is possible to copy some list of data into Linqpad, creating the necessary classes and inserting the same values into the list, so I have real data to work with
So I would debug and get something like this in a breakpoint:
I then want those 5 items in a list in linqpad that I can work with
Check out LINQBridgeVs, it's a VS Extension that allows you to launch LINQPad from the VS debugger copying a complex data type over to a new LINQPad snippet along with the debug time data.
After installing the extension, enable the solution you're debugging, click the magnifier dropdown for the complex type and click LINQBridgeVS Visualizer from the context menu.
A new snippet will be opened in LINQPad with the data structure and debug time data ready to go.
Related
I'm doing an application on Visual Studio using an SQL Server database, the application is almost complete but I did a few changes on the database (added and deleted some rows) but when I'm trying to do the Schema Comparison to update the database on Visual Studio it doesn't let me choose a project as the target.
According to what I've found, it should show the project I'm working on, but instead I have this:
try to use directly database comparison and you will get the difference anyways
Don't you need to do it the other way round? So if you want to compare changes with the database so you can update the database (your target schema) you should be clicking 'Database' and doing it that way. That will show you the differences, which you can then choose to propagate to the database.
See here for more info.
I have code that generates SQL scripts that will run nightly. I want to check this into source control each night, so I get a history of changes to tables etc. as well as picking up new tables and when tables are deleted.
I have a team project created in Visual Studio Online.
From looking online it looks like there's no reliable way of automatically picking up changes locally and committing them to VSO. I'd have to create something that compares what I have locally to what is in VSO, which to me seems error-prone.
If I use the command line utility it looks like I have to tell it what is added and deleted (i can't just check everything out, then add/edit/delete my local files, then commit).
I've also looked into the Team Foundation Server class, but that's obsolete.
TL;DR: Is there anything I can to do easily sync local changes (add/edit/delete) to VSO, without having to tell it what's been changed?
Why not just check in the changed from your workspace?
If you have a Local Workspace that includes the folder that you generate the SQL into you can just call tf.exe checkin to get all of the changed into TFS.
+Daniel is right.
I am developing a new version of a Visual Studio extension. In the old version, the hotkeys were stored in the registry and I would like to import these settings into the new version of the software.
The new version uses .vsct format for defining menu commands and you can assign the hotkeys in the .vsct file. However, I can't use this mechanism, as I would like to import the user settings from the registry, whiles the .vsct is a static description.
When my VSPackage is initialized, I can read the old hotkeys from the registry, but I have problems assigning them to my menu commands defined in the .vsct file. I can get a hold on the OleMenuCommand interface and OleMenuCommandService, but they have no property where they can accept key bindings.
How one can assign hotkeys to menu commands programmatically?
A clunky workaround would be that the installer imports the hotkeys, writes them into the .vsct file, compiles the file and puts the .cto into the MyPackage.Resources.dll during the installation. But I'd rather not resort to this...
Though I define my commands through the .vsct file, I still can access them via the EnvDTE.Command interface.
// The commandGuid has to be the same GUID you use in the .vsct file, HOWEVER, you have to include the braces here
Command command = dte.Commands.Item(commandGuid, commandId);
command.Bindings = new object[] { "Global::Ctrl+Alt+Shift+1" };
It works. It is saved and remembered the next time Visual Studio starts up, so there is no need to import the old hotkeys every time.
Since I'm not allowed to comment [despite my 50 years of systems-level programming experience, including 3 books for MS Press :( ], I have to ask this way for Shakaron to post some more of his code. I added a short tree of menu commands to the VS 2015 Tools menu (1-4-1 elements). An enumeration of dte.Commands didn't show any of them. Calling Commands.Item with a string (or an "object" to which I'd assigned a string) containing the GUID, both with and without {}, generated an invalid argument exception.
So, either the EnvDTE80 interface is incredibly fragile, the documentation is wildly wrong, or else Shakaron's solution has some more magic that we haven't seen yet. And I was so hopeful that this would be the last piece of my puzzle...
Answering Shakaron's questions:
I used the .vsct file to add 1 menu with 3 commands and 1 submenu, which in turn had 1 command.
Calling Commands.Item with a guid and an index argument caused an apparently identical invalid argument exception. I was able to enumerate the collection, but my commands were not in the set.
I also couldn't compile your code for the right-hand-side of the Bindings assignment. But, of course, I didn't get that far because I couldn't find the command item in the first place.
There has to be a version dependency at work here. I don't doubt that your code worked a year ago, but I ran into the problems I described using a fresh-out-of-the-virtual-box copy of VS 2015 running on Win 10.
For the tl;dr crowd:
What is causing type names to be written to the output window if it isn't Console.WriteLine or Debug.Print statements in the code? Is it the Visual Studio debugger? and
How can I turn it off?
Background and details:
I am trying to debug a program that imports CSV files into a database. Recently, I changed how I include 3rd party library dependencies. Previously, I was referencing the downloaded binary files. Now, if a 3rd party library has source code available, such as NHibernate, the project is included in my solution to be compiled along with the projects I have written myself.
Since the change, I am seeing a lot of single lines containing only a type name in the Output/Debug window that I didn't used to see before. My program is a data importer, and the main loop is causing these lines to appear 1000s of times, slowing down debugging and polluting the output window. Specifically, there are a lot of lines that say this:
NHibernate.Driver.NHybridDataReader
I have traced the code, and it seems that this is displayed whenever NHibernate is reading results back from the database. However, the line isn't output in code by the NHibernate library, so it must be coming from somewhere else. My guess is that the Visual Studio Debugger is writing it to the output window, similar to what happens during assembly binding.
I have tried compiling the NHibernate project in Release mode and everything else in Debug mode, but that didn't fix it. I also tried unchecking "Enable the Visual Studio hosting process" for just the NHibernate project, but that didn't work either.
In summary, my questions are:
What is writing type names to the output window if it isn't Console.WriteLine or Debug.Print statements in the code? and
How can I turn it off?
What my question is not
My question is NOT about a better way to write the data importer program so that the needed data is preloaded from the database. I know the code I have written is slow; in this particular case, in production, that is okay. What I want is to stop polluting the debug window with tons of unneeded type information. The work loop of my program causes the types to be written 1000s of times for long CSV files, which makes the output hard to use, and slows the debugger down as it tries to sync the output window. THIS is what I am trying to prevent. But I'm not sure how to do that, because I'm not even sure where the messages are coming from.
It's difficult to make suggestions without being able to see the code, but what I would do to debug it is install the trial version of RedGate's Reflector and use it to add breakpoints to the Debug.* and Console.* functions. If one of the breakpoints is hit, you can trace back up the call stack to find what is actually adding the lines to the output. If none of those methods are causing the lines to be added, maybe add breakpoints to DefaultTraceListener and TextWriter.
I haven't come across anything else which can add messages to the Visual Studio output window at run time.
I think this is irrelevant, though it solved my seemingly unrelated problem a while back (I had automated tests randomly failing and printing to console). I had to uncheck Visual Studio's "Enable property evaluation and other implicit function calls" under the Debugging menu in Options. Sorry if this is off topic/unhelpful!
EDIT: Also, have you tried changing the 'Output Window' settings in the Debugging section? You could maybe turn all debug output off and print your own debugging to a file.
I have a solution that uses a native .DLL library that is wrapped by a .NET .DLL with a C# GUI.
All my plumbing works just fine in Debug mode. The moment I try going to Release mode, I get a whole whack of error messages, largely to do with the .CPP files in the native library. Errors include the following:
definition of dllimport function not allowed
TRACE_DEBUG_METHOD_CALL: identifier not found
a lot of undeclared identifiers in my main .CPP file (eg: DLLAPI_Release: undeclared identifier)
I have to admit that the Properties configuration for a C/C++ project is overwhelming so I wonder if there is one or more simple settings somewhere that I simply need to modify.
ALSO, is there a book out there that is devoted to the project properties window in VS2010 specifically? I have a few books but none really spend anytime on what is obviously a very crucial component to serious app development.
I appreciate any assistance anyone can offer. Thanks!
This is not unlikely to happen when you made a bunch of setting changes but didn't also make them for the Release build. Easy to forget, the first time anyway. You can easily tell which settings were changed from the default, they are displayed in bold type. Step through the setting pages, flip back-and-forth with the Configuration combobox in the upper left corner.
About 15 minutes of your life, not counting the thinking time you need because the setting should be different for the Release build. Start another instance of Visual Studio with a dummy project to verify that.
Trying to compare the property pages can be a beating. My recommendation would be to open the property pages for your project, select the Debug configuration, and under "C/C++", select "Command Line" and copy the command line options into a text editor, then do the same for the Release configuration and see where they differ. You'll need to do the same for the "Linker" command line.
Some of the differences will be intentional (e.g. debug flags should be set for the Debug configuration), but you should be able to spot things that should be the same but are not.
Actually tracking down where the command line options are set can be a bit of a pain, especially if you are using property sheets to manage common properties between projects, but generally you should be able to track them down just by looking through the different options on the different pages.
As for a reference, the best reference is the actual compiler documentation on MSDN. There is a section containing all of the documented compiler options and one containing all of the documented linker options.
The property pages are just a GUI frontend for setting these various options. When you select one of the properties in the property pages, it should say in the help box at the bottom of the dialog which compiler options are used by that property.